akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int a[25],b[25],c[25];
int main()
{
	int n;
	cin >>n;
	for(int i=1;i<=n;i++)
		cin >> a[i];
	for(int i=1;i<=n;i++)
		cin >> b[i];
	for(int i=1;i<n;i++)
		cin >> c[i];
	int ans=0;
	int X,x,sum;
	for(int i=1;i<=n;i++){
		sum=0;
		x=a[i];
		sum=b[x];
		if(i>1){
			if((X+1) == x) sum += c[X];
		}
		X=x;
		ans += sum;
	}
	cout << ans << endl;	
 } 

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<long long int> a(n);
	vector<long long int> subsum(n);
	long long int suma = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		suma += a[i];
		subsum[i] = suma;
	}
	long long int result = 100000000000;
	if (n == 2)
	{
		cout << abs(a[0] - a[1]) << endl;
		return 0;
	}
	for (int i = 1; i < n - 1; i++)
	{
		long long int temp = abs(subsum[i - 1] - (suma - subsum[i - 1]));
		if (temp < result)
		{
			result = temp;
		}
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll x ;
    cin>>x ;
    ll count1=0,count2=0 ;
    while(x>=500)
    {
       x=x-500 ;
       count1++ ;
    }
    while(x>=5)
    {
        x = x-5  ;
        count2++ ;
    }
    cout<<count1*1000 + count2 *5 <<endl ;
	return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

bool ok(const string& s) {
  if (s[0] != 'A') {
    return false;
  }
  if (count(s.begin() + 2, s.end() - 1, 'C') != 1) {
    return false;
  }
  int lower = 0;
  for (char c : s) if (islower(c)) ++lower;
  return lower == s.size() - 2;
}

int main() {
  in(string, s);
  out(ok(s) ? "AC" : "WA");
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> A(N),B(N);
    rep(i,N) cin >> A[i],B[i]=A[i];
    sort(all(B));
    rep(i,N){
        if (A[i]==B[N-1]) cout << B[N-2] << endl;
        else cout << B[N-1] << endl;
    }
}

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

int main(){
    int n;
    cin >> n;
    int var = n % 10;
    if(var == 2 || var == 4 || var == 5 || var == 7 || var == 9){
        cout << "hon" << endl;
    }else if(var == 3){
        cout << "bon" << endl;
    }else{
        cout << "pon" << endl;
    }
    return 0;
}

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

main() {
  int A,B,C;
  cin >> A >> B >> C;
  vector<int> ABC(3);
  ABC[0] =A;
  ABC[1] =B;
  ABC[2] =C;
  sort(ABC.begin(),ABC.end());
  int X,Y;
  X = ABC.back();
  Y = A+B+C-X;
  int K;
  cin >> K;
  for(int i=0; i<K; i++)
    X *=2;
  cout << X+Y << endl;
  return 0;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    vector< int> x(5);
    for (int i = 0; i < 5; i++) {
        cin >> x[i];
    }
    REP(i, 5){
        if(x[i]==0)pr(i+1);
    }
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main solution = new Main();
		Scanner sca = new Scanner(System.in);
		int ans = 0;
		String str = sca.next();
		ans = solution.oneCount(str);
		System.out.println(ans);
		sca.close();
	}
	
	public int oneCount(String string) {
		int res = 0;
		for (int i = 0; i < string.length(); i++) {
			String s = string.substring(i, i+1);
			if (s.equals("1")) {
				res++;
			}
		}
		return res;
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define rer(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest) { 
	cout << arg << " "; Debug(rest...); }
template<class T>ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<< ", ";out<<v.back();}out << "]";return out;}
template<class S, class T>ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll K;
ll B[MAX_N];

void solve() {
	cin >> K;
	if(K == 0) {
		cout << "4\n";
		cout << "3 3 3 3\n"; 
	}
	else if(K == 1) {
		cout << "3\n";
		cout << "1 0 3\n";
	}
	else if(K <= 50) {
		cout << K << "\n";
		rep(i, 0, K) cout << K << " ";
		cout << "\n";
	}
	else {
		rep(i, 0, 50) B[i] = K / 50 + 49; 
		K = K % 50;

		rep(i, 0, K) {
			rep(j, 0, 50) {
				if(i == j) B[i] += 50;
				else B[j]--;
			}
		}
		cout << 50 << "\n";
		rep(i, 0, 50) {
			cout << B[i] << " ";
		}
		cout << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int main() {
	string h, ans = "e869120";
	cin >> h;
	if (h == "ani") { ans = "square1001"; }
	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

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

    set<char> e;
    for(int i=0; i<s.size(); i++){
        e.insert(s[i]);
    }
    int num = 97;
    while(num < 123){
        auto itr = e.find(char(num));
        if(*itr != char(num)){
            cout << char(num) << "\n";
            return 0;
        }
        num++;
    }
    cout << "None" << "\n";
    return 0;
}


Measured memory_bytes: 512
n,a,b = map(int, input().split())
ab = a+b
s = input()

cap_a,cap_b = 0,0

for i in range(n):
	if s[i] == "a":
		if cap_a+cap_b < ab:
			print("Yes")
			if cap_a < a:
				cap_a += 1
			else:
				cap_b += 1
		else:
			print("No")
	elif s[i] == "b":
		if cap_a+cap_b < ab and cap_b < b:
			print("Yes")
			cap_b += 1
		else:
			print("No")
	else:
		print("No")

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

void sprit_number(int input, int *front,int *behind){
  (*behind)=input % 100;
  (*front) = (input - (*behind))/100;
  return;
}

bool check_month(int n){
  return n >= 1 && n <=12;
}


int main(){
  int input,front,behind;
  bool front_check=false,behind_check=false;
  cin >> input;
  sprit_number(input,&front,&behind);
  front_check=check_month(front);
  behind_check=check_month(behind);
  if(front_check && behind_check){
    cout << "AMBIGUOUS" << endl;
    return 0;
  }
  if(behind_check){
    cout << "YYMM" << endl;
    return 0;
  }
  if(front_check){
    cout << "MMYY" << endl;
    return 0;
  }
  cout << "NA" << endl;
  
  return 0;
}
    


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int n, m;
int t[100], p, x;

int main(int argc, char **argv) {
	cin >> n;
	REP(i, n) cin >> t[i];
	int s = 0;
	REP(i, n) s += t[i];
	cin >> m;
	REP(i, m) {
		cin >> p >> x;
		--p;
		cout << (s - t[p] + x) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
/*


            
██╗░░██╗███████╗██╗░░░░░██╗░░░░░░█████╗░
██║░░██║██╔════╝██║░░░░░██║░░░░░██╔══██╗
███████║█████╗░░██║░░░░░██║░░░░░██║░░██║
██╔══██║██╔══╝░░██║░░░░░██║░░░░░██║░░██║
██║░░██║███████╗███████╗███████╗╚█████╔╝
╚═╝░░╚═╝╚══════╝╚══════╝╚══════╝░╚════╝░




*/
#include <bits/stdc++.h>
using namespace std;
#define debug(...) 42

#define endl '\n'
#define ll long long


#define pb(xx) push_back(xx);
#define ce(xx) cout << xx << '\n';

using db = long double;
using pll = pair < ll, ll >;

const ll sizee = 300009;

ll row[sizee], col[sizee];
void check(){
    if(false){
        cout<<"check"<<endl;
    }
}
int main() {


	ll t, i, xx, j, y;
	ll m,	z = 0, k, n;
	cin >> n ;
	cin>> m ;
	cin>> t;
	set<pll> st;
	check();

	set<ll> xx_co, y_co;

	for(long long i=0;i<t;i++){
		cin >> xx >> y;
     		xx=xx-1, y=y-1;
		row[xx]+=1;
	    	check();
		col[y]+=1;
		check();;
	    	st.insert({xx, y});
		xx_co.insert(xx);
	    	y_co.insert(y);
	}

	ll y_max = 0, xx_max = 0;
check();
vector<ll> xx_alter;
vector<ll> y_alter;

	for (auto xx : xx_co) {
		if (!(row[xx] < row[xx_max])) {
		    check();
			xx_max = xx;
		}
	}
check();
	for (auto xx : xx_co) {
		if (row[xx] == row[xx_max]) {
			xx_alter.push_back(xx);
			
		}
		else{
		    check();
		}
	}



	for (auto y : y_co) {
		if (col[y] > col[y_max]&&true) {
			y_max = y;
		}

	}
	for (auto y : y_co) {
		if (col[y] == col[y_max]) {
			y_alter.push_back(y);
		}
		else{
		   check();
		}
	}

	for (auto xx_max : xx_alter) {
		for (auto y_max : y_alter) {
			t = row[xx_max] + col[y_max];
			t-= (st.count({xx_max, y_max}) > 0);
			z = max(z, t);
			if (st.count({xx_max, y_max}) == 0&&true)	{
			    check();
				return cout << z, 0;
			}
		}
	}

	cout << (z)<<"\n";

	debug(z, xx_max, y_max);
}

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

#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)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int N; cin >> N;
    vector<ll> A(N);
    REP(i,N){
        cin >> A[i];
    }

    REP(i,N){
        if (A[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll INF = 1000000000000000000;

    ll a = 1;
    REP(i,N){
        ll b = A[i];
        if (b <= (INF / a)){
           a *= b; 
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 4044
#include <iostream>

using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	if (a < b) {
		cout << "a < b" << endl;
	} else if (a > b) {
		cout << "a > b" << endl;
	} else {
		cout << "a == b" << endl;
	}
	return 0;
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef tuple<int, int, int> data;

enum {UNVISITED, VISITED, EXPLORED};

const int MAX = 2e5 + 5;
vector<ii> adj[MAX];
int state[MAX];
int degree[MAX];
int pos[MAX];
int n, m;

void die() {
	puts("No");
	exit(0);
}

void dfs(int node) {
	state[node] = VISITED;
	for(auto &each : adj[node]) {
		if(state[each.first] == UNVISITED) {
			pos[each.first] = pos[node] + each.second; 
			dfs(each.first);
		}
	}
	state[node] = EXPLORED;
}

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

	vector<data> v;
	fori(i, 1, m + 1) {
		int l, r, d;
		scanf("%d %d %d", &l, &r, &d);
		adj[l].emplace_back(r, d);
		degree[r]++;
	}

	fori(i, 1, n + 1) {
		if(degree[i] == 0) {
			dfs(i);
		}
	}

/*	fori(i, 1, n + 1) {
		cout << "pos[" << i << "] = " << pos[i] << endl;
	}
*/
	fori(i, 1, n + 1) {
		for(auto &each : adj[i]) {
			int other, dis;
			tie(other, dis) = each;

			if(pos[other] - pos[i] != dis) {
				die();
			}
		}
	}

	puts("Yes");

	return 0;
}


Measured memory_bytes: 12672
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")
           
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
           
using namespace std;
using namespace __gnu_pbds;
           
//#define int long long
  
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
           
using matrix = vector<vector<ll>>;
template<typename T>
using kawaii_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
           
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
  
void FAST_IO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.setf(ios::fixed);
    //cout.precision(20);
    #ifndef _offline
    //freopen("mincost.in", "r", stdin);
    //freopen("mincost.out", "w", stdout);
    #endif
}

const int MAXN = 2e5 + 100;
int arr[MAXN];
ll cnt[MAXN], ans = 0;

signed main() {
    FAST_IO();
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        ans -= (cnt[arr[i]] * (cnt[arr[i]] - 1)) / 2;
        cnt[arr[i]]++;
        ans += (cnt[arr[i]] * (cnt[arr[i]] - 1)) / 2;
    }
    for (int i = 0; i < n; ++i) {
        ans -= (cnt[arr[i]] * (cnt[arr[i]] - 1)) / 2;
        cnt[arr[i]]--;
        ans += (cnt[arr[i]] * (cnt[arr[i]] - 1)) / 2;
        cout << ans << '\n';
        ans -= (cnt[arr[i]] * (cnt[arr[i]] - 1)) / 2;
        cnt[arr[i]]++;
        ans += (cnt[arr[i]] * (cnt[arr[i]] - 1)) / 2;
    }
}   

Measured memory_bytes: 3968
N, K = map(int, input().split())
tree_dict = {}
tree_list = []
for i in range(N):
    a = int(input())
    tree_list.append(a)

tree_list = sorted(tree_list)
min_count = 10 ** 9
max_num = 0
min_num = 0


for i in range(len(tree_list) - K + 1):
    max_num = tree_list[i + K - 1]
    min_num = tree_list[i]
    if max_num - min_num < min_count:
        min_count = (max_num - min_num)

print(min_count)

Measured memory_bytes: 8280
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  vector<int> B(N+1, 0);
  REP(i, N) B[i+1] += B[i]+A[i];
  REP(i, N+1) B[i] = ((B[i]-i)%K+K)%K;

  map<int, int> m;

  int ans = 0;
  REP(i, N+1){
    if(i-K >= 0) m[B[i-K]]--;
    ans += m[B[i]];
    m[B[i]]++;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 15872
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			int N = Integer.parseInt(str);
			int a = 0;
			while(true) {
				if(N==1 || N==0) {
					break;
				}else {
					N = N/2;
					a++;
				}
			}

			System.out.println((int)Math.pow(2, a));

		}catch (Exception e) {
			System.exit(0);
		}
	}
}


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

const int N = 100005;

int n, m;
char s[N], t[N];

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

map<long long, char> c;

int main() {
  scanf("%d %d", &n, &m);
  scanf("%s", s);
  scanf("%s", t);
  
  long long L = 1LL * n * m / gcd(n, m);
  for (long long i=0; i<n; i++) {
    c[L/n * i] = s[i];
  }
  
  for (long long i=0; i<m; i++) {
    if (c.find(L/m * i) != c.end() && c[L/m * i] != t[i]) {
      return 0 * printf("-1\n");
    }
  }
  
  printf("%lld\n", L);
  return 0;
}


Measured memory_bytes: 6144
N = int(input())
A = [int(input()) for i in range(N)]

max1 = [A.index(max(A)), max(A)]
p = A.pop(A.index(max(A)))
max2 = max(A)
for k in range(N):
    if k == max1[0]:
        print(max2)
    else:
        print(max1[1])


Measured memory_bytes: 12568
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include <queue>
#include <stack>
#include<iomanip>
#include<set>
#include<map>
using namespace std;
#define all(v) v.begin(),v.end()
#define omani dance();
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sz(v) (int)v.size()
#define uq(c) (c).resize(unique(all(c)) - (c).begin())
typedef long long ll;
#define clr(v,val) memset(v,val,sizeof v)
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
void dance()
{
	//cout << fixed << setprecision(15);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int n;
int x[100000 + 9], y[100000 + 9], cost[100000 + 9];
ll dp[100000 + 9];
ll rec(int i, int nxt)
{
	if (nxt == n||i==n)
		return 0;

	ll ch1=rec(i+1,nxt+1);
	ll ch3 = 0;
	ll ch2 = 0;
	if (((x[i] > x[nxt] && y[i] > y[nxt]) || (x[i] < x[nxt] && y[i] < y[nxt]) || (x[i] == x[nxt] && y[i] == y[nxt])) && i != nxt)
	{
		//ch3 = rec(i + 1, nxt + 1)+cost[i]+cost[nxt];
		ch2 = rec(i, nxt + 1) + cost[i]+cost[nxt];
	}
	return max(ch1, ch2);
}

int main() {
	
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);

	int sum = 0;
	sum += a[1] - a[0];
	sum += a[2] - a[1];
	cout << sum;


	
	

#if _DEBUG
	system("pause");
#endif
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

int main(void)
{
    long double A,B,H,M;
    cin >> A >> B >> H >> M;

    long double rad = M_PI * 2 * ( H/12.0 + M/60.0/12.0 - M/60.0 );

    long double rsq = A*A + B*B - 2*A*B * cosl(rad);
    
    printf("%20.20Lf\n",sqrtl(rsq));

    return 0;
}


Measured memory_bytes: 4140
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<int> c(26);
vector<vector<int>> s(365, vector<int>(26, 0));
vector<int> last(26, -1);
vector<int> t(365, -1);
int d;
inline int scoreing() {
    int res = 0;
    vector<int> tmp_last(26, -1);
    for(int i = 0; i < d; i++) {
        tmp_last[t[i]] = i;
        res += s[i][t[i]];
        for(int j = 0; j < 26; j++) {
            res -= c[j] * (i - tmp_last[j]);
        }
    }
    return res;
}
int main() {
    cin >> d;
    for(int i = 0; i < 26; i++) {
        cin >> c[i];
    }
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    int score = 0;
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            score -= c[j] * (i - last[j]);
        }
        int ind = -1;
        int tmp = score;
        for(int k = 0; k < 26; k++) {
            if(tmp < score + s[i][k] + c[k] * (i - last[k])) {
                ind = k;
                tmp = score + s[i][k] + c[k] * (i - last[k]);
            }
        }
        t[i] = ind;
        last[t[i]] = i;
        score = tmp;
    }
    int max = 1000;
    int cnt = 0;
    std::mt19937 mt(0);
    while(cnt < max) {
        int rnd = mt() % d;
        // cout << ":" << rnd << endl;
        rnd = min(d - 1, rnd);
        int new_s = t[rnd];
        int now_sc = scoreing();
        for(int i = 0; i < 26; i++) {
            t[rnd] = i;
            if(now_sc < scoreing()) {
                now_sc = scoreing();
                new_s = i;
            }
        }
        t[rnd] = new_s;
        cnt++;
    }
    for(int i = 0; i < d; i++) {
        cout << t[i] + 1 << endl;
    }
}

Measured memory_bytes: 3660
#include <iostream>
#include <map>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;

    map<int, int> num;
    rep(i, n) num[i] = 10;

    vector<int> s(m);
    vector<int> c(m);

    rep(i, m) {
        cin >> s.at(i) >> c.at(i);
        s[i]--;
    }

    rep(i, m) {
        if (num[s[i]] != 10 && num[s[i]] != c[i]) {
            cout << -1 << endl;
            return 0;
        }
        num[s[i]] = c[i];
    }

    if (n > 1) {
        if (num[0] == 0) {
            cout << -1 << endl;
            return 0;
        } else if (num[0] == 10) {
            num[0] = 1;
        }
        rep(i, n) {
            if (num[i] == 10) cout << 0;
            else cout << num[i];
        }
        cout << endl;
        return 0;
    } else { // N == 1
        if (num[0] == 10) num[0] = 0;
        cout << num[0] << endl;
        return 0; 
    }
}


Measured memory_bytes: 256
n,m,q=map(int, input().split())
s=[list(map(int, input().split())) for i in range(q)]

import itertools
A = [i for i in range(1,m+1)]
k = list(itertools.combinations_with_replacement(A, n))


ma = 0
for i in k:
    su = 0
    for n in s:
        if i[n[1]-1] - i[n[0]-1] == n[2]:
            su += n[3]
    ma = max(ma,su)

print(ma)

Measured memory_bytes: 21612
import numpy as np
N = int(input())

x = []
y = []
xy1 = []
xy2 = []

for i in range(N):
    a, b = (int(t) for t in input().split())
    x.append(a)
    y.append(b)
    xy1.append(a + b)
    xy2.append(a - b)

max1 = max(xy1) - min(xy1)
max2 = max(xy2) - min(xy2)
print(max((max1, max2)))


Measured memory_bytes: 59344
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int H, W; cin >> H >> W;
	int h, w; cin >> h >> w;

	cout << (H*W - h*W - H*w + h*w) << endl;
}

Measured memory_bytes: 256
def solve():
    from sys import stdin
    f_i = stdin
    
    N = int(f_i.readline())
    red = [tuple(map(int, f_i.readline().split())) for i in range(N)]
    blue = [tuple(map(int, f_i.readline().split())) for i in range(N)]
    
    red.sort(key=lambda x: x[1], reverse=True)
    blue.sort()
    
    for bp in blue:
        bx, by = bp
        for i, rp in enumerate(red):
            rx, ry = rp
            if rx < bx and ry < by:
                del red[i]
                break
    
    ans = N - len(red)
    print(ans)

solve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=507,p=998244353;
int n,sa,sb,a[N],b[N],f[N][N],g[N][N]; long long fac[N],ifac[N];
inline long long pows(long long u,int v){
	long long ans=1; while(v>0) {if(v&1) ans=ans*u%p; u=u*u%p,v=v>>1;} return ans;
}
inline void init(){
	fac[0]=ifac[0]=1;
	for(int i=1;i<=500;i++) fac[i]=fac[i-1]*i%p,ifac[i]=pows(fac[i],p-2);
}
int main(){
	cin>>n,init();
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i],sa+=a[i],sb+=b[i];
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int x=0;x<=sa;x++)
			for(int y=0;y<=sb;y++) g[x][y]=f[x][y];
		for(int x=0;x<b[i];x++){
			long long t=ifac[x]*pows(a[i],x)%p;
			for(int fx=0;fx+a[i]<=sa;fx++)
				for(int fy=0;x+fy<=sb;fy++){
					g[fx+a[i]][x+fy]=(g[fx+a[i]][x+fy]-t*f[fx][fy])%p;
				}
		}
		for(int x=0;x<=sa;x++)
			for(int y=0;y<=sb;y++) f[x][y]=g[x][y],g[x][y]=0;
	}
	long long ans=0;
	for(int i=1;i<=sa;i++)
		for(int j=0;j<=sb;j++){
			ans=(ans+f[i][j]*fac[j]%p*pows(i,p-2-j)%p*sa%p)%p;
		}
	cout<<(p-ans)%p<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	string S;
	cin >> S;
	lint Z = S.size();
	lint a = 0, b = 0;
	rep(i, Z) {
		if (S[i] == 'A') {
			a = i;
			break;
		}
	}
	rep(i, Z) {
		if (S[i] == 'Z') {
			b = i;
		}
	}
	cout << b - a + 1 << endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll ans=1;
    int n=s.length();
    int a[26]={0};
    for(int i=0;i<n;i++){
        a[s[i]-'a']++;
    }
    for(int i=0;i<n;i++){
        a[s[i]-'a']--;
        ans+=(n-i-1-a[s[i]-'a']);
    }
    cout << ans<<endl;
    return 0;
}


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

using namespace std;

int main(){
    int N;
    bool mx = false;
    cin >> N;
    vector<long long int> x(N),y(N),h(N),cal(N);
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i]==0){
            mx = true;
        }
    }

    if(mx){
        for(int i=0;i<=100;i++){
            for(int j=0;j<=100;j++){
                for(int k=0;k<=200;k++){
                   for(int l=0;l<N;l++){
                        if(h[l]!=max((long long int)0,k-abs(x[l]-i)-abs(y[l]-j))){
                           break;
                        }
                        if(l==N-1){
                            cout << i << " " << j << " " << k << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }else{
        for(int i=0;i<=100;i++){
            for(int j=0;j<=100;j++){
                for(int k=0;k<N;k++){
                    cal[k] = h[k]+abs(x[k]-i)+abs(y[k]-j);
                }
                sort(cal.begin(),cal.end());
                if(0<cal[0] && cal[0]==cal[N-1]){
                    cout << i << " " << j << " " <<  cal[0] << endl;
                    return 0;
                }
            }
        }
    }
}

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

using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<double> x(n);
	vector<string> u(n);
	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> u[i];
	}
	double ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (u[i] == "BTC") {
			ans += x[i] * 380000;
		}
		else
			ans += x[i];
	}
	cout << ans << endl;
}



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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

vi a;

int main()
{
    ll n;
    cin >> n;

    REP(i,5){
        ll c;
        cin >> c;
        a.push_back(c);
    }
    ll m = *min_element(ALL(a));
    cout << (5+(ll)ceil(n/(double)m) - 1);


}

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

ll N, M, X;
vector<ll> C;
vector<vector<ll>> A;

ll Min = 1e12;
bool flag1 = false;

int dfs(vector<ll> V){
    if(V.size() == N){
        vector<ll> UND(M);

        for(int i = 0; i < N; i++){
            for(int j = 0; j < M; j++){
                if(V[i] == 1){
                    UND[j]+=A[i][j];
                }
            }
        }
        bool flag = true;
        for(auto x : UND) if(x < X) flag = false;
        if(flag){
            flag1 = true;
            ll SUM = 0;
            for(int i = 0; i < N; i++) if(V[i] == 1) SUM += C[i];
            Min = min(Min, SUM);
        }

        return 0;
    }
    for(int i = 0; i < 2; i++){
        vector<ll> U = V;
        U.push_back(i);
        dfs(U);
    }
    return 0;
}


int main(){
    cin >> N >> M >> X;
    C.resize(N);
    A.resize(N);
    for(int i = 0; i < N; i++){
        cin >> C[i];
        for(int j = 0; j < M; j++){
            ll a; cin >> a; A[i].push_back(a);
        }
    }
    dfs({});
    if(flag1) cout << Min << endl;
    else cout << -1 << endl;

    


}


Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

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

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
int i, j, k;

static const int MAX = 10000;
static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

vector<pair<int, int>> adj[MAX];
int n;

void dijkstra() {
	int d[MAX], p[MAX], color[MAX];
	priority_queue<pair<int, int>> PQ;
	rep(i, n) {
		color[i] = White;
		d[i] = INF;
	}
	d[0] = 0;
	PQ.push(make_pair(0, 0));
	color[0] = Gray;
	while (!PQ.empty()) {
		pair<int, int> f = PQ.top();
		PQ.pop();
		int u = f.second;
		color[u] = Black;
		if (d[u] < f.first * (-1)) continue;
		rep(j, adj[u].size()) {
			int v = adj[u][j].first;
			if (color[v] == Black) continue;
			if (d[v] > d[u] + adj[u][j].second) {
				d[v] = d[u] + adj[u][j].second;
				PQ.push(make_pair(d[v] * -1, v));
				color[v] = Gray;
			}
		}
	}
	rep(i, n) {
		cout << i << ' ' << (d[i] == INF ? -1 : d[i]) << '\n';
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin >> n;
	rep(i, n) {
		int u,k;
		cin >> u >> k;
		rep(j, k) {
			int v, c;
			cin >> v >> c;
			adj[u].pb(make_pair(v, c));
		}
	}
	dijkstra();
	return 0;
}


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

int main(){
    int n,highest;
    cin>>n;

    int ans=0;

    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    highest=h[0];

    for(int i=0;i<n;i++){
        if(h[i]>=highest){
            ans++;
            highest=h[i];
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) {return (n==0)?1:10*TEN(n-1);}

int main() {
    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 1) {
            int j = i+1;
            while (j < n and a[j] and a[j] % 2 == 0) j++;
            if (j < n and a[j] % 2 == 1) {
                a[i]--; a[j]--;
                ans++;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        ans += a[i]/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
    long long a,b;
    cin >> a >> b;
    long long num = 2;
    int ans =1;
    long long c;
    while(true){
        c=a%b;
        if(c==0){
            break;
        }else{
            a=b;
            b=c;
        }
    }
    if(b%num==0){
        ans++;
        while(b%num==0){
            b=b/num;
        }
    }
    num++;
    while(num<=b){
        if(sqrt(b)<num){
            ans++;
            break;
        }
        if(b%num==0){
            ans++;
            while(b%num==0){
                b=b/num;
            }
        }
        num+=2;
    }
    cout << ans;
   
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int m[10][10]={0},a[5],k=0;

void dfs(int i,int j){
  if(m[i-1][j]==1){
    m[i-1][j]=0;
    a[k]=1;
    //cout<<"1"<<" ";////
    k++;
    dfs(i-1,j);
  }
  if(m[i][j-1]==1){
    //  cout<<"2"<<" ";////
    m[i][j-1]=0;
    a[k]=2;
    k++;
    dfs(i,j-1);
  }
  if(m[i+1][j]==1){
    //    cout<<"3"<<" ";////
    m[i+1][j]=0;
    a[k]=3;
    k++;
    dfs(i+1,j);  
  }
  if(m[i][j+1]==1){
    //    cout<<"4"<<" ";////
    m[i][j+1]=0;
    a[k]=4;
    k++;
    dfs(i,j+1); 
  }  
}

int main(){
  int ih=0,jh=0;
  char s;
  while(cin>>s){
    k=0;
    m[1][1]=s-'0';
    for(int i=1;i<=8;i++){
      for(int j=1;j<=8;j++){
	//cout<<i<<" "<<j<<endl;/////
	if(i==1&&j==1)continue;
	else cin>>s;
	m[i][j]=s-'0';
	
	if(m[i][j]==1){
	  ih=i;
	  jh=j;
	}
	
      }
    }
    m[ih][jh]=0;
    dfs( ih , jh );
    //cout<<endl<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;////
    if(a[0]==1&&a[1]==2&&a[2]==3)cout<<"A"<<endl;
    else if(a[0]==1&&a[1]==1&&a[2]==1)cout<<"B"<<endl;
    else if(a[0]==2&&a[1]==2&&a[2]==2)cout<<"C"<<endl;
    else if(a[0]==1&&a[1]==4&&a[2]==1)cout<<"D"<<endl;
    else if(a[0]==2&&a[1]==1&&a[2]==2)cout<<"E"<<endl;
    else if(a[0]==1&&a[1]==2&&a[2]==1)cout<<"F"<<endl;
    else if(a[0]==1&&a[1]==4&&a[2]==2)cout<<"G"<<endl;

  }
  return 0;
}

Measured memory_bytes: 3076
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int h,i;
  int a[10],b[10];
  for(i=0;i<10;i++)
    cin>>a[i];
  for(i=0;i<10;i++)
    cin>>b[i];
  do{
    h=0;
    for(i=1;i<10;i++){
      if(a[i-1]<a[i]){
	swap(a[i-1],a[i]);
	h=1;
      }
    }
  }while(h);
  do{
    h=0;
    for(i=1;i<10;i++){
      if(b[i-1]<b[i]){
	swap(b[i-1],b[i]);
	h=1;
      }
    }
  }while(h);
  cout<<a[0]+a[1]+a[2]<<" "<<b[0]+b[1]+b[2]<<endl;
  return 0;
}

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

long long cnt;
int l, n, A[1000000];
vector<int> G;

void insertionSort(int A[], int n, int g) {
        for(int i = g; i < n; i++) {
                int v = A[i];
                int j = i - g;
                while(j >= 0 && A[j]  > v) {
                        A[g + j] = A[j];
                        j -= g;
                        cnt++;
                }
                A[j + g] = v;
        }
}

void shellSort(int A[], int n) {
        for(int h = 1; ; ) {
                if(h > n) break;
                G.push_back(h);
                h = 3*h + 1;
        }
        for(int i = G.size() - 1; i >= 0; i--) {
                insertionSort(A, n, G[i]);
        }
}

int main() {
        cin >> n;
        for(int i = 0; i < n; i++) scanf("%d", &A[i]);
        cnt = 0;
        shellSort(A, n);
        cout << G.size() << endl;
        for(int i = G.size() - 1; i >= 0; i--) {
                printf("%d",G[i]);
                if(i) printf(" ");
        }
        cout << endl;
        cout << cnt << endl;
        for(int i = 0; i < n; i++) cout << A[i] << endl;
}       

Measured memory_bytes: 7184
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

ll solve(ll l, ll x){
    ll ans;
    if(x == 0){
        return 0;
    }
    if(l == 0){
        return 1;
    }
    ll mid = (pow(2, l + 2) - 3) / 2;
    if(mid >= x){
        ans = solve(l - 1, x - 1);
        // バンズ引く
    }else if(mid + 1 == x){
        ans = solve(l - 1, x - 1) + 1;
    }else{
        ll tmp = pow(2, (l + 1) - 1) - 1;
        ll tmp2 = solve(l - 1, x - mid - 1);
        ans = tmp + tmp2 + 1;
    }
    return ans;
}


int main(){
    ll N, X;
    cin >> N >> X;
    ll ans = solve(N, X);
    cout << ans << endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

use proconio::input;

const MAX_A: u64 = 1e6 as u64;
fn main() {
    input! {
        N: usize,
        mut A: [u64; N],
    }
    let mut arr = [0; MAX_A as usize + 1];

    let mut ans: u64 = 0;

    for &a in A.iter() {
        if arr[a as usize] == 1 {
            arr[a as usize] = 2;
        } else if arr[a as usize] == 0 {
            arr[a as usize] = 1;
            for i in ((2 * a)..=MAX_A).step_by(a as usize) {
                arr[i as usize] += 2;
            }
        }
    }

    for &a in A.iter() {
        if arr[a as usize] == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8996
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

int main(){
  int n, m, k, p = 0, ans = 0;
  cin >> n >> m;
  vector<int> s(n);
  rep(i, m){
    cin >> k; 
    rep(j, k){
      int sw;
      cin >> sw; sw--;
      s[sw] |= 1<<i;
    }
  }

  rep(i, m){
    cin >> k;
    p |= k<<i;
  }

  for(int i = 0; i < (1<<n); i++){
    int d = 0;
    rep(j, n){
      if(i & (1<<j)) d ^= s[j];
    }
    if(d == p) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
	int n,i,j,x=0,cnt,k,flg;
	int pr[201][201],ten[201];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			scanf("%d",&pr[i][j]);
		}
	}
	for(i=0;i<n;i++){
		ten[i]=0;
	}
	for(i=0;i<3;i++){
		for(j=0;j<n;j++){
			flg=0;		
			for(k=j+1;k<n;k++){
				if(pr[j][i]==pr[k][i]){
					pr[k][i]=0;
					flg=1;
				}
			}
			if(flg==0){
				ten[j]+=pr[j][i];
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%d\n",ten[i]);
	}
	
	return 0;
}

Measured memory_bytes: 1180
def dfs(t):
    if 0 not in already:#全ての辺を訪問していた場合
        return 1
    allReach=0
    for i in range(n):
        if connect[t][i]==1 and already[i]==0:#辺があり、訪問しいない場合
            already[i]=1
            allReach+=dfs(i)
            already[i]=0
    return allReach

n,m=map(int,input().split())
connect=[[0 for i in range(n)]for j in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    #辺の情報を記録する
    connect[a-1][b-1]=1
    connect[b-1][a-1]=1
already=[0 for i in range(n)]#訪問した点を記録する
already[0]=1#必ず1から始まるので訪問履歴をつけておく
print(dfs(0))#記録した情報をもとに0からdfs


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
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; }

ll gcd(ll x, ll y){
    if (y==0) return x;
    else return gcd(y, x%y);
}
int main(){
    int N; cin >> N;

    int n = gcd(N,360);

    cout << 360 / n << endl;
}

Measured memory_bytes: 3584
//   Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long int ll;
const ll mod = 998244353;
long double PI=3.1415926;

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

//vector<ll>v;
//vector<ll>::iterator it;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    //cin>>t;
    t=1;
    //ll c=1;
    while(t--){
        string s;
        cin>>s;
        ll n=s.length();
        for(ll x=0; x<n; x++){
            if(s.at(x)=='?'){
                s[x]='D';
            }
        }
        cout<<s<<"\n";
        //v.clear();
        //cout<<"Case #"<<c<<": "<<ans<<"\n";
        //c++;
    }
    return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
int main()
{
    ///"In the name of Allah,most gracious and most merciful"///

    ll i,j,x,y,z,count=100000000000,sum=0,n,ans=0;
    cin>>x>>y>>z;
    j=y/z;
    i=x/z;
    if(x%z==0)
        cout<<(j-i+1)<<endl;
    else
        cout<<(j-i)<<endl;

    return 0;
}







Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll,int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {
	int n, d;
	cin >> n >> d;
	vvi x(n, vi(d));
	rep(i, n)rep(j, d)cin >> x[i][j];
	int ans = 0;
	rep(i, n)rep(j, n) {
		if (i <= j)continue;
		int dist = 0;
		rep(k, d)dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
		if (dist == (int)sqrt(dist) * (int)sqrt(dist))ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256