akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


const int MAX = 1000010;
int n;
int get(int a,int b){
  if(a < b)swap(a,b);
  return a * n + b;
}
vector<int> d[MAX];
int deg[MAX];
int res[MAX];
int wyn = 0;
int il = 0;
void add_edge(int a,int b){
  d[a].PB(b);
  deg[b]++;
}
void dfs(int v){
  if(deg[v] != 0)return;
  deg[v] = -1;
  il ++;
  maxi(wyn,res[v]);
  for(int el:d[v]){
    maxi(res[el], res[v] + 1);
    deg[el]--;
    dfs(el);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n){
    vector<int> t(n - 1);
    R(j,n-1){
      cin >> t[j]; t[j]--;
    }
    R(j,n-2){
      add_edge(get(i,t[j]), get(i,t[j+1]));
    }
  }
  R(i,n*n)dfs(i);
  if(il != n * n){
    cout << "-1\n";
  }else{
    cout << wyn+1 << "\n";
  }
}


Measured memory_bytes: 54272
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N];

        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();

            if (A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) {
                System.out.println("DENIED");
                return;
            }
        }

        System.out.println("APPROVED");
    }
}


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

int main() {
	int k, n, a[200005];
	cin >> k >> n;
	rep(i, n) {
		cin >> a[i];
	}
	int m = 0;
	rep(i, n - 1) {
		m = max(m, a[i+1] - a[i]);
	}
	m = max(m, a[0] + k - a[n-1]);
	cout << k - m << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

typedef long long LL;

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

LL lcm(LL x, LL y) {
   return x/gcd(x, y)*y;
}

int main()
{
   int N, i;
   LL ans = 1LL;
   LL T;

   scanf("%d", &N);

   for (i = 0; i < N; i++) {
       scanf("%ld", &T);
       ans = lcm(ans, T);
   }
   printf("%lld\n", ans);

   return 0;
}

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

int main()
{
  ll A,B,C;cin>>A>>B>>C;
  string ans = "NO";

  for(int i = 1; i < B+1; i ++) {
    int tmp = i*A % B;
    if (tmp == C) {
      ans = "YES";
    }
  }

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

Measured memory_bytes: 3604
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N;
    vi P(N); REP(i, N) cin >> P[i];

    int cnt = 0;
    REP(i,N) {
        if (P[i] != i + 1) cnt++;
    }

    if (cnt == 0 || cnt == 2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];
  Int mi=*min_element(as.begin(),as.end());
  for(Int i=0;i<n;i++)
    if(as[i]==mi) drop(i+1);
  return 0;
}



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

class DisjointSet {
public:
	DisjointSet() {};
	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		for (int i = 0; i < size; i++)makeSet(i);
	}

	void makeSet(int i) {
		p[i] = i;
		rank[i] = 0;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

private:
	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}

	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
		}
		return p[x];
	}
	vector<int> rank, p;
};

int main() {
	int n, a, b, q;
	int t;
	cin >> n >> q;
	DisjointSet ds(n);

	for (int i = 0; i < q; i++) {
		cin >> t >> a >> b;
		if (t == 0)ds.unite(a, b);
		else if (ds.same(a, b))cout << 1 << "\n";
		else cout << 0 << "\n";
	}
	return 0;
}


Measured memory_bytes: 3176
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] ds = new int[N];
			for(int i = 0; i < N; i++) { ds[i] = sc.nextInt(); }
			Arrays.sort(ds);
			//System.out.println(Arrays.toString(ds));
			
			int answer_min = 0, answer_max = -1;
			
			int prev = -1;
			for(int i = 0; i < N; i++) {
				final int curr = ds[i];
				if(prev == curr) { continue; }
				prev = curr;
				
				final int ABC = i;
				final int ARC = N - ABC;
				
				//System.out.println(ABC + " " + ARC);
				
				if(ABC == ARC) { answer_max = curr; }
				if(ABC < ARC && curr > answer_min) { answer_min = curr; }
			}
			
			//System.out.println(answer_max + " " + answer_min);
			
			if(answer_max < 0) {
				System.out.println(0);
			}else {
				System.out.println(answer_max - answer_min);
			}
			

		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 33632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second

ll dsum(ll s) {
	ll ss = 0, sss = s;
	while (sss) {
		ss += sss % 10;
		sss /= 10;
	}
	return ss;
}

ll Stoi(string str) {
	ll ret;
	stringstream ss;
	ss << str;
	ss >> ret;
	return ret;
}


int main() {
	ll k;
	cin >> k;
	vector<ll>ans(200000);
	ans.clear();
	map<ll, bool>mp;
	for (int i = 1;i < 10;i++) {
		ans.pb(i);
		mp[i] = 1;
	}

	for (ll j = 1;j < 13;j++) {
		for (ll i = 1;i < 1000;i++) {
			string s;
			s += to_string(i);
			for (int l = 0;l < j;l++)s += "9";
			ll p = (ll)Stoi(s);
			bool fl = 1;
			for (int m = i + 1;m < i + 20;m++) {
				string t;
				t += to_string(m);
				for (int l = 0;l < j;l++)t += "9";
				ll q = (ll)Stoi(t);
				if (p*dsum(q) > q*dsum(p)) {
					fl = 0;
				}
			}
			if (fl && !mp[p]) {
				ans.pb(p);
				mp[p] = 1;
			}
		}
	}
	sort(ALL(ans));
	for (int i = 0;i < k;i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 1920
// 1_2_A

#include <iostream>
using namespace std;

int main(){
  int a, b;
  cin >> a; cin >> 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: 3076
from itertools import product
number = list(input())

for c in product(range(2),repeat=3):
    formula = number[0]
    for i in range(3):
        if c[i] == 1:
            formula += '+' + number[i+1]
            
        else:
            formula += '-' + number[i+1]
    if eval(formula) == 7:
        print(formula + '=7')
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

char s[444], t[444], r[444];

int main() {
	int n;
	scanf("%d%s%s", &n, s, t);
	FOR(i,n+1) {
		bool ok=1;
		FOR(j,n) r[j] = s[j];
		FOR(j,n) {
			if (i+j < n && t[j] != r[i+j]) ok=false;
			r[j+i] = t[j];
		}
		if (ok) {
			printf("%d\n", n+i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

int P[200001];
ll kotae = 0;
int N;
int to[400001], ne[400001], he[200001];
int dfs(int v, int prev) {
	int kazu = 1;
	for (int u = he[v]; u; u = ne[u]) {
		if (to[u] != prev) kazu += dfs(to[u], v);
	}
	kotae += P[N - kazu] + P[kazu];
	return kazu;
}

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


	N = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();
		to[k] = b;
		ne[k] = he[a];
		he[a] = k++;
		to[k] = a;
		ne[k] = he[b];
		he[b] = k++;
	}
	P[0] = 1;
	rep1(i, N) {
		P[i] = P[i - 1] << 1;
		if (P[i] >= mod) P[i] -= mod;
	}

	dfs(1, 0);
	kotae = ((ll(P[N - 1]) * N + P[N] - 1 + N - kotae) % mod + mod) % mod;
	kotae = kotae * modpow(P[N], mod - 2) % mod;

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 7936
#include <iostream>
#include <algorithm>

using ll = long long int;

int main()
{
    ll n, a[110];
    std::cin >> n;

    for (int i = 0; i < n; ++i)
        std::cin >> a[i];

    ll mini = 1e18;
    for (int i = 1; i <= 100; ++i)
    {
        ll dist = 0;
        for (int j = 0; j < n; ++j)
        {
            dist += (i - a[j]) * (i - a[j]);
        }

        mini = std::min(mini, dist);
    }

    std::cout << mini;
}


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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 1e5;
const int INF = (int) 1e9 + 7;

int main(int argc, char *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
	cin >> s;
	if (s == "ABC") cout << "ARC";
	else cout << "ABC";

	return 0;
}


Measured memory_bytes: 3620
const main = (input) => {
  const [head, next] = input.split("\n")
  const [W, H] = head.split(" ")
  const [ww, hh] = next.split(" ")
  return (W - ww) * (H - hh)
}

if (process.env.NODE_ENV !== "test") {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(main(input.trim()))
}


Measured memory_bytes: 7500
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
  
    if(n == 3){
        printf("5 9 16");
        return 0;
    }
    int nNum = n / 8;
    for(int i = 0; i < nNum; i++){
        int k = 12 * i;
        printf("%d %d %d %d %d %d %d %d ", k+2, k+3, k+4, k+6, k+8, k+9, k+10, k+12);
    }
    
    int nMax = nNum * 12;
    switch(n % 8){
      case 0:
        break;
      case 1:
        printf("%d", nMax+6);
        break;
      case 2:
        printf("%d %d", nMax+6, nMax+12);
        break;      
      case 3:
        printf("%d %d %d", nMax+2, nMax+4, nMax+6);
        break;
      case 4:
        printf("%d %d %d %d", nMax+2, nMax+3, nMax+4, nMax+9);
        break;
      case 5:
        printf("%d %d %d %d %d", nMax+2, nMax+3, nMax+4, nMax+6, nMax+9);
        break;
      case 6:
        printf("%d %d %d %d %d %d", nMax+2, nMax+3, nMax+4, nMax+8, nMax+9, nMax+10);
        break;
      case 7:
        printf("%d %d %d %d %d %d %d", nMax+2, nMax+3, nMax+4, nMax+6, nMax+8, nMax+9, nMax+10);
        break; 
      default:
        return 1;
    }
    
    return 0;
}


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

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

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

void solve() {
    string s;
    cin >> s;
    auto ans = (s[1] == 'B') ? "ARC" : "ABC";
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


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

using namespace std;

template <typename T> string toString(const T& t) {
    ostringstream os; os << t; return os.str();
}

void solve(int s) {
    string w;
    for (int i = 0; i < 10; i++) {
        w = toString(s * s);
        while (w.size() != 8) w = "0" + w;
        w = w.substr(2, 4);
        s = atoi(w.c_str());
        cout << s << endl;
    }
}

int main(void) {
    int d, s;
    cin >> d;
    for (int i = 0; i < d; i++) {
        cin >> s;
        cout << "Case " << i + 1 << ":\n";
        solve(s);
    }

    return 0;
}


Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"#%d (%s) = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

const int iinf = 1e9+10;
const ll inf = 1ll<<60;
const ll mod = 1e9+7 ;


void GG(){cout<<"0\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b,mo) % mo;
}

const int maxn = 2e6+5;

int p[maxn];

struct nd{
    int p;
    ll v;
    bool l;
};

signed main(){
    IOS();

    int n; cin>>n;
    n = (1<<(n-1));
    for (int i = 0; i<n; ++i) cin>>p[i], --p[i];
    ll re = 0;
    for (int o = 1; o<n; ++o) {
        int L = o;
        ll nmo = 0;
        while (L * 2 < n+n) L*=2, nmo++;
        int R = ((o+1)<<(nmo))-1;
        bug(o,L,R);
        vector<nd> pos;
        for (int i = L; i<=R; ++i) {
            ll vv = 1;
            int tmp = i;
            while (tmp != o) (vv *= tmp) %= mod, tmp /= 2;
            pos.pb({p[i-n] + n, vv, i <= ((L+R)/2) } );
        }
        sort(ALL(pos),[&](nd a, nd b){return a.p!=b.p?a.p<b.p:a.l<b.l;});
        while (SZ(pos) > 1) {

            vector<nd> np;


            for (int i = 0; i<SZ(pos); ++i) {
                if (i && pos[i-1].p == pos[i].p) {
                    re -= pos[i-1].v * pos[i].v % mod * o % mod * pos[i].p % mod * pos[i].p % mod * (pos[i-1].p/2) % mod;
                }
            }
            sort(ALL(pos),[&](nd a, nd b){return (a.p/2)!=(b.p/2)?a.p<b.p:a.l<b.l;});
            for (int i = 0; i<SZ(pos); ++i) {
                nd x = pos[i];
                if (i && (np.back().p) == (x.p/2) && np.back().l == x.l) {
                    bug(i);
                    (np.back().v += x.v*x.p)%=mod;
                }else{
                    np.pb({x.p/2, x.v*x.p%mod, x.l});
                }
            }
//            sort(ALL(pos),[&](nd a, nd b){return a.p!=b.p?a.p<b.p:a.l<b.l;});
            for (int i = 0; i<SZ(np); ++i) {
                if (i && np[i].p == np[i-1].p) {
                    assert(np[i].l != np[i-1].l);
                    re += np[i].v * np[i-1].v % mod * o % mod * np[i].p % mod;
                }
            }
            if (SZ(np) <= 1 || (SZ(np) == 2 && np[0].p == np[1].p)) break;
            pos = np;

        }
    }
    re = (re % mod + mod) % mod;
    cout<<re%mod<<endl;
}


Measured memory_bytes: 11812
a = list(map(int,input().split()))
if a[0] == a[1]:
  if a[1] == a[2]:
    print('1')
  else:
    print('2')
elif a[0] == a[2] or a[1] == a[2]:
  print('2')
else:
  print('3')


  
  
  
  
    
  
  
  
  

Measured memory_bytes: 38256
N = int(input())

lst = list()
for i in range(1, N+1):
    s, p = input().split()
    lst.append({"id":i, "s":s, "p":int(p)})

lst.sort(key=lambda x:x["p"], reverse=True)
lst.sort(key=lambda x:x["s"])

for i in range(0, len(lst)):
    print(lst[i]["id"])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
typedef long long ll;
typedef long double lld;
const ll mx = 1e14 + 5;
const ll mod = 1e9 + 7;

void input(){
    int a, b, c; cin >> a >> b >>c;
    if(a+ b + c >= 22)cout <<"bust" << endl;
    else cout <<"win" << endl;

}
int main(){
    input();
    return 0;
}



Measured memory_bytes: 256
import heapq

N = int(input())
A = [int(a) for a in input().split()]

L = A[:2*N]
L.sort()
s1 = 0
s2 = 0
h1 = []
h2 = []
dic = {}
dic_h = {}
for i in range(N):
    heapq.heappush(h1, -L[i])
    if L[i] in dic_h:
        dic_h[L[i]] += 1
    else:
        dic_h[L[i]] = 1
    s1 += L[i+N]
    if L[i+N] in dic:
        dic[L[i+N]] += 1
    else:
        dic[L[i+N]] = 1
    s2 += A[i+2*N]
    heapq.heappush(h2, -A[i+2*N])
    
ans = s1-s2
for i in range(2*N-1, N-1, -1):
    if A[i]+h2[0] < 0:
        s2 += heapq.heappop(h2)
        heapq.heappush(h2, -A[i])
        s2 += A[i]
    if A[i] in dic:
        if dic[A[i]] > 0:
            dic[A[i]] -= 1
            s1 -= A[i]
            t = -heapq.heappop(h1)
            while h1:
                if dic_h[t] > 0:
                    dic_h[t] -= 1
                    break
                else:
                    t = -heapq.heappop(h1)
            s1 += t
            if t in dic:
                dic[t] += 1
            else:
                dic[t] = 1
    else:
        dic_h[A[i]] -= 1
    ans = max(ans, s1-s2)
    
print(ans)

Measured memory_bytes: 43640
using System;
using System.Collections.Generic;
using System.Linq;

public class Prog
{
    public void run()
    {
        int N = int.Parse(Console.ReadLine());
        int ans = (N - 2) * 180;
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        //var input = Console.ReadLine().Split();
        //int[] X = Array.ConvertAll(input, int.Parse);
        var prog = new Prog();
        prog.run();
    }
}

//Array.ConvertAll(int.Parse)

Measured memory_bytes: 11092
#include<stdio.h>
int main(void)
{
	int i,c,sum=0,A[6]={1,5,10,50,100,500};
	for(i=0;i<6;i++){
		scanf("%d",&c);
		sum = sum + c * A[i];
	}
	if(sum >= 1000)
		printf("1\n");
	else
		printf("0\n");
	return 0;
}

Measured memory_bytes: 584
fun main(args: Array<String>) {
    val n = readInt()
    var h = readIntList().toMutableList()

    if (n == 1) {
        println("Yes")
        return
    }

    if (h[0] >= h[1]) {
        h[0]--
    }

    for (i in 1 until n - 1) {
        if (h[i] > h[i - 1]) {
            h[i]--
            continue
        }
        if (h[i] >= h[i + 1] && h[i] - 1 >= h[i + 1]) {
            h[i]++
            continue
        }
        if (h[i] < h[i - 1] || h[i] > h[i + 1]) {
            println("No")
            return
        }
    }
    if (h[n - 1] < h[n - 2]) {
        println("No")
        return
    }
    println("Yes")
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)


Measured memory_bytes: 56836
#include <iostream>
using namespace std;
int abs(int x){
  if(x > 0)return x;
  else return 0-x;
}
int main(){
  int Sx,Sy;
  int Tx,Ty;
  char V1[3] = {'L','R'};
  char V2[2] = {'D','U'};
  int index1 = 0,index2 = 0;
  cin >> Sx >> Sy >> Tx >> Ty;
  if(Tx > Sx){
    index1 = 1;
  }
  if(Ty > Sy){
    index2 = 1;
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<abs(Tx-Sx);j++){
      cout << V1[index1];
    }
    for(int j=0;j<abs(Ty-Sy);j++){
      cout << V2[index2];
    }
    index1 = (index1+1)%2;
    index2 = (index2+1)%2;
  }
  if(Sx - Tx == 0){
    cout << "R";
    for(int j = 0;j<abs(Ty-Sy);j++){
      cout << V2[index2];
    }
    cout << "LL";
    for(int j=0;j<abs(Ty-Sy);j++){
      cout << V2[(index2+1)%2];
    }
    cout << "R";
  }
  else if(Sy - Ty == 0){
    cout << "D";
    for(int i=0;i<abs(Tx-Sx);i++){
      cout << V1[index1];
    }
    cout << "UU";
    for(int i=0;i<abs(Tx-Sx);i++){
      cout << V1[(index1+1)%2];
    }
    cout << "D";
  }
  else{
    for(int i=0;i<2;i++){
      cout << V2[(index2+1)%2] << V1[index1];
      for(int j=0;j<abs(Tx-Sx);j++){
        cout << V1[index1];
      }
      for(int j=0;j<abs(Ty-Sy);j++){
        cout << V2[index2];
      }
      cout << V2[index2] << V1[(index1+1)%2];
      index1 = (index1+1)%2;
      index2 = (index2+1)%2;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){

    while(true){
        int x, y;
        std::cin >> x >> y;
        if(x == 0 && y == 0){
            break;
        }
        if(x > y){
            std::swap(x, y);
        }
        std::cout << x << " " << y << std::endl;
    }

    return 0;
}


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

using namespace std;

constexpr long long MOD = 998244353LL;

// MOD考慮power関数
template<typename type>
inline type ModPow(type a, type b)
{
	type ret=1;
	while(b>0){
		if(b&0x1) ret=ret*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return ret;
}


// MOD考慮Combination関数使用準備関数
vector<long long> fac;
vector<long long> finv;
vector<long long> inv;
inline void ModCombiSetup(int size)
{
	fac.resize(size+1);
	finv.resize(size+1);
	inv.resize(size+1);
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(long long i=2;i<size;i++){
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}

// MOD考慮Combination関数
inline long long ModCombi(long long n, long long r)
{
	if(n==0 && r==0) return 1;
	if(n<r || n<0) return 0;
	return fac[n]*(finv[r]*finv[n-r]%MOD)%MOD;
}

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

	long long ans=0;
	
	ModCombiSetup(n);

	for(long long i=0;i<=k;i++){
		long long cnt=((m*ModCombi(n-1,i)%MOD)*ModPow(m-1,n-1-i))%MOD;
		ans = (ans+cnt)%MOD;
	}

	cout << ans << endl;
}

Measured memory_bytes: 7892
import java.util.*;
import java.io.BufferedInputStream;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner (new BufferedInputStream(System.in));
    int n = sc.nextInt();
    int res = 0;
    for(int i = 1; i <= n; ++i) {
      for(int j = i; j <= n - i; ++j) {
        int k = n - i - j;
        res = Math.max(res, i * k * j);
      }
    }
    System.out.println(Math.pow((double)n / 3, 3) );
  }
}

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

		

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> k(m);
	vector<vector<int>> s(m, vector<int>(n));
	rep(i,m){
		cin >> k[i];
		rep(j,k[i]) cin >> s[i][j];
	}
	vector<int> p(m);
	rep(i,m) cin >> p[i];

	int count=0;
	vector<int> bin(n);
	for(int b=0; b<pow(2,n); b++){
		int t = b;
		for(int i=n-1; i>=0; i--){
			int in = pow(2,i);
			bin[i]=t/in;
			t = t%in;
		}

		bool flag = 1;
		rep(i,m){
			int tmp=0;
			rep(j,k[i]){
				tmp += bin[s[i][j]-1] ;
			}
			if(tmp%2 != p[i]) flag=0;
		}
		if(flag) count++;
	}
	
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 384
/**********************************
	author:  mariogzsl
**********************************/

#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,b,a) for(int i=b-1;i>=a;i--)
#define f first
#define s second
#define puts(x) cout<<x<<endl
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b,c,d,e,n;
	cin>>n>>a>>b>>c>>d>>e;
	ll aux=min(a,min(b,min(c,min(d,e))));
	cout<<ll((n+aux-1)/aux)+4<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	ll a,b;
	cin>>a>>b;
	ll lc = a*b/__gcd(a,b);
	cout<<lc;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3588
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>
using namespace std;
long long int MOD = 1000000000 + 7;
using ll = long long;
ll LARGE = 1000000;


int main() {
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<ll> p(a);
	vector<ll> q(b);
	vector<ll> r(c);

	for (ll i = 0; i < a; ++i) {
		cin >> p[i];
	}
	for (ll i = 0; i < b; ++i) {
		cin >> q[i];
	}
	for (ll i = 0; i < c; ++i) {
		cin >> r[i];
	}
	sort(p.begin(), p.end(), greater<ll>());
	sort(q.begin(), q.end(), greater<ll>());
	sort(r.begin(), r.end(), greater<ll>());

	vector<ll> red(p.begin(), p.begin() + x);
	vector<ll> gre(q.begin(), q.begin() + y);

	ll rend = x - 1;
	ll gend = y - 1;

	for (ll i = 0; i < c; ++i) {
		if (gend < 0) {
			if (red[rend] < r[i] && 0 <= rend) {
				red[rend] = r[i];
				--rend;
				continue;
			}
			continue;
		}
		if (rend < 0) {
			if (gre[gend] < r[i] && 0 <= gend) {
				gre[gend] = r[i];
				--gend;
				continue;
			}
			continue;
		}
		if (gre[gend] <= red[rend] && gre[gend] < r[i] && 0 <= gend) {
			// wをrにする
			gre[gend] = r[i];
			--gend;
			continue;
		}
		if (red[rend] <= gre[gend] && red[rend] < r[i] && 0 <= rend) {
			// wをrにする
			red[rend] = r[i];
			--rend;
			continue;
		}
		//break;
	}
	ll ans = 0;
	for (ll i = 0; i < x; ++i) {
		ans += red[i];
	}
	for (ll i = 0; i < y; ++i) {
		ans += gre[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3968
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int a, b, c;
	cin >> a >> b >> c;
	cout << (a <= b * c ? "Yes" : "No") << '\n';

	return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#define N 1000

void trace(int A[], int n){
  int i;
  for(i = 0; i < n; i++){
    if(i >= 1) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

main(){
  int i, j, n;
  int arr[N+1];
  int key;

  scanf("%d",&n);

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

  trace(arr, n);

  for(i = 1; i < n; i++){
    key = arr[i];
    j = i-1;
    while(j >= 0 && arr[j] > key){
      arr[j+1] = arr[j];
      j--;
    }
    arr[j+1] = key;
    trace(arr, n);
  }

  return 0;
}




Measured memory_bytes: 2760
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in = new Scanner(System.in);
		int a=in.nextInt();
		int b=in.nextInt();
		if((a+b)%2!=0)
		{
			System.out.println("IMPOSSIBLE");
		}
		else
		{
			System.out.println((a+b)/2);
		}
	}
}
	

Measured memory_bytes: 21844
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var ret = 0;
            for (int i = 1; i <= N; i++)
            {
                if (i.ToString().Length % 2 == 1)
                {
                    ret++;
                }
            }
            Console.WriteLine(ret);
        }
    }
}

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

using namespace std;

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

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

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

ll h1 , m1 , h2 , m2;
ll k;

int main(){
    migmig
    cin >> h1 >> m1;
    cin >> h2 >> m2;
    cin >> k;
    ll ans = (h2 - h1)*60;
    ans+=m2-m1;
    cout << ans - k ;
    
    
    
    
    return(0);
}

Measured memory_bytes: 3692
#include<stdio.h>
int main(){
  char s[100];
  int c,i,k;
  k = 0;
  scanf("%s",s);
  for(c=0;s[c]!='\0';c++);
  for(i=0;i!=c/2;i++){if(s[i] != s[(c-1)-i]) k++;}
  printf("%d",k);
}

Measured memory_bytes: 128
b1,b2,b3=map(int,input().split())

if b1==1:
    if b2==0:
        print("Close")
    else:
        print("Open")
else:
    if b2==0:
        if b3==0:
            print("Close")
        else:
            print("Open")
    else:
        print("Close")



Measured memory_bytes: 5592
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> Vlist = new ArrayList<>();
        List<Integer> Clist = new ArrayList<>();

        for(int i=0; i<N; i++){
            Vlist.add(scanner.nextInt());
        }
        for(int i=0; i<N; i++){
            Clist.add(scanner.nextInt());
        }

        int maxVal = 0;
        for(int i=0; i<N; i++){
            if (Vlist.get(i) - Clist.get(i) >0){
                maxVal = maxVal + Vlist.get(i) - Clist.get(i);
            }
        }

        System.out.println(maxVal);
    }
}

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

for k in range(K):
  imos = [0] * (N+1)
  for i, a in enumerate(A):
    l = max(0, i-a)
    r = min(N, i+1+a)
    imos[l] += 1
    imos[r] -= 1
  imos[0] = min(N, imos[0])
  for i in range(N):
    imos[i+1] = min(N, imos[i] + imos[i+1])
  A = imos[:-1]
  if all(a==N for a in A):
    break

print(*A)
  


Measured memory_bytes: 168828
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		System.out.println("ABC" + N);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 21200
#include<bits/stdc++.h>
using namespace std;
int n,m,k=0;
int dist[2][100005];
int vis[100005];
vector<int> v[100005];
inline void dfs(int x,int l,int k)
{
	vis[x]=1;
	dist[l][x]=k;
	for (int i=0;i<v[x].size();i++)
	{
		if (vis[v[x][i]]==0)
			dfs(v[x][i],l,k+1);
	}
}
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n-1;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	memset(vis,0,sizeof(vis));
	dfs(0,0,0);
	memset(vis,0,sizeof(vis));
	dfs(n-1,1,0);
	int f,s;
	for (int i=0;i<n;i++)
	{
		if (dist[0][i]<=dist[1][i])
			f++;
		else
			s++;
	}
	if (f>s)
		printf("Fennec");
	else
		printf("Snuke");
	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;

const ll inf = (ll)1e9;
ll H,W,ans;
char S[20][20];
ll d[20][20];
ll sx,sy,nx,ny,x,y;
ll dx[4] = {1,0,-1,0},dy[4]={0,1,0,-1};
queue<P> que;

int main(void){
    cin >> H >> W;
    rep(i,H)rep(j,W)cin >> S[i][j];
    ans = 0;
    rep(i,H)rep(j,W){
        rep(k,H)rep(l,W)d[k][l]=inf;
        if(S[i][j]=='#')continue;
        sx = i; sy=j;
        d[sx][sy] = 0;
        que.push(mp(sx,sy));
        while(!que.empty()){
            P p = que.front();que.pop();
            x = p.first;y=p.second;
            rep(k,4){
                nx = x + dx[k];ny=y+dy[k];
                if(nx<0 || nx>=H || ny<0||ny>=W||d[nx][ny]!=inf||S[nx][ny]=='#')continue;
                d[nx][ny] = d[x][y] + 1;
                que.push(mp(nx,ny));
            }
        }
        
        rep(k,H)rep(l,W)if(d[k][l]!=inf)ans = max(ans,d[k][l]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//krishrawat 
 
 
//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 1e6 + 1;//                                                             |
//----------------------------------------------------------------------------------


void solve()
{   
    ll x,y;cin>>x>>y;
    multiset<pp> m;
    sl s;
    for(int i=0;i<x;i++){
        ll a,b;cin>>a>>b;
        m.pb({b,a});
    }
    for(ll i=0;i<y;i++){
    	s.pb(-1*i);
    }
    ll ans=0;
    ll i=0;
    while(!m.empty()){
        ll a=(*--m.end()).ff,b=(*--m.end()).ss;
        ll k=y-b;
        k*=-1;
        auto it=s.lower_bound(k);
        if(it!=s.end()){
        	s.erase(it);
        	ans+=a;
        }
        m.erase(--m.end());
    }
    cout<<ans<<"\n";
}
 
int main()
{	
	#ifndef ONLINE_JUDGE 
   		freopen("input.txt", "r", stdin);  
   		freopen("output.txt", "w", stdout); 
   	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
     

    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
	return 0;
}

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

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

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a_c = a
for i in range(n):
    a_c[i] -= i
a_c.sort()
med = a_c[n // 2]
score = 0
for i in range(n):
    score += abs(a_c[i] - med)
print(score)

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

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

int main(){
  int n;
  cin >> n;
  int ans = 0;
  rep(i, n){
    ll tmp;
    cin >> tmp;
    while(tmp%2 == 0){
      ans++;
      tmp /= 2;
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
N = int(input())
s = input()
l = {}
a = [{} for i in range(N)]
a[-1] = {s[-1]: N-1}

for i in range(N-2, -1 , -1):
  a[i] = a[i+1].copy()
  a[i].update({s[i]: i})

r = 0
for k1, v1 in a[0].items():
  if v1 >= N - 2: continue
  for k2, v2 in a[v1+1].items():
    if v2 >= N - 1 : continue
    r += len(a[v2+1].keys())

print(r)

Measured memory_bytes: 31076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

struct edge{
    int to;
    ll s;
    edge(){};
    edge(int to, ll s) : to(to), s(s) {} 
};

int n, m;
vector<edge> G[100010];
bool used[100010];
int si[100010];//0 : +, 1 : -
ll val[100010];
ll l, r;

void dfs(int v){
    used[v] = true;
    if(si[v] == 1){
        chmin(r, val[v] - 1);
    }else{
        chmax(l, 1 - val[v]);
    }

    for(auto u : G[v]){
        if(si[v] == 1){
            chmax(l, val[v] - u.s + 1);
        }else{
            chmin(r, u.s - val[v] - 1);
        }
        ll vl = u.s - val[v];
        int s = (si[v] + 1) & 1;

        if(used[u.to]){
            if(si[u.to] != s && val[u.to] == vl){
                l = inf, r = -inf;
            }else if(si[u.to] != s && val[u.to] != vl){
                ll p = vl - val[u.to];
                if(abs(p) & 1){
                    l = inf, r = -inf;
                }else{
                    p /= 2;
                    p = abs(p);
                    chmax(l, p);
                    chmin(r, p);
                }
            }else if(si[u.to] == s && val[u.to] != vl){
                l = inf, r = -inf;
            }
        }else{
            val[u.to] = vl;
            si[u.to] = s;
            dfs(u.to);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    l = 1, r = inf;
    for(int i = 0; i < m; ++i){
        int u, v, s;
        cin >> u >> v >> s;
        G[u].emplace_back(edge{v, s});
        G[v].emplace_back(edge{u, s});
    }
    dfs(1);
    cout << max(0LL, r - l + 1) << endl;
    return 0;
}

Measured memory_bytes: 12288
#include <iostream>
#include <string>
using namespace std;
int main(){
    int move[][2] = { {0,1},{1,0},{0,-1},{-1,0} };
    
    while(true){
        int sx,sy;
        int x=1,y=1;
        int dir = 0;
        string command;
        cin >> sx >> sy;
        if(sx==0&&sy==0)return 0;
        while(true){
        cin >> command;
        if(command=="RIGHT"){
            dir = dir+1 >=4 ? 0:dir+1; 
        }else if(command=="LEFT"){
            dir = dir-1 < 0 ? 3:dir-1;
        }else if(command=="FORWARD"){
            int k;
            cin >> k;
            x+=move[dir][0]*k;
            y+=move[dir][1]*k;
            x = max(1,x);
            x = min(sx,x);
            y = max(1,y);
            y = min(sy,y);
        }else if(command=="BACKWARD"){
            int k;
            cin >> k;
            x-=move[dir][0]*k;
            y-=move[dir][1]*k;
            x = max(1,x);
            x = min(sx,x);
            y = max(1,y);
            y = min(sy,y);
        }else if(command=="STOP"){
            cout << x << " " << y << endl;
            break;
        }else{
            cout << "!!!!!!!!!!!!!!!" << endl;
            break;
        }
        }
    }
}

Measured memory_bytes: 0