akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n;
  cin >> n;
  vector<int> odd(100001, 0), evn(100001, 0);
  REP(i, n / 2) {
    int o, e;
    cin >> o >> e;
    odd.at(o)++;
    evn.at(e)++;
  }
  int mo_cnt = 0, me_cnt = 0, mo, me, so_cnt = 0, se_cnt = 0;
  for (int i = 1; i <= 100000; i++) {
    if (mo_cnt < odd.at(i)) {
      mo_cnt = odd.at(i);
      mo = i;
    }
    if (me_cnt < evn.at(i)) {
      me_cnt = evn.at(i);
      me = i;
    }
  }
  for (int i = 1; i <= 100000; i++) {
    if (so_cnt < odd.at(i) && i != mo) {
      so_cnt = odd.at(i);
    }
    if (se_cnt < evn.at(i) && i != me) {
      se_cnt = evn.at(i);
    }
  }
  if (me == mo)
    cout << min(n - mo_cnt - se_cnt, n - so_cnt - me_cnt) << "\n";
  else
    cout << n - mo_cnt - me_cnt << "\n";
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define maxn 1000005
int prime[maxn];
bool is_prime[maxn];
int sieve(int n) {
	int p = 0;

	for(int i=2; i<=n; i++) {
		if(is_prime[i]) {
			prime[p++] = i;
			for(int j=2*i; j<=n; j+=i) is_prime[j] = false;
		}
	}
	return p;
}
int main() {
	int n;
	for(int i=0; i<=maxn; i++) is_prime[i] = true;
	//0???1???????´???°
	is_prime[0] = is_prime[1] = false;
	while(~scanf("%d",&n)) {

		int p = sieve(n);
		printf("%d\n",p);
	}
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  for(int i=0; i<N; i++) cin >> a.at(i);
  for(int i=0; i<N; i++) b.at(i)=a.at(i)-1-i;
  int ans=0;
  for(int i=0; i<N-1; i++){
    if(b.at(i)==0){
      ans++;
      b.at(i+1)=a.at(i)-i;
    }
  }
  if(b.at(N-1)==0) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<string> A, B;
    for (int i = 0; i < N; i++) {
        string s; cin >> s;
        string a = s, b = s;
        replace(begin(a), end(a), '?', 'a');
        replace(begin(b), end(b), '?', 'z');
        A.emplace_back(move(a));
        B.emplace_back(move(b));
    }
    string T; cin >> T;
    int M = 0, m = N;
    for (auto &a : A) {
        if (a <= T) M++;
    }
    for (auto &b : B) {
        if (b >= T) m--;
    }
    for (int i = m; i <= M; i++) {
        cout << i + 1 << (i == M ? '\n' : ' ');
    }
    return 0;
}


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

typedef long long ll;

int main(){
    ll a=0, b=1, n;
    cin >> n;
    for(int i=0;i<n;i++){
        ll q, x;
        cin >> q >> x;
        if(q == 1){
            b *= x;
            a *= x;
        }
        else if(q == 2){
            a += x;
        }
        else{
            a -= x;
        }
    }
    cout << -a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 3120
#include<iostream>
//#include<vector>

int main(){
	long long int n,sum=0;
	std::cin>>n;

	sum = n / 500 * 1000;

	//std::cout << sum << std::endl;

	sum+=(n%500) / 5 * 5;

	std::cout<<sum<<std::endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn main() {
    let buf = io::read_string();
    let mut sc = io::Scanner::new(&buf);
    let d: usize = sc.read();
    let g: usize = sc.read();
    let p: Vec<(usize, usize)> = (0..d).map(|_| (sc.read(), sc.read())).collect();
    let mut res = 10000000000;
    for b in 0..(1 << d) {
        let mut sum = 0;
        let mut num = 0;
        let mut m = 0;
        for i in 0..d {
            if b >> i & 1 == 1 {
                sum += 100 * (i + 1) * p[i].0 + p[i].1;
                num += p[i].0;
            } else {
                m = i;
            }
        }
        if sum < g {
            let s = 100 * (m + 1);
            let c = (g - sum + s - 1) / s;
            if c >= p[m].0 {
                continue;
            }
            num += c;
        }
        res = std::cmp::min(res, num);
    }
    println!("{}", res);
}
#[allow(dead_code)]
mod io {
    use std;
    use std::io::Read;
    use std::str::{FromStr, SplitWhitespace};
    pub struct Scanner<'a> {
        pub iter: SplitWhitespace<'a>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.iter
                .next()
                .unwrap()
                .parse()
                .ok()
                .expect("parsing failed")
        }
        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read()).collect()
        }
    }
    pub fn read_string() -> String {
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define fio ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
// #define y1 asdf__y1;

const int N = 2e5+5;
pii P[N];
int X1,X2,Y1,Y2,n;

vector<pii> ir;
set<int> cc;
map<int,int> lab;
int A[N];

int lis(int *A, int n) {
	if(!n) return 0;
	vector<int> v = {0};
	for(int i = 1; i < n; ++i) {
		if(A[i] > A[v.back()])
			v.push_back(i);
		else {
			int lo = -1, hi = v.size()-1;
			while(hi-lo>1) {
				int md = (lo+hi)/2;
				((A[i] > A[v[md]])?lo:hi) = md;
			}
			v[hi] = i;
		}
	}
	return v.size();
}

int B[N];

const bool dbg = 0;

int main() {	
	scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
	scanf("%d",&n);
	for(int i = 0; i < n; ++i)
		scanf("%d%d",&P[i].fi,&P[i].se);
	if(X1 > X2) {
		X1 = -X1, X2 = -X2;
		for(pii &p : P)
			p.fi = -p.fi;
	}
	if(Y1 > Y2) {
		Y1 = -Y1, Y2 = -Y2;
		for(pii &p : P)
			p.se = -p.se;
	}
	for(int i = 0; i < n; ++i) {
		pii p = P[i];
		if(X1 <= p.fi && p.fi <= X2 && Y1 <= p.se && p.se <= Y2)
			ir.pb(p);
	}
	sort(ir.begin(),ir.end());
	n = ir.size();
	for(int i = 0; i < n; ++i)
		B[i] = ir[i].se;
	int ans = lis(B,n);
	long double pi = 2*acosl(0);
	long double ra = (long double)(Y2-Y1 + X2-X1) * 100.0;
	if(ans == Y2-Y1+1 || ans == X2-X1+1) {
		ra += 10*pi-20;
		--ans;
		if(dbg) cout << "1 bad\n";
	}
	ra += (5*pi-20) * ans;
	if(dbg) cout << ans << " good\n";
	printf("%.20lf\n",double(ra));
}

Measured memory_bytes: 6000
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 200005

int a[1001];
int main(){
	int n, sum;
	while(cin >> n, n){
		sum = 0;
		for(int i = 0;i < n;i++){
			cin >> a[i];
			sum += a[i];
		}
		sum -= *max_element(a, a+n);
		sum -= *min_element(a, a+n);
		cout << sum/(n-2) << endl;
	}
	return 0;
}

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

int main(){
    int i = 1;
    int x;
    do{
        cin >> x;
        if(x != 0){
            cout << "Case " << i << ": " << x << endl;
            i++;
        }
        
    }while(x != 0);
    return 0;
}


Measured memory_bytes: 3044
from math import factorial
N,M=map(int,input().split())
ans=0
mod=10**9+7
if abs(N-M)>1:
    print(0)
    exit()
elif N == M:
    ans=2*(factorial(N)*factorial(M))%mod
    print(ans)
else:
    ans=(factorial(N)*factorial(M))%mod
    print(ans)


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
    int a, b = 0;
    string s = "";
    cin >> a >> b >> s;
    if (s[a] != '-')
    {
        COUT("No");
        return 0;
    }

    REP(i, s.length())
    {
        if (i == a)
        {
            continue;
        }
        int num = s[i] - '0';
        if (!(0 <= num && num <= 9))
        {
            COUT("No");
            return 0;
        }
    }

    COUT("Yes");

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
#define YMAX 250001
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	rep(i,S.size()-8){
		printf("%c",S[i]);
	}
	kaigyo;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  ll n,m;
  while(cin>>n>>m,n){
  ll a[1111];
  for(int i=0;i<n;i++){
	cin>>a[i];
  }
  ll ans=0;
  for(int i=0;i<n;i++){
	for(int j=i+1;j<n;j++){
	  ll tmp=a[i]+a[j];
	  if(tmp>m)continue;
	  ans=max(ans,tmp);
	}
  }
  if(ans)cout<<ans<<endl;
  else cout<<"NONE"<<endl;
  }
  return 0;
}



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

vector<long> a;
long N,M;
vector<vector<int>> g(100005);
vector<int> d(100005,-1);
vector<int> p(100005);
int c=0;
void bfs(int s){
  queue<long> q;
  d[s] = c;
  q.push(s);
  long u;
  while (!q.empty()) {
        int v = q.front(); // キューから先頭頂点を取り出す
        q.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : g[v]) {
            if (d[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            d[nv] = c;
            q.push(nv);
        }
    }

return;

}

int main() {
cin>>N>>M;
for(int i=0;i<N;i++) cin>>p[i],p[i]--;
for(int i=0;i<M;i++){
  int a,b;
  cin>>a>>b;
  a--,b--;
  g[a].push_back(b);
  g[b].push_back(a);
}


  for(int i=0;i<N;i++){
    if(d[i]==-1){
      d[i]=c;
      bfs(i);
      c++;
    }
  }

long ans=0;
for(int i=0;i<N;i++){
  if(d[i]==d[p[i]]||p[i]==i) ans++;
}
cout<<ans<<endl;


}


Measured memory_bytes: 9492
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
// using P = pair<int, int>;
struct Vec{
    double x, y;
};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
     return false;
}
using namespace std;
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x) * t << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n, m; cin >> n >> m;
  vl a(n); ina(a,n);
  map<ll, ll> nums;
  ll sum = 0, ans = 0;
  nums[sum]++;
  rep(i,n) {
    sum += a[i];
    nums[sum % m]++;
  }
  for (auto it=nums.begin(); it!=nums.end(); ++it) {
    ans += it->ss * (it->ss - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, bool> P;
ll N,K;
ll a[510];
ll sum;
priority_queue<P,vector<P>,greater<P> > pq;
bool Able(ll M){
    vector<ll> v;
    ll tmpSum=0;
    for(int i=0;i<N;i++){
        v.push_back(a[i]%M);
        tmpSum+=M-a[i]%M;
    }
    sort(v.begin(),v.end());
    ll lPlusSum=0;
    ll rMinusSum=tmpSum;
    ll ans=0;
    for(int i=0;i<N;i++){
        lPlusSum+=v[i];
        rMinusSum-=M-v[i];
        if(lPlusSum==rMinusSum){
            ans=lPlusSum;
            break;
        }
    }
    return ans<=K;
}
vector<ll> toCheck;
int main(){
    cin>>N>>K;
    sum=0;
    for(int i=0;i<N;i++){
        cin>>a[i];
        sum+=a[i];
    }
    ll ans=0;
    for(ll i=1;i*i<=sum;i++){
        if(sum%i==0){
            toCheck.push_back(i);
            if(i!=sum/i)toCheck.push_back(sum/i);
        }
    }
    sort(toCheck.begin(),toCheck.end());
    for(int i=0;i<toCheck.size();i++){
        if(Able(toCheck[i])){
            ans=max(ans,toCheck[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

 int main(){
     int n;
     cin >> n;
     int ans=0;
     vector<int> a(n);
     vector<int> b(n);
     rep(i,n){
         cin >> a[i] >> b[i];
     }
     for(int i=0;i<n-2;i++){
         if(a[i]==b[i] &&a[i+1]==b[i+1] && a[i+2]==b[i+2] ){
             ans=1;
         }
     }
     if(ans==1){
         cout << "Yes" << endl;
     }
     else{
         cout << "No" << endl;
     }
     return 0;
 }

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  int n;
  cin >> n;
  int a[n+5],b[n+5],c[n+5];
  for(int i = 0;i<n;++i){
    cin >> a[i] >> b[i] >> c[i];
  }
  int m = 3;
  //初期化,初期条件
  int dp[n+5][m];
  for(int i = 0;i<n+5;++i){
    for(int j =  0;j<m;++j){
      dp[i][j] = 0;
    }
  }
  //ループ
  for(int i = 0;i<n;++i){
    chmax(dp[i+1][0],dp[i][1] + a[i]);
    chmax(dp[i+1][0],dp[i][2] + a[i]);
    
    chmax(dp[i+1][1],dp[i][0] + b[i]);
    chmax(dp[i+1][1],dp[i][2] + b[i]);
      

    chmax(dp[i+1][2],dp[i][0] + c[i]);
    chmax(dp[i+1][2],dp[i][1] + c[i]);
  }
  
  int ans;
  for(int i = 0;i<m;++i){
    ans = max(ans,dp[n][i]);
  }
  
  cout << ans;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
    	//
        Scanner scan = new Scanner(System.in);
        //
        String strIn = "";
        //???????????????
        int[] array = new int[26];
        //??£?¨?
        int intTemp;
        //?????£?????????????????????????????´??? true?????????????????????
        while(scan.hasNext()){
        	//1????????£?????????
            strIn += scan.nextLine();
        }
        
        for(int i = 0; i < strIn.length(); i++){
            intTemp = strIn.charAt(i);
            if('A' <= intTemp && intTemp <= 'Z'){
                array[intTemp - 'A']++;
            }else if('a' <= intTemp && intTemp <= 'z'){
                array[intTemp - 'a']++;
            }
        }
        for(int i = 0; i < array.length; i++){
            System.out.println((char)('a' + i) + " : " + array[i]);
        }
 
        scan.close();
    }
}

Measured memory_bytes: 26088
#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll H, W;
  cin >> H >> W;
  vector<string> S(H);
  cin >> S;

  vector<vector<ll>> map(H * W, vector<ll>(H * W, INF));
  rep(y, H) rep(x, W) {
    if (S[y][x] == '#') continue;
    int i = x + y * W;
    if (x >= 1 && S[y][x - 1] == '.') {
      map[i][i - 1] = 1;
      map[i - 1][i] = 1;
    }
    if (x <= W - 2 && S[y][x + 1] == '.') {
      map[i][i + 1] = 1;
      map[i + 1][i] = 1;
    }
    if (y >= 1 && S[y - 1][x] == '.') {
      map[i][i - W] = 1;
      map[i - W][i] = 1;
    }
    if (y <= H - 2 && S[y + 1][x] == '.') {
      map[i][i + W] = 1;
      map[i + W][i] = 1;
    }
  }

  rep(i, H * W) rep(j, H * W) rep(k, H * W) {
    map[j][k] = min(map[j][k], map[j][i] + map[i][k]);
  }

  ll ans = 0;
  bool one = false;
  rep(i, H * W) rep(j, H * W) {
    if (map[i][j] != INF) {
      ans = max(ans, map[i][j]);
    }
    if (map[i][j] == 1) one = true;
  }
  out(ans != 2 ? ans : one ? 1 : 2);
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> city(m * 2);
  vector<int> road(n);
  
  for (int i = 0; i < m * 2; i++) {
    cin >> city.at(i);
    road.at(city.at(i) - 1)++;
  }
  
  for (int i = 0; i < n; i++) {
    cout << road.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N, C; cin >> N >> C;
  
  vector<vector<int>> D(C, vector<int>(C));
  for(int i=0; i<C; i++)
    for(int j=0; j<C; j++)
      cin >> D[i][j];
  
  vector<vector<int>> sameCNum(3, vector<int>(C, 0));
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      int c; cin >> c; c--;
      sameCNum[(i+j)%3][c]++;
    }
  }
  
  ll minD, tmpD;
  minD = INF;
  for(int c0=0; c0<C; c0++){
    for(int c1=0; c1<C; c1++){
      for(int c2=0; c2<C; c2++){
        if(c0==c1 || c1==c2 || c2==c0) continue;
        tmpD = 0;
        for(int cn=0; cn<C; cn++){
          tmpD += sameCNum[0][cn] * D[cn][c0];
          tmpD += sameCNum[1][cn] * D[cn][c1];
          tmpD += sameCNum[2][cn] * D[cn][c2];
        }
        minD = min(minD, tmpD);
      }
    }
  }
  
  cout << minD << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int one,A,B;
	scanf("%d", &one);
	if (one==1){
			printf("Hello World");
	}
	if (one==2){
		scanf("%d", &A);
		scanf("%d", &B);
		printf("%d",A+B);
	}
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int sum[400005],lazy[400005],n,m;;
struct obj
{
    int l,r;
}p[300005];
bool cmp(obj x,obj y)
{
    return x.r-x.l<y.r-y.l;
}
void push_down(int k,int l,int r)
{
    if(l==r)
    {
        sum[k]+=lazy[k];
    }
    else
    {
        lazy[k<<1]+=lazy[k];
        lazy[k<<1|1]+=lazy[k];
        sum[k]+=lazy[k]*(r-l+1);
    }
    lazy[k]=0;
}
void change(int k,int l,int r,int x,int y,int w)
{
    if(l>=x&&r<=y)
    {
        lazy[k]+=w;
    }
    else
    {
        push_down(k,l,r);
        int mid=(l+r)>>1;
        if(y>=l&&x<=mid)
        {                 
            change(k<<1,l,mid,x,y,w);
        }             
        if(y>=mid+1&&x<=r)
        {                
            change(k<<1|1,mid+1,r,x,y,w);
    	}
    }
}
int query(int k,int l,int r,int x)
{
    push_down(k,l,r);
    if(l==r)
    {
        return sum[k];
    }
    int mid=(l+r)>>1;
    if(x<=mid)
    {
        return query(k<<1,l,mid,x);
    }
    return query(k<<1|1,mid+1,r,x);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&p[i].l,&p[i].r);
    }
    int i=0;
    sort(p,p+n,cmp);
    for(int d=1;d<=m;d++)
    {
        while(i<n&&p[i].r-p[i].l<d)
        {
            change(1,1,m,p[i].l,p[i].r,1);
            i++;
        }
        int ans=n-i;
        for(int k=d;k<=m;k+=d)
        {
            ans+=query(1,1,m,k);
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
#define N_MAX 1000

int w,h;
int n, xy[N_MAX][2];

int sgn(int n){
	if(n<0)
		return -1;
	if(n>0)
		return 1;
	return 0;
}

int abs(int n){
	return(n>0)?n:-n;
}

int difference(int x,int y){
	return abs(x-y);
}

int min(int x,int y){
	return (x<y)?x:y;
}

int path(int x, int y){
	int ans = difference(x,y);
	if(sgn(x)==sgn(y))
		ans += min(abs(x),abs(y));
	return ans;
}

void solve(void){
	int answer = 0;
	int i = 0;
	while(++i < n){
		int
		x = xy[i][0] - xy[i-1][0],
		y = xy[i][1] - xy[i-1][1];
		answer += path(x,y);
	}
	printf("%d\n",answer);
	return;
}

int main(void){
	int i;
	scanf("%d%d%d",&w,&h,&n);
	for(i=0;i<n;i++){
		scanf("%d%d", &xy[i][0], &xy[i][1]);
	}
	solve();
	return 0;
}

Measured memory_bytes: 604
H, W = map(int, input().split())
if (H == 1) or (W == 1):
    ans = 1
elif (H%2 == 0) or (W%2 == 0):
    ans = (H * W)//2
else:
    ans = ((W - 1) * H)//2 + (H//2 + 1)

print(ans)


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

    int n,b,c=0; cin>>n;
    if(n==1)cout<<"Hello World";
    else {
        for(int i=0;i<n;i++){
            cin>>b;
            c+=b;
        }
        cout<<c;
    }
}


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

#define int long long

signed main(){

  int t;
  int X, Y, Z, K;
  vector<int> A, D, E;
  
  cin>>X>>Y>>Z>>K;

  for(int i = 0; i < X; i++){
    cin>>t;
    A.push_back(t);
  }

  for(int i = 0; i < Y; i++){
    cin>>t;
    for(int j = 0; j < X; j++){
      D.push_back(t+A[j]);
    }
  }

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

  // for(int i = 0; i < D.size(); i++){
  //   cout<<i<<" DD "<<D[i]<<endl;
  // }

  for(int i = 0; i < Z; i++){
    cin>>t;
    for(int j = 0; j < K && j < D.size(); j++){
      E.push_back(t+D[j]);
    }
  }

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

  for(int i = 0; i < K; i++){
    cout<<E[i]<<endl;
  }
  return 0;
}


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

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

    cout << total[1][N - 1] << endl;
}

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

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

    //good luck kittu!
    vector<int> a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(), a.end());
    if(a[0]==5 && a[1]==5 && a[2]==7) cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char x,y;
  cin>>x>>y;
  if(x>y){
    cout<<">"<<endl;
  }
  else if(x<y){
    cout<<"<"<<endl;
  }
  else{
    cout<<"="<<endl;
  }
}

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

#define ALP 26

using namespace std;

struct Day_data{
    int penalty;
    int satis[ALP];
    int lasts[ALP];
    int selected;
};

struct Solution_data{
    int days;

    int penalties[ALP];
    vector<Day_data> day_data;
    int satis_sum;
    int penal_sum;

    Solution_data(int d);
    int get_score();
    void solve_greedily();
};

Solution_data::Solution_data(int d): days(d), day_data(d)
{
    satis_sum = 0;
    penal_sum = 0;

    for(int i = 0; i < d; i++){
        for(int j = 0; j < ALP; j++){
            day_data[i].lasts[j] = -1;
        }
    }
}

int Solution_data::get_score()
{
    return satis_sum - penal_sum;
}

void Solution_data::solve_greedily()
{
    for(int i = 0; i < days; i++){
        int penal = (i - day_data[i].lasts[0]) * penalties[0];
        pair<int, int> max = make_pair(0, day_data[i].satis[0] + penal);
        cerr << "*first*  last cont: " << day_data[i].lasts[0] << endl;
        cerr << "penalty: " << penal << " total: " << day_data[i].satis[0] + penal << endl;
        for(int j = 1; j < ALP; j++){
            int penal = (i - day_data[i].lasts[j]) * penalties[j];
            int day_score = day_data[i].satis[j] + penal;
            cerr << "last cont of " << j << ": " << day_data[i].lasts[j] << endl;
            cerr << "penalty: " << penal << " total: " << day_score << endl;
            if(max.second < day_score){
                cerr << "****this is currently best****" << endl;
                max.first = j;
                max.second = day_score;
            }
            cerr << endl;
        }

        day_data[i].selected = max.first;
        for(int j = i; j < days; j++){
            day_data[j].lasts[max.first] = i;
        }
        satis_sum += day_data[i].satis[max.first];

        for(int j = 0; j < ALP; j++){
            penal_sum += (i - day_data[i].lasts[j]) * penalties[j];
        }
    }
}

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

    Solution_data sol(days);

    for(int i = 0; i < ALP; i++){
        int p;
        cin >> p;
        sol.penalties[i] = p;
    }

    for(int i = 0; i < days; i++){
        for(int j = 0; j < ALP; j++){
            int s;
            cin >> s;
            sol.day_data[i].satis[j] = s;
        }
    }

    for(int i = 0; i < days; i++){
        for(int j = 0; j < ALP; j++){
            sol.day_data[i].lasts[j] = -1;
        }
    }

    sol.solve_greedily();

    for(int i = 0; i < days; i++){
        cout << sol.day_data[i].selected + 1 << endl;
    }
}

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

public class Main {
    static int n;
    static int m;
    static int[] g;
    static int[] toN;
    static int[] from1;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();//要素の数
        m = sc.nextInt();//編の数
        toN = new int[n+1];
        from1 = new int[n+1];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a == 1) {
                from1[b] = 1;
            } else if (b == n) {
                toN[a] = 1;
            }
        }
        boolean ok = false;
        for (int i = 0; i < n+1; i++) {
            if (from1[i] != 0) {
                if (toN[i] != 0) {
                    ok = true;
                    break;
                }
            }
        }
//        g = new int[n+1];//グラフを表す配列
        //最初は全て親
//        Arrays.fill(g, -1);
//        for (int i = 0; i < m; i++) {
//            union(sc.nextInt(), sc.nextInt());
//        }
//        System.out.println(find(n) == find(1)?"POSSIBLE": "IMPOSSIBLE");
        System.out.println(ok?"POSSIBLE": "IMPOSSIBLE");
    }
//    //要素間の結合を行う。
//    static void union (int a, int b) {
//        int pa = find(a);
//        int pb = find(b);
//        //要素が小さい方に結合する。(負の数なので数が小さい方が大きい）
//        if (pa > pb) {
//            int tmp = pa;
//            pa = pb;
//            pb = tmp;
//        }
//        //pb を　pa に結合する。
//        //paの値にpbを足し、pb を paの要素に置き換える。
//        g[pa] += g[pb];
//        g[pb] = pa;
//    }
//    //要素の親をリターンする。親(0未満)が見つかるまで再帰
//    static int find (int a) {
//        if (g[a] < 0) return a;
//        return find(g[a]);
//    }
}


Measured memory_bytes: 95892
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 200010
using namespace std;

int main(){
  int n;
  cin>>n;
  int p[n];
  REP(i,n) cin>>p[i];
  int ans = 0;
  int min = MAX;
  
  REP(i,n){
    if(min >= p[i]){
      min = p[i];
      ans++;
    }
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 1024
//============================================================================
// Name        : ReversePoland.cpp
// Author      : koike
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <stack>
#include <sstream>

using namespace std;
const int BLOCK_LENGTH = 3;
const char PLUS = '+';
const char MINUS = '-';
const char POWER = '*';
const char NOT_BLOCK = 'n';
std::stack<int> numStack;


bool strIsDigit(string str) {
	try{
		stoi(str);
	}catch (std::invalid_argument e) {
		return false;
	}

	return true;//std::all_of(str.cbegin(), str.cend(), isdigit)
}

stack<string> getReverseStack(stack<string> &arg) {
	stack<string> ret;
	int argSize = arg.size();

	for (unsigned int i = 0; i < argSize;i++) {
		ret.push(arg.top());
		arg.pop();
	}

	return ret;
}

void calcStackNums(string ope) {

	int result = 0;
	const char* c_ope = ope.c_str();

	//??????????????????????????????????????????
	int var2 = numStack.top();
	numStack.pop();
	int var1 = numStack.top();
	numStack.pop();

	switch (c_ope[0]) {
		case PLUS:
			result = var1 + var2;
			break;
		case MINUS:
			result = var1 - var2;
			break;
		case POWER:
			result = var1 * var2;
			break;
		default:
			cout << "calc error" << endl;
			break;
	}

	numStack.push(result);
}

void calcPoland(vector<string> &formula) {

	string top;

	for (vector<string>::iterator it = formula.begin(); it != formula.end(); ++it)
	{
		if (strIsDigit(*it)) {
			numStack.push(stoi(*it));
		}
		else {
			calcStackNums(*it);
		}
	}
}


vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}

int main() {

	//?¨??????\?????????
	string s;
	getline(cin, s);
	vector<string> formula = split(s,' ');

	calcPoland(formula);

	cout << numStack.top() << endl;

	return 0;
}

Measured memory_bytes: 3288
#include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main()
{
    int time_n;
    int hour = 0;
    int minute = 0;
    int second = 0;

    while (cin >> time_n) {
        hour = time_n / 3600;
        time_n = time_n % 3600;
        minute = time_n / 60;
        time_n = time_n % 60;
        second = time_n;
        cout << hour << ":" << minute << ":" << second << endl;
    }

    return 0;
}



Measured memory_bytes: 3080
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
  
  if a + b + c >= 22 {
    fmt.Printf("bust\n")
  } else {
    fmt.Printf("win\n")
  }
}

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

int main() {
	int n,k;
	cin>>n>>k;
	vector<int> v, dp(n, INT_MAX-1);
	int temp;
	for(int i=0;i<n;i++) {
		cin>>temp;
		v.push_back(temp);
	}
	if(n==1) {
		cout<<0<<endl;
		return 0;
	} else if(n==2) {
		cout<<abs(v[1]-v[0])<<endl;
		return 0;
	}
	dp[0] = 0;
	dp[1] = abs(v[0]-v[1]);
	for(int i=2;i<n;i++) {
		for(int j=i-1;j>=i-k && j>=0;j--) {
			dp[i] = min(dp[i], abs(v[j]-v[i]) + dp[j]);
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1276
ans=(X 0 0 0 0 0 0 0 0 0 1 1 1 1 2 2 3 3 3 3 8 8 11 11 11 11 14 14 32 32 35 35 35 35 42 42 42 42 49 49 49 49 49 49 75 75 86 86 86 86 86 86 123 123 131 131 131 131 148 148 153 153 170 170 170 170 170 170 227 227 227 227 227 227 250 250 323 323 324 324 324 324 354 354 354 354 384 384 384 384 384 391 491 491 529 529 529 529 529 529 543)
echo ${ans[$(cat)]}

Measured memory_bytes: 536
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int n;
int k;
int h[100010];
int dp[100010];

void chmin(int a, int *b)
{
	if (*b > a)
		*b = a;
}

int main(int argc, char const *argv[])
{
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) scanf("%d", h+i);
	for (int i = 0; i < 100010; i++) dp[i] = INT_MAX;

	dp[0] = 0;
	//今の足場
	for (int i = 0; i < n; i++)
	{
		//次の足場(i+j)
		for (int j = 1; j <= k; j++)
		{
			chmin(dp[i] + abs(h[i+j] - h[i]), &dp[i+j]);
		}
	}
	printf("%d", dp[n-1]);
	return 0;
	
}


Measured memory_bytes: 896
MOD=10**9+7
def factorization(n):
    arr=[]
    tmp=n
    for i in range(2,int(n**0.5)+1):
        if(tmp%i==0):
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
    if(not arr):
        arr.append([1,1])
    if(tmp!=1):
        arr.append([tmp,1])
    return arr
def moddiv(a,m):
    return pow(a,m-2,m)
N=int(input())
A=list(map(int,input().split()))
cnt={}
for i in range(N):
    arr=factorization(A[i])
    for a,b in arr:
        cnt[a]=max(cnt.get(a,0),b)
g=1;res=0
for k,v in cnt.items():
    g=g*(pow(k,v,MOD))%MOD
for i in range(N):
    res=(res+(g*moddiv(A[i],MOD))%MOD)%MOD
print(res)

Measured memory_bytes: 4700
#include <iostream>
#include <sstream>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <stdexcept>
#include <algorithm>
#include <set>
#include <map>
#include <stdlib.h>
using namespace std;
int main(){
    int A,B,C,D,i,p,s,g;
    cin >> A >> B >> C >> D;
    if(A < C){
        s = C;
    }
    else{
        s = A;
    }
    if (B < D)
    {
        g = B;
    }
    else
    {
        g = D;
    }
    if(g - s > 0){
        cout << g - s << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <cstdlib>
#define ll long long
#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define MX 100010
using namespace std;

int N;
vector<int> H;
int ans;

int main(){
        cin >> N;
        H.resize(N);
        FOR(i,0,N){
                cin >> H[i];
        }
        FOR(i,0,N){
//                cout << "i=" << i << endl;
                int j;
                for(j=0;j<i;j++){
                        if(H[j]>H[i]) break;
                }
//                cout << j << "," << i << endl;
                if(j==i){
                        ans++;
                }
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
long long int n;
cin >>n;
long long int a[n], i, b[n];
for(i=0;i<n;i++)	
	cin >> a[i] >> b[i];
sort(a, a+n);sort(b, b+n);
 
 if(n%2 == 1)
 {
 	//cout << b[n/2] <<  " " << a[n/2] << endl;
 	long long int x = b[n/2]-a[n/2]+1;
 	cout << x << endl;
	 }
	 else
	 {
	 	long long int x = a[n/2], x1 = a[n/2-1];
	 	long long int y = b[n/2], y1 = b[n/2-1];
	 	long long int cnt = (y1-x1+1)+(y-x);
	 	cout << cnt << endl;
		 }	

	return 0;
}

Measured memory_bytes: 6704
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

ll N, K, P[5000], C[5000];

vector<vector<ll>> get_loops() {
    vector<vector<ll>> ret;
    bool checked[5000] = {};
    REP(i, N) {
        if (checked[i]) continue;

        vector<ll> loop;
        ll index = i;
        while (true) {
            index = P[index];
            if (checked[index]) break;
            loop.push_back(C[index]);
            checked[index] = true;
        }
        ret.push_back(loop);
    }
    return ret;
}

ll get_ans_sub(vector<ll> loop, ll len) {
    ll ret = 0, sum = 0, size = loop.size();
    REP(i, len) sum += loop[i];
    ret = sum;
    if (len == size) {
        return ret;
    }

    ll s = 0, e = len;
    REP(i, size) {
        sum += loop[e];
        sum -= loop[s];
        e = (e + 1) % size;
        s = (s + 1) % size;
        ret = max(ret, sum);
    }
    return ret;
}

ll get_ans(vector<ll> loop) {
    ll all_sum = 0;
    for (ll n : loop) all_sum += n;

    ll ret = -1e18, size = loop.size();
    FOR(i, 1, min(K, size) + 1) {
        ll cnt = (K - i) / size;
        ll ans_sub = get_ans_sub(loop, i) + cnt * max(0LL, all_sum);
        ret = max(ret, ans_sub);
    }
    return ret;
}

int main() {
    cin >> N >> K;
    REP(i, N) {
        cin >> P[i];
        P[i]--;
    }
    REP(i, N) cin >> C[i];

    vector<vector<ll>> loops = get_loops();
    ll ans = -1e18;
    for (auto loop : loops) {
        ans = max(ans, get_ans(loop));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3848
#include <iostream>

using namespace std;

const int kMaxN = 100;


void bubbleSort(string *a, int n) {
    
    for (int i = 0; i < n; i++) {
        for (int j = n - 1; j  > i; j--) {
            if (a[j][1] < a[j - 1][1]) {
                swap(a[j], a[j - 1]);
            }
        }
    }
}

void selectionSort(string *a, int n) {
    for (int i = 0; i < n; i++) {
        int min_i = i;
        for (int j = i + 1; j < n; j++) {
            if (a[j][1] < a[min_i][1]) {
                min_i = j;
            }
        }
        swap(a[i], a[min_i]);
    }
}

int main() {
    int n;
    string card;
    string A[kMaxN];
    string B[kMaxN];

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> card;
        A[i] = card;
        B[i] = card;
    }

    bubbleSort(A, n);

    for (int i = 0; i < n; i++) {
        cout << A[i];
        if (i != n - 1) {
            cout << " ";
        }
    }

    cout << endl;
    cout << "Stable" << endl;
    
    selectionSort(B, n);
    bool flag = true;

    for (int i = 0; i < n; i++) {
        cout << B[i];
        if (i != n - 1) {
            cout << " ";
        }
        
        if (A[i] != B[i]) {
            flag = false;
        }
    }
    
    cout << endl;
    
    if (flag) {
        cout << "Stable" << endl;
    }
    else {
        cout << "Not stable" << endl;
    }

}




Measured memory_bytes: 3204
//file_name:ABC79_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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

    ll l[87] = {};
    l[0] = 2;
    l[1] = 1;
    srep(i,2,87){
        l[i] = l[i-1] + l[i-2];
    }

    ll ans = 0;

    cout << l[n] << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x;
    cin >> x;
    int arr[x];
    for(int i = 0; i < x; i++) cin >> arr[i];
    for(int i = x - 1; i >= 0; i--){
        if (i != x - 1) cout << " ";
        cout << arr[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3116
#include<stdio.h>
#include<vector>
using namespace std;

const int sz=1e5+10;
vector<int> ans(sz,0);
vector<vector<pair<int,int> > > roads;

void dfs(int now, int back, int back_color)
{
    int cnt=1;
    for(pair<int,int> i : roads[now])
    {
        if(i.first==back)continue;
        if(cnt==back_color)cnt++;
        ans[i.second]=cnt;
        dfs(i.first,now,cnt);
        cnt++;
    }
}

main()
{
    int a;
    scanf("%d",&a);
    roads.resize(a);
    for(int i=0;i<a-1;i++)
    {
        int b,c;
        scanf("%d%d",&b,&c);
        b--,c--;
        roads[b].push_back({c,i});
        roads[c].push_back({b,i});

    }

    int k=0;
    for(int i=0;i<a;i++)k=max(k,(int)roads[i].size());

    dfs(0,-1,-1);

    printf("%d\n",k);
    for(int i=0;i<a-1;i++)printf("%d\n",ans[i]);

    return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int biggest(vector<int> cakes, int except)
{
	int index = 0;
	int value = 0;
	for (int i = 0; i < cakes.size(); ++i)
	{
		if ( i == except)
		{
			continue;
		}
		if (cakes[i] > value)
		{
			value = cakes[i];
			index = i;
		}
	}
	if (value == 0)
	{
		index = except;
	}
	return index;
}
bool isBreak(vector<int> cakes)
{
	for (int i = 0; i < cakes.size(); ++i)
	{
		if (cakes[i] > 0)
		{
			return false;
		}
	}
	return true;
}
int main(){
#ifndef ONLINE_JUDGE
	//freopen("test.txt", "r", stdin);
	//freopen("result.txt", "w", stdout);
#endif
	int k, t;
	cin >> k >> t;
	vector<int> cakes(t, 0);
	for (int i = 0; i < t; ++i)
	{
		cin >> cakes[i];
	}
	int count = 0;
	int index = -1;
	while (true)
	{
		if (isBreak(cakes))
		{
			break;
		}
		int curindex = biggest(cakes, index);
		if (curindex == index)
		{
			count++;
		}
		cakes[curindex]--;
		index = curindex;
		
	}
	cout << count << endl;
#ifndef ONLINE_JUDGE
	//fclose(stdin);
	//fclose(stdout);
	///system("result.txt");
#endif
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;
	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;
}


Measured memory_bytes: 384
n = int(input())
d = {}
l = []
for i in range(n):
    a, b = input().split()
    if a not in l:
        l.append(a)
        d[a] = set([(int(b), i + 1)])
    else:
        d[a].add((int(b), i + 1))
l.sort()
for i in range(len(l)):
    d[l[i]] = list(d[l[i]])
    d[l[i]].sort(reverse=True)
    for j in range(len(d[l[i]])):
        print(d[l[i]][j][1])

Measured memory_bytes: 3064
n = 2000001
kagen = -1000000
jogen = 1000000
k, x = map( int, input().split() )

ans = ""
for i in range( x - (k-1),  x + (k-1)+1 ) :
	if i < kagen :
		continue
	if jogen < i :
		continue
	ans += str( i ) + " " 

#ans = ans[:-2]
print( ans.strip() )

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,K;
  cin >> N >> K;
  vl A(N);
  rep(i,N) {
    cin >> A[i];
    A[i]--;
  }
  vl sum(N+1,0);
  map<int,vi> mp;
  mp[0].push_back(0);
  rep(i,N) {
    sum[i+1] = sum[i]+A[i];
    sum[i+1] %= K;
    mp[sum[i+1]].push_back(i+1);
  }
  ll ans = 0;
  for(auto x:mp) {
    vi ve = x.second;
    rep(i,sz(ve)) {
      auto d = lower_bound(rng(ve),ve[i]+K);
      ans += max(0,(int)(d-(ve.begin()+i+1)));
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int H1, M1, H2, M2, K, S, E, L, l;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  S = H1 * 60 + M1;
  E = H2 * 60 + M2;
  L = E - S;
  l = L - K;
  cout << l << endl;
}

Measured memory_bytes: 3164
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail

    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1);
    
    return 0;
}

Measured memory_bytes: 256