akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

map<int,int> memo;
int dfs(int mask){
  if(mask == 0) return 0;
  if(__builtin_popcount(mask)==1) return INF;
  if(memo.count(mask)>0) return memo[mask];
// dbg(mask);
  int ret = INF;
  for(int nmask = mask; nmask>0; nmask = (nmask-1)&mask){
    int x = 0;
    rep(i,16) if(nmask>>i&1) x ^= i;
    if(x == 0){
      int r = dfs(mask - nmask);
      ret = min(ret, r + __builtin_popcount(nmask) - 1);
    }
  }
  return memo[mask] = ret;
}

int main(){
  int n;
  cin>>n;
  vector<int> v(n, 0);
  rep(i,n-1){
    int x,y,a;
    cin>>x>>y>>a;
    v[x] ^= a;
    v[y] ^= a;
  }

  vector<int> cnt(16, 0);
  rep(i,n){
    cnt[v[i]]++;
  }

  int ans = 0;
  int mask = 0;
  rep(i,1,16){
    ans += cnt[i]/2;
    if(cnt[i]%2) mask |= (1<<i);
  }

  int r = dfs(mask);
  assert(r<INF);

  cout << ans + r << endl;

  return 0;
}


Measured memory_bytes: 768
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <array>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T, typename U>
using P = pair<T, U>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define DOUBLE(n) static_cast<double>(n)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
// Usual REP runs from 0 to n-1 (R: n-1 to 0)
// Natural REP runs from 1 to n (R: n to 1)

/* ---------- ここまでマクロ ----------*/

// bのn乗を再帰的に求める
ll mypow(ll b, ll n) {
    return n == 0 ? 1 : b * mypow(b, n - 1);
}

// 桁和を求める(B問題を参照)
ll dsum(ll n) {
    ll ret = 0;
    while (n > 0) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

// n以上で最小のすぬけ数を求める
ll snuke(ll n) {
    GPQ<P<double, ll>> val;
    // 逆順priority_queue, 一番上が最小の要素
    // (g(m), m)

    ll dig = 0;
    // 9が連続する桁数

    while (mypow(10, dig) <= n) {
        NREP(i, 9) {
            ll v = n - n % mypow(10, dig) + i * mypow(10, dig) - 1;
            // 下dig桁が9
            // 1つ上は1~9
            // それより上はnと一致

            if (v >= n) {
                val.push(make_pair(DOUBLE(v) / dsum(v), v));
            }
        }
        dig++;
    }
    
    dig--;
    NREP(i, 100) {
        ll v = i * mypow(10, dig) - 1;
        if (v >= n) {
            val.push(make_pair(DOUBLE(v) / dsum(v), v));
        }
    }

    auto ret = val.top();
    // g(m)とmが最小となる(g(m), m)の組

    return ret.second;
}


int main() {
    ll K;
    cin >> K;
    ll pre = 1;
    REP(_, K) {
        cout << pre << endl;
        pre = snuke(pre + 1);
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#define findmax(a,b) (a)>(b)?(a):(b)
#define findmin(a,b) (a)<(b)?(a):(b)
#define inout freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)
#define swap(a,b) (a)+=(b);(b)=(a)-(b);(a)-=(b)
#define quicksort(a,n) qsort(a,n,sizeof(a[0]),cmp)
#define inputarr(a,n) for(int i=0;i<n;i++){scanf("%d",&a[i]);}
#define printarr(a,n) for(int i=0;i<n;i++){printf("%d ",a[i]);}puts("");
int cmp(const void *a,const void *b){return *(int *)a - *(int *)b;}

int main() {

	//inout;

	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d", a*b);


}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 200'000
i64 N, P;
string A;

int main() {
    cin >> N >> P;
    cin >> A;

    if (10 % P == 0) {
        i64 cnt = 0;
        REP(r, N) {
            if ((A[r] - '0') % P == 0) {
                cnt += r + 1;
            }
        }
        cout << cnt << endl;
        return 0;
    }

    vector<i64> C(N + 1, 0);
    i64 ten = 1;
    for (i64 i = N - 1; i >= 0; i--) {
        C[i] = (C[i + 1] + (A[i] - '0') * ten) % P;
        ten *= 10; ten %= P;
    }

    i64 cnt = 0;
    vector<i64> dist(P);
    for (i64 i = N; i >= 0; i--) {
        cnt += dist[C[i]];
        dist[C[i]]++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 2196
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 29/07/2017 13:11:30
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define POB pop_back
#define dist(a, b) sqrt(a*a + b*b)
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vipi;
bool compare(pi p1, pi p2){
	 if(1) return true;
	 return false;
}

map<int, bool> w;

vector<vi> graph(200001);

void dfs(int a, int h){
	w[a] = true;
	if(h == 2) return;
	
//	cout<<"dfs de "<<a<<endl;
	for(int i = 0; i < graph[a].size(); i++){
//		cout<<graph[a][i]<<endl;
		if(w[graph[a][i]] == true) continue;
//		w[graph[a][i]] = true;
		dfs(graph[a][i], h+1);
	}
}


int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	int n, m;
	cin>>n>>m;
	for(int i = 0; i < m; i++){
		int a, b;
		cin>>a>>b;
		graph[a].PB(b);
		graph[b].PB(a);
	}
	dfs(1, 0);
//	for(int i = 1; i <= n; i++){
//		cout<<i<<" = ";
//		for(int j = 0; j < graph[i].size(); j++) cout<<graph[i][j]<<" ";
//		cout<<endl;
//	}
//	for(int i = 1; i <= n; i++) cout<<w[i]<<" ";
	if(w[n] == true) cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
	return 0;
}


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

int n, a[1025][1025], vis[1025];
bool flag;
bool ok() {
  for (int i = 1; i <= n; i++)
    if (a[i][0] != n) return 0;
  return 1;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n - 1; ++j) cin >> a[i][j];
    a[i][0] = 1;
  }
  for (int z = 0; z <= 0x3f3f3f3f; z++) {
    if (ok()) {
      cout << z << '\n';
      return 0;
    }
    flag = 0;
    memset(vis, 0, sizeof vis);
    for (int i = 1; i <= n; i++) {
      if (vis[i] || a[i][0] == n) continue;
      int x = a[i][a[i][0]];
      if (a[x][a[x][0]] == i && !vis[i] && !vis[x]) {
        a[i][0]++;
        a[x][0]++;
        vis[i] = vis[x] = 1;
        vis[i]++;
        flag = 1;
        vis[i]--;
      }
    }
    if (!flag) {
      cout << -1 << '\n';
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 4352
import math
a, b, h, m = map(int, input().split())

t = h * 60 + m
th_a = (0.5 * t) % 360
th_b = (6.0 * t) % 360
th = min(abs(th_a - th_b), 360 - abs(th_a - th_b))
# print(th_a, th_b, th)
th = (th / 360) * (2 * math.pi)

c = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(th))
print(c)


Measured memory_bytes: 9476
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int f(int i, int j) {
    return 7 * i + j + 1;
}

void solve() {
	int n, k; cin >> n >> k;
    if(n <= 2) {
        cout << 0 << endl;
        return;
    }
    n -= 3;
    vector<int> v(11, 0), vs(12, 0);
    for(int i = 0; i < 11; ++ i) {
        for(int j = 0; j < 5; ++ j) {
            int tmp = 0;
            rep(k, 3) {
                rep(l, 3) {
                    tmp += f(i + k, j + l);
                }
            }
            if(tmp % 11 == k) {
                v[i] ++;
            }
        }
        vs[i + 1] = vs[i] + v[i];
    }
    int ans = n / 11 * vs[11] + vs[1 + n % 11];
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0); 
	int t=1,q;
	//cin>>t;
	for(q=1;q<=t;q++)
	{
		int n,w,i,j;
		cin>>n>>w;
		long long int a[n],dp[w+1]={0},b[n],m=0;
		for(i=0;i<n;i++)cin>>a[i]>>b[i];
		for(i=0;i<n;i++)
		{
			for(j=w;j>0;j--)
			{
				if(j-a[i]>=0)dp[j]=max(dp[j],dp[j-a[i]]+b[i]);
			}
		}
		for(i=1;i<=w;i++)m=max(m,dp[i]);
		cout<<m<<"\n";
	}
	return 0;
}

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

int main() {

  int N;
  cin >> N;
  string S[N];
  for(int i = 0; i<N ;i++){
    cin >> S[i];
  }

  int AC=0;
  int WA=0;
  int TLE=0;
  int RE=0;

  for(int i = 0; i < N ; i++){
    if(S[i] == "AC"){
      AC +=1;
    }
    else if(S[i] == "WA"){
      WA +=1;
    }
    else if(S[i] == "TLE"){
      TLE +=1;
    }
    else{
      RE +=1;
    }
  }

  cout << "AC" << " x " << AC << endl;
  cout << "WA" << " x " << WA << endl;
  cout << "TLE" << " x " << TLE << endl;
  cout << "RE" << " x " << RE << endl;

return 0;
}

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

int main(){
  int64_t X;
  cin >> X;
//  A^5-B^5=X;
//  (A-B)(A^4+A^3B+A^2B^2+AB^3+B^4)=X;
  int64_t F4=(int64_t)pow(X, 0.25)+1;
  int64_t F5=(int64_t)pow(X, 0.2)-1;
  for(int64_t i=0; i<=F4; i++){
    int64_t B=(int64_t)pow(i, 5)-X;
    if(B>=0){
      int Q=(int64_t)sqrt(B);
      for(int64_t j=0; j<=Q; j++){
        if((int64_t)pow(j, 5)==B){
          cout << i << " " << j << endl;
          goto finish;
        }
      }
    }
    if(B<0){
      int64_t E=-B;
      int64_t Q=(int64_t)sqrt(E);
      for(int64_t j=0; j<=Q; j++){
        if((int64_t)pow(j, 5)==E){
          cout << i << " " << -j << endl;
          goto finish;
        }
      }
    }
  }
finish: X=0;
}

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

int main(){
	int N;
	cin >> N;
	int X[N], Y[N];
	rep(i,N) {
		int x;
		cin >> x;
		X[i] = x;
		Y[i] = x;
	}
	sort(Y, Y+N);
	rep(i,N) {
		if (X[i] <= Y[N/2-1]) cout << Y[N/2] << endl;
		else cout << Y[N/2-1] << endl;
	}

return 0;
}


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

//vector…可変長、データの大きさに合わせてサイズを変える
//list…双方向リスト、要素を挿入、削除の多いとき
//forward_list
//array…固定長配列
//set…集合
//multiset
//bitset…2進数、固定長ビット列
//map…連想配列、キーと値を関連付ける
//multimap
//deque…双方向リスト
//stack…FILO, 深さ優先探索
//queue…FIFO, 幅優先探索
//priority_queue…格納された最大値から順に取り出す
//pair…二つの値を一組
//tuple…複数の値を一組

const int mod = 1e9+7;

template<typename T>
void remove(std::vector<T>& vector, char index) {
    vector.erase(vector.begin() + index);
}

template<class T>
T ma(std::vector<T> &v) {
    T maxi = 0;
    for(auto &i:v) maxi = max(maxi, i);
    return maxi;
}
template<class T>
T mi(std::vector<T> &v) {
    T mini = 0;
    for(auto &i:v) mini = min(mini, i);
    return mini;
}
template <class T>
T pow(T x, T y, T n = numeric_limits<T>::max()) {
    if(y == 0) return 1;
    if(y % 2 == 0) return pow((x * x) % n, y / 2);
    return (x * pow(x, y - 1)) % n;
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return !y ? x : gcd(x % y, y);
}

using Graph = vector<vector<int>>;

template <class T, class S>
class Edge {
  T to;  //辺の行き先
  S weight;  //辺の重み

public:
  Edge(T t, S w) : to(t), weight(w) {}
};

int ansi = 0;
ll ansl = 0;
double ansd = 0.0;

int accumul(int mul) {
  if (mul == 0) {
    return 1;
  } else {
    return mul * accumul(mul-1);
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  vector<int> memo(n);
  rep(i, 0, n-1) {
    cin >> A[i];
    memo[i] = A[i];
  }

  sort(memo.rbegin(), memo.rend());

  rep(i, 0, n-1) {
    if (A[i] == memo[0]) {
      cout << memo[1] << endl;
    } else {
      cout << memo [0] << endl;
    }
  }
}


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


int main(){
	auto read_string 	=	[](){ string s; cin >> s; return s; };
	auto read_int       =   [](){ int tmp; cin >> tmp; return tmp; };
	auto read_char      =   [](){ char c; cin >> c; return c; };
	auto str_repeat	 	=	[](string a,int count){	string res = ""; for(size_t i = 0 ; i < count ; i++) res += a; return res;	};
	auto to_lower_case 	= 	[](string s){ string res=""; for(size_t i = 0 ; i < s.size() ; i++) res += tolower(s[i]); return res; };
	auto to_upper_case 	= 	[](string s){ string res=""; for(size_t i = 0 ; i < s.size() ; i++) res += toupper(s[i]); return res; };
	auto read_vec_int   =   [](int count){ vector<int> tmp(count); for(size_t i = 0 ; i < count ; i++) cin >> tmp[i]; return tmp; };
	auto title_case     =   [](string s) { string ret = ""; ret+=toupper(s[0]); ret += s.substr(1); return ret; };

	int a , b ;
	scanf ("%d%d" , &a , &b ) ;
	printf("%d\n " , a%b != 0 ) ;

//	int n=read_int(),k=read_int();
//
//	if(k > n){
//			cout <<  "1" << endl;
//			exit(0);
//	}
//
//	if(n==k || n%k == 0){
//		cout <<  "0" << endl;
//		exit(0);
//	}
//
//
//
//	int min = n / k;
//	int max = (n/k) + (n%k);
//	cout <<  (max-min)<< endl;
	return 0;
}


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

#define MAX 1000
int dp[MAX+1][MAX+1];

int lcs(string X, string Y){
    int m = X.size();
    int n = Y.size();
    for(int i = 0; i <= m; i++) dp[i][0] = 0;
    for(int j = 0; j <= n; j++) dp[0][j] = 0;

    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            if(X[i-1] == Y[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }else{
                dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }

    return dp[m][n];
}

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

    string X, Y;

    for(int i = 0; i < q; i++){
        cin >> X >> Y;
        cout << lcs(X,Y) << endl;
    }

    return 0;

}


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

//bucketmethod

int main() {
  string str;
  cin >> str;
  int bucket[26]={0};
  rep(i,str.size()) bucket[str[i]-'a']++;
  rep(i,26) {
    if(bucket[i]==0){
      cout<<(char)(i+'a')<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;
 
}


Measured memory_bytes: 512
#include<stdio.h>
int d[100];
int main(){
int a,b,c,e;
scanf("%d%d%d",&a,&b,&c);
d[1]=a+b;
d[2]=a+c;
d[3]=b+c;
e=d[1];
for(int i=1;i<=3;i++){
    if(e>d[i])e=d[i];
}
printf("%d\n",e);

}

Measured memory_bytes: 760
#include <iostream>
using namespace std;
int count(int x, int c){
    if(x >= 500){
        return count(x-500, c+1);
    }
    if(x >= 100){
        return count(x-100, c+1);
    }
    if(x >= 50){
        return count(x-50, c+1);
    }
    if(x >= 10){
        return count(x-10, c+1);
    }
    if(x >= 5){
        return count(x-5, c+1);
    }
    if(x == 0){
        return c;
    }
    else {
        return count(x-1,c+1);
    }
}

int main (void){
    int x;
    while (true){
        cin >> x;
        if(x == 0) {
            break;
        }
        cout << count(1000 - x, 0) << endl;
    }
}



Measured memory_bytes: 3016
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize)(list:[i64]));
    let max = list.clone().into_iter().max().unwrap();
    let min = list.clone().into_iter().min().unwrap();

    let mut res = <i64>::max_value();
    for x in min..max + 1 {
        res = std::cmp::min(res, f(list.clone(), x));
    }

    res.to_string()
}

fn f(list: Vec<i64>, n: i64) -> i64 {
    list.into_iter().map(|x| (x - n) * (x - n)).sum()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "2\n4 8" => "8",
    test2: "3\n1 1 3" => "3",
    test3: "3\n4 2 5" => "5",
    test4: "4\n-100 -100 -100 -100" => "0",
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n,i,j;
	int a[110];
	scanf("%d",&n);
	for(i=0;i<n;i++){scanf("%d",&a[i]);}
	sort(a,a+n);
	int maks = a[0];
	int cnt = 1;
	for(i=1;i<n;i++){
		if(maks<a[i]){
			maks = a[i];
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
};

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dfs(vector<vector<int>>&edges,vector<bool>&visited,vector<int>&longest_path,int i){
  if(!visited[i]){
    visited[i]=true;
    int ans=-1;
    for(auto j:edges[i]){
      ans=max(ans,dfs(edges,visited,longest_path,j));
    }
    return longest_path[i]=1+ans;
  }
  else return longest_path[i];
}
int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>>edges(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    edges[a].push_back(b);
  }
  vector<bool>visited(n,false);
  vector<int>longest_path(n,-1);
  for(int i=0;i<n;i++)
  dfs(edges,visited,longest_path,i);
  int ans=0;
  for(auto i:longest_path)ans=max(i,ans);
  cout<<ans<<endl;
}

Measured memory_bytes: 12296
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;++i) {
        cin >> a[i];
    }

    for(int i=k;i<n;++i) {
        cout << ((a[i-k] < a[i]) ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
const int mo = 1e9 + 7;
int main()
{
    int n, k;
    cin >> n >> k;
    long long ans = 0;
    for (int i = k; i <= n + 1; i++) {
        long long l = 1ll * i * (i - 1) / 2, r = 1ll * (n + n + 1 - i) * i / 2;
        ans += r - l + 1;
        ans %= mo;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3632
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    S = input()
    cnt = 0
    for i in range(1000):
        ptn = str(i).zfill(3)
        j = 0
        flg = 0
        while j < N:
            if S[j] == ptn[flg]:
                flg += 1
                if flg == 3:
                    cnt += 1
                    break
            j += 1
    print(cnt)


if __name__ == '__main__':
    main()

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

using namespace std;

int n,i;
long long a,b;

int main(){
	scanf("%d", &n);
	scanf("%d%d", &a, &b);
	
	for(i = 0; i < n - 1; i++){
		int x,y;
		scanf("%d%d", &x, &y);
		long long t = (a - 1) / x + 1;
		long long t1 = (b - 1) / y + 1;
		
		long long now = max(t, t1);
		a = now * x;
		b = now * y;
	}
	
	printf("%lld\n", a + b);
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int l,k,j,array1[101],array2[101][101];
  int num,i;  
scanf("%d",&num);
  for(i = 1;i <= num;i++){
    scanf("%d%d",&array1[i-1],&array1[i]);
  }
 
  for(i = 1; i <= num;i++){
    array2[i][i] = 0;
  }
   
  for(k = 2;k <= num;k++){
    for(i = 1;i <= num - k + 1;i++){
      j = i + k - 1;
      array2[i][j]=(1<<21);
      for(l = i;l <= j - 1;l++){
	if(array2[i][j] > array2[i][l] + array2[l+1][j] + array1[i-1] * array1[l] * array1[j]){
	  array2[i][j] = array2[i][l] + array2[l+1][j] + array1[i-1] * array1[l] * array1[j];
	}
      }
    }
  }
  printf("%d\n",array2[1][num]);
  
  return 0;
}

Measured memory_bytes: 636
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main(void)
{
    int x,i,n;
    
    scanf("%d",&n);
    
    for(i=1; i<=n; i++) {
        x = i;
        
        if(x %3 == 0) {
            printf(" %d",i);
        } else if(x % 10 == 3) {
            printf(" %d",i);
        } else {
            while(x != 0) {
                x /=10;
                if(x % 10 == 3) {
                    printf(" %d",i);
                    break;
                }
            }
        }
        
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2096
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=10000000;
int n,d1,d2,cnt,i,j,k,x,y,Head[N],Adj[N],Nxt[N],l,v1[N],v2[N],head[N],adj[N],nxt[N],g[10][10];
int Id(int x,int y)
{
	return x*2*n+y+1;
}
void Addedge(int u,int v)
{
	Adj[++l]=v;
	Nxt[l]=Head[u];
	Head[u]=l;
	Adj[++l]=u;
	Nxt[l]=Head[v];
	Head[v]=l;
}
void addedge(int u,int v)
{
	adj[++l]=v;
	nxt[l]=head[u];
	head[u]=l;
	adj[++l]=u;
	nxt[l]=head[v];
	head[v]=l;
}
void dfs(int x)
{
	for(int y=Head[x];y;y=Nxt[y])
		if(!v1[Adj[y]])
		{
			v1[Adj[y]]=(v1[x]==1?2:1);
			dfs(Adj[y]);
		}
}
void Dfs(int x)
{
	for(int y=head[x];y;y=nxt[y])
		if(!v2[adj[y]])
		{
			v2[adj[y]]=(v2[x]==1?2:1);
			Dfs(adj[y]);
		}
}
int main()
{
	scanf("%d%d%d",&n,&d1,&d2);
	if(d1>d2)
		swap(d1,d2);
	for(i=0;i*i<=d1;++i)
	{
		j=(int)sqrt(d1-i*i);
		if(i*i+j*j!=d1)
			continue;
		for(x=0;x<2*n;++x)
			for(y=0;y<2*n;++y)
			{
				if(i==0)
				{
					if(y+j<2*n)
						Addedge(Id(x,y),Id(x,y+j));
				}
				else
				{
					if(x+i<2*n)
					{
						if(y+j<2*n)
							Addedge(Id(x,y),Id(x+i,y+j));
						if(y-j>=0&&j)
							Addedge(Id(x,y),Id(x+i,y-j));
					}
				}
			}
	}
	l=0;
	for(i=0;i*i<=d2;++i)
	{
		j=(int)sqrt(d2-i*i);
		if(i*i+j*j!=d2)
			continue;
		for(x=0;x<2*n;++x)
			for(y=0;y<2*n;++y)
			{
				if(i==0)
				{
					if(y+j<2*n)
						addedge(Id(x,y),Id(x,y+j));
				}
				else
				{
					if(x+i<2*n)
					{
						if(y+j<2*n)
							addedge(Id(x,y),Id(x+i,y+j));
						if(y-j>=0&&j)
							addedge(Id(x,y),Id(x+i,y-j));
					}
				}
			}
	}
	for(i=1;i<=4*n*n;++i)
		if(!v1[i])
		{
			v1[i]=1;
			dfs(i);
		}
	for(i=1;i<=4*n*n;++i)
		if(!v2[i])
		{
			v2[i]=1;
			Dfs(i);
		}
	for(i=1;i<=4*n*n;++i)
		g[v1[i]][v2[i]]++;
	for(x=1;x<=2;++x)
	for(y=1;y<=2;++y)
	if(g[x][y]>=n*n)
	{
		for(i=1;i<=4*n*n&&cnt<n*n;++i)
		if(v1[i]==x&&v2[i]==y)
		{
			printf("%d %d\n",(i-1)/(2*n),(i-1)%(2*n)),++cnt;
		}
		break;
	}
	return 0;
}


Measured memory_bytes: 116096
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;


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

    int n, k;
    cin >> n >> k;
    cout << ((n % k == 0) ? 0 : 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);

    if (n % 10 == 7 || n/ 10 % 10 == 7 || n / 100 % 10 == 7)
    {
        printf("Yes");
    }
    else
        printf("No");

    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<limits.h>
#define LIM  667000
int P,C[6] = {1,5,10,50,100,500};
int N[6],R[6],limit;
int clerk[LIM];
int i,j;
   
 
int getChange(int sum){ // clerk
  int ret = 0;
  int l;
  for(l=5;l>=0;l--){
    if(sum >= C[l]){
      ret += sum/C[l];
      sum -= sum/C[l]*C[l];
    }   
  }
  return ret;
}
 
int getChangeBy(int sum){
  int ret = 0;
  int index = sum;
  int e;
  for(e = 0;e<6;e++)R[e] = 0;
  for(e=5;e>=0;e--){
    if(sum >= C[e] && N[e] != 0){
      R[e] = sum/C[e]>N[e]?N[e]:sum/C[e];
      sum -= R[e]*C[e];
ret += R[e];     
    }
  }
  if(sum != 0)return -1;
  return ret;
}
 
void createChange(){
  for(i=0;i<LIM;i++)clerk[i] = 0;
  int B,f;
  for(f=1;f<666001;f++){ 
    B = getChange(f);
    clerk[f] = B;
    //if(f < 100)printf("%d\n",clerk[f]);
  }
 
}
 
 
int main(){
  createChange();
  
  while(scanf("%d",&P) && P){
    int cnt,pay,ans,res;
 
  
     
     limit = 0;
     int u;
     for(u=0;u<6;u++){
       scanf("%d",&N[u]);
        
       limit += N[u]*C[u];
     }
 
     
    ans = INT_MAX;
    for(i=0;i<limit;i++)clerk[i] = -1;
    for(i=P;i<=limit;i++){
      cnt = getChangeBy(i);
      if(cnt == -1 || ans <= cnt)continue;
      pay = 0;
      for(j = 0;j<6;j++)pay += C[j]*R[j];
      if(clerk[pay-P] == -1)clerk[pay-P] = getChange(pay-P);
      if(cnt+clerk[pay-P] < ans){
    ans = cnt+clerk[pay-P];
      }
    }
    printf("%d\n",ans);
 
  }
  return 0;
}

Measured memory_bytes: 3204
#include <stdio.h>

int main (void){
    int i,ans=0;
    int N; 

    scanf("%d",&N);

    int V[N],C[N]; 

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

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

    for(i=0;i<N;i++){
        if(V[i] > C[i]){
            ans = ans + V[i] - C[i];
        }
    }

    printf("%d\n",ans);

    return 0;
}

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


int main()
{
    string s,t;
    cin >>s >> t;

    vector<vector<int>> dp(s.length()+1,vector<int>(t.length()+1)); 
    for(int i=0;i<=s.length();i++)
    {
        for(int j=0;j<=t.length();j++)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0; 
            }
            else if(s[i-1]==t[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]); 
            }
        }
    }
    /*
    for(int i=0;i<=s.length();i++)
    {
        for(int j=0;j<=t.length();j++)
        {
            cout <<dp[i][j]<< " "; 
        }
        cout <<endl; 
    }
    */
    vector<char> res(dp[s.length()][t.length()]); 
    int i=s.length();
    int j=t.length(); 
    int idx=dp[s.length()][t.length()]; 
    while(i>0 && j>0) 
    {
        if(s[i-1] == t[j-1])
        {
            res[idx-1] = s[i-1]; 
            i--;
            j--; 
            idx--; 
            
        }
        else if(dp[i-1][j] > dp[i][j-1])
        {
            i--; 
        }
        else 
        {

            j--; 
        }

    }
    //cout<<dp[s.length()][t.length()]; 
    string op(res.begin(),res.end()); 
    cout << op <<endl;

    return 0; 
}



Measured memory_bytes: 35712
N,Y = map(int,input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z_m = Y-(10000*x+5000*y)
        z_n = N-x-y
        if z_m >=0 and z_m//1000 == z_n:
            print(x,y,z_n)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
#include<stdio.h>
typedef struct{
  char sub;
  int figure;
}card;
void bubble(card [],int);
void selection(card [],int);
int stable_cor(card [],card [],int);
void swap(card *,card *,int);
int main(){
  int number;
  int i;
  int flag;
  card cards[36],cards1[36];
  scanf("%d%*c",&number);
  for(i=0;i<number;i++){
    scanf("%c%d%*c",&cards[i].sub,&cards[i].figure);
    cards1[i].sub=cards[i].sub;
    cards1[i].figure=cards[i].figure;
  }
bubble(cards,number);
selection(cards1,number);
flag=stable_cor(cards,cards1,number);
for(i=0;i<number;i++){
  printf("%c%d",cards[i].sub,cards[i].figure);
  if(i<number-1)printf(" ");
  else printf("\n");
}
printf("Stable\n");
for(i=0;i<number;i++){
  printf("%c%d",cards1[i].sub,cards1[i].figure);
  if(i<number-1)printf(" ");
  else printf("\n");
}
if(flag!=1)printf("Stable\n");
else printf("Not stable\n");
return 0;
}
void swap(card *a,card *b,int n){
card c;
c=*a;
*a=*b;
*b=c;
}
int stable_cor(card a[],card b[],int n){
int i;
int flag=0;
  for(i=0;i<n;i++){
    if(a[i].sub!=b[i].sub)flag=1;
  }
  return flag;
}
void bubble(card b[],int n){
int i;
int j;
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(b[j].figure<b[j-1].figure)swap(&b[j],&b[j-1],j);
    }
  }
}
void selection(card s[],int n){
  int i;
  int j;
  int min;
  for(i=0;i<n-1;i++){
    min=i;
    for(j=i;j<n;j++){
      if(s[j].figure<s[min].figure)min=j;
    }
    if(min!=i)swap(&s[i],&s[min],min);
  }
}



Measured memory_bytes: 2068
#include <stdio.h>
int main(){
 int N;
 scanf("%d",&N);
 int A[N];
 int judge=1;
 for(int i=0;i<N;i++){
  scanf("%d",&A[i]);
  if(A[i]%2==0){
  if(A[i]%3==0||A[i]%5==0);
   else judge=0;
   }
 }
 if(judge==1)printf("APPROVED");
   else printf("DENIED");
 return 0;
}

Measured memory_bytes: 2108
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scd(x) scanf("%lf", &x)
#define scld(x) scanf("%Lf", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

const int sz = 1e6+5;
bool done[sz];

int main() {
	int N;
	sci(N);
	vi arr(N);
	for (int i = 0; i < N; ++i) {
		sci(arr[i]);
	}
	done[0] = 1;
	int breaks = 0;
	for (int i = 0; i < N; ++i) {
		if (done[arr[i]-1] && !done[arr[i]]) {
			done[arr[i]] = 1;
		} else {
			++breaks;
		}
	}
	if (done[1]) {
		printf("%d\n", breaks);
	} else {
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 1280
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var preOrder = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var inOrder = Console.ReadLine().Split().Select(int.Parse).ToArray();

        Console.WriteLine(string.Join(" ", Reproduce(preOrder, inOrder)));
    }

    static IEnumerable<int> Reproduce(int[] preOrder, int[] inOrder)
    {
        if (preOrder.Length == 0) return Enumerable.Empty<int>();
        var root = preOrder[0];
        var lCount = Array.IndexOf(inOrder, root);
        var l = Reproduce(
                preOrder.Skip(1).Take(lCount).ToArray(),
                inOrder.Take(lCount).ToArray()
            ).ToArray();
        var r = Reproduce(
                preOrder.Skip(1 + lCount).ToArray(),
                inOrder.Skip(lCount + 1).ToArray()
            ).ToArray();
        return l.Concat(r).Concat(new int[] { root });
    }
}


Measured memory_bytes: 18308
#include<bits/stdc++.h>
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define ret return
#define all(vl) vl.begin(),vl.end()
#define sor sort 
#define cl clear()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
typedef double dou;
#define int ll
ll gcd(ll a,ll b)
{
	return (b == 0?a:gcd(b,a%b));
}
ll lcm(ll a,ll b)
{
	return (a*b)/gcd(a,b);
}
ll getlcm(vector<ll> vl)
{
	ll ch = 1;
	if(vl.size() == 1)
	{
		return vl[0];
	}
	if(vl.size() == 2)
	{
		return lcm(vl[0],vl[1]);
	}
	ch = lcm(vl[0],vl[1]);
	for(int i=2;i<vl.size();i++)
	{
		ch = lcm(ch,vl[i]);
	}
	return ch;
}
signed main()
{
	ll n,m;
	cin>>n>>m;
	vector<ll> vl(n);
	for(int i=0;i<n;i++)
	{
		cin>>vl[i];
		vl[i]/=2;
	} 
	ll ch = getlcm(vl); 
	ll pl = ch*2;
	ll he = ch;
	for(int i=0;i<n;i++)
	{
		if((ch/vl[i])%2 == 0)
		{
			cout<<"0\n";ret 0;
		}
	}
	ll cnt = 1;
	while(he<=m)
	{
		cnt++;he+=pl;
	}
	cout<<cnt-1<<endl;
	return 0;
}

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

public class Act
{
    public int[] joi { get; set; }
    public int ano { get; set; }
}

public class hello
{
    public static void Main()
    {
        var acts = new List<Act>();
        Actset(acts);
        var n = int.Parse(Console.ReadLine().Trim());
        var chg = new int[n + 1];
        var s = Console.ReadLine().Trim();
        for (int i = 0; i < n; i++)
            if (s[i] == 'O') chg[i + 1] = 1;
            else if (s[i] == 'I') chg[i + 1] = 2;
        var dp = new int[n + 1, 8];
        for (int i = 0; i < n + 1; i++)
            for (int j = 0; j < 8; j++) dp[i, j] = -99;
        for (int i = 0; i < 8; i++)
            if (acts[i].joi[0] == 1 && acts[i].joi[chg[1]] == 1) dp[1, i] = 1;
            else dp[1, i] = 0;
        for (int i = 2; i <= n; i++)
            GetDP(dp, acts, chg, i);
        var ans = 0;
        for (int i = 0; i < 8; i++)
            ans += dp[n, i] % 10007;
        ans = ans % 10007;
        Console.WriteLine(ans);

    }
    public static void Actset(List<Act> a)
    {
        var z = new string[] { "000", "100", "010", "001", "111", "110", "101", "011" };
        for (int i = 0; i < 8; i++)
            a.Add(new Act { ano = i, joi = new int[] { int.Parse(z[i][0].ToString()), int.Parse(z[i][1].ToString()), int.Parse(z[i][2].ToString()) } });
    }
    public static void GetDP(int[,] dp, List<Act> a, int[] c, int d)
    {
        for (int i = 0; i < 8; i++)
        {
            var charge = c[d];
            if (a[i].joi[charge] == 0) dp[d, i] = 0;
            else dp[d, i] = GetSum(dp, a, d, i) % 10007;
        }
    }
    public static int GetSum(int[,] dp, List<Act> a, int d, int i)
    {
        var gtotal = 0;
        for (int k = 0; k < 8; k++)
        {
            if (dp[d - 1, k] != 0)
            {
                for (int L = 0; L < 3; L++)
                        if (a[k].joi[L] == 1 &&  a[i].joi[L] == 1)
                        {
                            gtotal += dp[d - 1, k];
                            goto next;
                        }
            }
            next:;
        }
        return gtotal;
    }
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

map< int, int > prime_factor(int64_t n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

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

    map<int, int> pm_num;
    for(int i=1;i<N+1;i++){
        pm_num[i] = 0;
    }
    for(int i=1;i<N+1;i++){
        map<int, int> temp = prime_factor(i);
        for(auto iter = temp.begin(); iter!=temp.end(); iter++){
            pm_num[iter->first] += iter->second;
        }
    }
    int tot_count = 0;
    for(int i=1;i<N+1;i++){
    for(int j=1;j<N+1;j++){
        if(i==j)continue;
    for(int k=j+1;k<N+1;k++){
        if(i==k||j==k)continue;
        if(pm_num[i]>=2 && pm_num[j]>=4 && pm_num[k]>=4){
            tot_count++;

        }
    }
    }
    }


    for(int i=1;i<N+1;i++){
        if(pm_num[i]>=74){
            tot_count++;
        }
    }

    for(int i=1;i<N+1;i++){
    for(int j=1;j<N+1;j++){
        if(i==j)continue;
        if(pm_num[i]>=24 && pm_num[j]>=2){
            tot_count++;
        }
    }
    }

    for(int i=1;i<N+1;i++){
    for(int j=1;j<N+1;j++){
        if(i==j)continue;
        if(pm_num[i]>=14 && pm_num[j]>=4){
            tot_count++;
        }
    }
    }




    cout<<tot_count<<endl;

    return 0;
}

Measured memory_bytes: 3616
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (H, W, h, w): (usize, usize, usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = if H % h == 0 && W % w == 0 {
        "No".to_string()
    } else {
        let x = (h * w) as i64;
        let a = 1_000_000_000 / (x - 1) - 1;
        let b = -a * (x - 1) - 1;
        format!(
            "Yes\n{}",
            (1..(H + 1))
                .map(|i| (1..(W + 1))
                    .map(|j| if i % h == 0 && j % w == 0 { b.to_string() } else { a.to_string() })
                    .collect::<Vec<_>>()
                    .join(" "))
                .collect::<Vec<_>>()
                .join("\n")
        )
    };

    println!("{}", ans);
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    int x=0;
    int res=0;
    for (int i=0; i<N; i++) {
        if (S[i]=='I') x++;
        else x--;
        res = max(res, x);
    }
    cout << res << "\n";
}

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

int main(int argc, char const *argv[])
{
    /* code */
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    if(A == B)
    {
        if(B != C)
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    else
    {
        if(B == C || C == A)
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    
    return (0);
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
long long cnt[N];
long long a[N];
int main()
{
    long long n;
    long long ans = 0;
    scanf("%lld",&n);
    for(long long i=1;i<=n;i++)   scanf("%lld",&a[i]),++cnt[a[i]];
    for(long long i=1;i<=n;i++)   ans+=(cnt[i]*(cnt[i]-1))>>1;
    for(long long i=1;i<=n;i++)
    {
        printf("%lld\n",ans-(cnt[a[i]]-1));
    }
    return 0;
}


Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = 2 * (a + b);
        System.out.println(area + " " + length);
        sc.close();
    }
}


Measured memory_bytes: 26356
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,l;
  cin >> n >> l;

  int fullsum = 0;
  rep(i,n)
  {
    fullsum += l + i + 1 - 1;
  }

  int sum = 0;
  int minsum = INF;
  int min_index = -1;

  rep(i,n)
  {
    sum = fullsum - l - i - 1 + 1;
    if(abs(fullsum - sum) < minsum)
    {
      minsum = abs(fullsum - sum);
      min_index = i;
    }
  }

  cout << fullsum - l - min_index - 1 + 1;


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

int n, m;
int mat[10][10];
bool visited[10];
ll ans = 0LL;

int dfs(int s){
  bool f = true;
  REP(i, n) if(!visited[i]) f = false;
  if(f) return 1;

  int ret = 0;
  REP(i, n){
    if(mat[s][i] && !visited[i]){
      //true-falseの出入りマン
      visited[i]=true;
      ret += dfs(i);
      visited[i]=false;
    }
  }
  return ret;
}

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

  cin >> n >> m;
  REP(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    mat[a][b] = mat[b][a] = 1;
  }

  visited[0] = true;
  cout << dfs(0) << endl;
  
  return 0;
}

  /*
  //解けなかった
  REP(bit, (1<<n)){ //bitDP
    bool visited[n];
    REP(j, n) visited[j] = false;
    REP(j, n){
      if(!(bit%2)) continue;
      if(bit & (1<<j)){ //bitのj番目のビットが立つ
	//cout << bitset<8>(bit) << endl;
	REP(k, n){
	  if((bit & (1<<k)) && mat[j][k] == 1 && !visited[k]){
	    visited[k] = true;
	  }	  
	}
      }
    }
  }
  */


Measured memory_bytes: 256