akhauriyash/Code-Regression huggingface dataset:
import queue
q = queue.Queue()
bool = True


def bfs():
    q.put(0)
    while not q.empty():
        now = q.get()
        for i in nodes[now]:
            if dist[i] != -1:
                continue
            dist[i] = dist[now] + 1
            q.put(i)
            ans[i] = now
    bool = False


N, M = map(int, input().split())
nodes = [[] for i in range(N)]
idxStock = []
for i in range(M):
    a, b = map(int, input().split())
    nodes[a - 1].append(b - 1)
    nodes[b - 1].append(a - 1)

dist = [-1] * N
ans = [-1] * N
bfs()
if bool:
    print("Yes")
    for i in range(1, N):
        print(ans[i]+1)
else:
    print("No")

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

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

constexpr int MOD = 1000000007;

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

    ll n, d, a;
    cin >> n >> d >> a;

    vector<pair<ll, ll>> xh(n);
    rep(i, 0, n) {
        ll x, h;
        cin >> x >> h;
        xh[i] = make_pair(x, h);
    }

    sort(xh.begin(), xh.end());

    vi maxj(n);
    ll sum = 0, cum = 0;

    int j = 0;
    rep(i, 0, n) {
        ll num = max(ll(0), (xh[i].second + a - 1) / a);
        sum += num;

        while (j < n && xh[j].first <= xh[i].first + 2 * d) {
            xh[j].second -= cum;
            cum += max(ll(0), a * ((xh[j].second + a - 1) / a));
            j++;
        }
        cum -= num * a;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4224
#include <algorithm>
#include <iostream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef pair < int, int > pii;
const int inf = 1e9 + 7;

#define nd second
#define st first
#define mp make_pair
#define pb push_back

const int N = 2e5 + 6;
const int logN = 17;

int n, k, x, F[N], a[N], pre[N];

void upd(int x) {
	for(; x < N; x += x & -x)
		F[x]++;
}

int que(int x) {
	int ans = 0;
	for(; x > 0; x -= x & -x)
		ans += F[x];
	return ans;
}

ll get(int x) {
	memset(pre, 0, sizeof pre);
	for(int i = 1; i <= n; i++) {
		if(a[i] > x)
			pre[i] = -1;
		else pre[i] = 1;
		pre[i] += pre[i - 1];
	}
	int T = min(*min_element(pre + 1, pre + n + 1), 0);
	for(int i = 0; i <= n; i++) pre[i] -= T - 1;
	memset(F, 0, sizeof F);
	ll cur = 0; upd(1);
	for(int i = 1; i <= n; i++) {
		cur += que(pre[i] - 1);
		upd(pre[i]);
	} return cur;
}

int main() {
	int n, m;
  	cin >> n >> m;
  cout << n - m + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	
	vector<int> ans(N + 1);
	
	FOR(i, 1, 100) FOR(j, 1, 100) {
		FOR(k, 1, 100) {
			int cur = i * i + j * j + k * k;
			cur += i * j + j * k + i * k;
			if (cur > N) break;
			++ans[cur];
		}
	}
	FOR(i, 1, N + 1) printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 3720
s=input()
n=len(s)
ans=0
for i in range(n):
    for j in range(i,n):
        bubun=s[i:j+1]
        flag=True
        for c in bubun:
            if(c not in ['A','G','C','T']):flag = False
        if(flag):ans = max(ans,len(bubun))
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a.back() == b.front() && b.back() == c.front()) {
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	//2338 start
	
	int [] p1 = {0,0,1,1,2,2};
	int [] p2 = {1,2,0,2,0,1};
	int [] p3 = {2,1,2,0,1,0};
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int [][] data = new int[n][3];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < 3; j++){
					data[i][j] = sc.nextInt();
				}
			}
			
			ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
			for(int i = 0; i < n; i++){
				list.add(new ArrayList<Integer>());
				
				for(int j = 0; j < 6; j++){
					int h = data[i][p1[j]];
					int m = data[i][p2[j]];
					int s = data[i][p3[j]];
					
					
					for(int offset = 0; offset < 60; offset++){
						int hh = (h + offset) % 60;
						int mm = (m + offset) % 60;
						int ss = (s + offset) % 60;
						if(hh % 5 != mm / 12) continue;
						list.get(i).add(calc(hh / 5, mm, ss));
						//System.out.println(hh + " " + mm + " " + ss + " " + calc(hh % 12, mm, ss));
					}
				}
				Collections.sort(list.get(i));
				//System.out.println(list.get(i));
			}
			
			int INF = 1 << 24;
			int anss = INF, anse = 0, diff = INF;
			for(int i = 0; i < n; i++){
				for(int j = 0; j < list.get(i).size(); j++){
					int s = list.get(i).get(j);
					int e = s;
					boolean flg = true;
					for(int k = 0; k < n; k++){
						if(i == k) continue;
						int ke = -1;
						for(int kk = 0; kk < list.get(k).size(); kk++){
							int temp = list.get(k).get(kk);
							if(temp >= s){
								ke = temp;
								break;
							}
						}
						if(ke == -1){
							flg = false;
							break;
						}
						e = Math.max(e, ke);
					}
					if(! flg) continue;
					int d = e - s;
					if(d < diff){
						anss = s;
						anse = e;
						diff = d;
					}
					else if(d == diff && s < anss){
						anss = s;
						anse = e;
					}
				}
			}
			//System.out.println(anss + " " + anse + "diff = " + diff);
			print(anss, anse);
		}
	}
	
	private int [] totime(int time){
		int h = time / 3600;
		int m = (time - 3600 * h) / 60;
		int s = time - 3600 * h - 60 * m;
		return new int[]{h,m,s};
	}

	private void print(int anss, int anse) {
		int [] s = totime(anss);
		int [] e = totime(anse);
		System.out.printf("%02d:%02d:%02d ",s[0], s[1], s[2]);
		System.out.printf("%02d:%02d:%02d\n", e[0], e[1], e[2]);
	}

	private int calc(int hh, int mm, int ss) {
		return hh * 3600 + mm * 60 + ss;
	}

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

Measured memory_bytes: 13000
import sys
import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

H, W = rl()
A = [list(rs()) for _ in range(H)]

INF = 10 ** 5
B = np.array([[0 if x == '#' else INF for x in row] for row in A])

for i in range(1, H):
    B[i] = np.minimum(B[i], B[i-1] + 1)
for i in range(H-2, -1, -1):
    B[i] = np.minimum(B[i], B[i+1] + 1)
for j in range(1, W):
    B[:, j] = np.minimum(B[:, j], B[:, j-1] + 1)
for j in range(W-2, -1, -1):
    B[:, j] = np.minimum(B[:, j], B[:, j+1] + 1)

print(B.max())



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

#define first  fs
#define second se
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, char s = '\n') { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	char a, b;
	cin >> a >> b;

	cout << (a == b ? "H" : "D") << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define repi(i,n) for(int i=0;i<(int)(n);i++)
#define repd(i,n) for(int i=(int)(n);i>=0;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)

int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    cout << min(C,int(B/A)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

const ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    mint K;
    cin >> N >> K.x;
    vec<ll> divisors;
    if(N==1){
        cout << K.x << endl;
        return 0;
    }
    for(int i=1;i*i<=N;i++){
        if(N%i==0){
            if(i<=N/2) divisors.push_back(i);
            if(i<=N/2 && i*i!=N) divisors.push_back(N/i);
        }
    }
    sort(divisors.begin(),divisors.end());
    int n = divisors.size();
    vec<mint> f(n),g(n);
    for(int i=0;i<n;i++){
        if(N%2) g[i] = K.pow((divisors[i]+1)/2);
        else{
            g[i] = (N/2%divisors[i]? K.pow(divisors[i]/2):K.pow(divisors[i]));
        }
        for(int j=0;j<i;j++) if(divisors[i]%divisors[j]==0) g[i] -= g[j];
    }
    mint ans = 0;
    for(int i=n-1;i>=0;i--){
        f[i] = g[i];
        ans += f[i]*divisors[i];
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 256
;;(declaim (optimize (speed 0) (safety 3) (debug 3)))
(declaim (optimize (debug 0) (safety 0) (speed 3)))

(defvar n (read))
(defvar m (read))

(defvar *aisles* (make-array m))
(dotimes (i m)
  (let* ((a (read))
	 (b (read)))
    (setf (aref *aisles* i) (cons a b))))

(defstruct chamber
  id
  neighbors
  visited)

(defvar *chambers* (make-array n))
(dotimes (i n)
  (setf (aref *chambers* i) (make-chamber :id (1+ i)
					  :neighbors nil
					  :visited nil)))


(declaim (inline chamber-by-id))
(defun chamber-by-id (id)
  (aref *chambers* (1- id)))

;; setup neighbors
(dotimes (i m)
  (let ((a (aref *aisles* i)))
    (let ((c (chamber-by-id (car a))))
      (setf (chamber-neighbors c) (cons (cdr a) (chamber-neighbors c))))
    (let ((c (chamber-by-id (cdr a))))
      (setf (chamber-neighbors c) (cons (car a) (chamber-neighbors c))))))

(defvar *torch* (make-array (1+ n)))
(defvar queue (make-array (+ 5 n)))
(defvar i 0)
(defvar j 0)

(declaim (inline popq pushq emptyq))
(defun popq ()
  (let ((x (aref queue i)))
    (incf i)
    x))
(defun pushq (item)
  (setf (aref queue j) item)
  (incf j))
(defun emptyq ()
  (= i j))

(pushq (chamber-by-id 1))
(do ((item (if (emptyq) (return)(popq)) (if (emptyq) (return)(popq))))
    (nil)
    (dolist (nei-id (chamber-neighbors item))
      (let ((nei (chamber-by-id nei-id)))
	(if (not (chamber-visited nei))
	    (progn
	      (setf (chamber-visited nei) t)
	      (setf (aref *torch* nei-id) (chamber-id item))
	      (pushq nei))))))
  
(if (every #'chamber-visited *chambers*)
    (progn
      (format t "Yes~%")
      (loop for i from 2 to n
	    do (format t "~a~%" (aref *torch* i))))
  (format t "No"))


Measured memory_bytes: 88400
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

bool valide(int n) {
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0 && i == n/i) return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    string a, b;
    cin >> a >> b;
    
    if (valide(stoi(a+b)) || valide(stoi(b+a))) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
}


Measured memory_bytes: 3628
#include <cstdio>
#include <vector>
#include <set>
#include <stack>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

struct UndirectionalCompare {
  bool operator() (const Edge& e, const Edge& f) const {
    if (min(e.src,e.dst) != min(f.src,f.dst))
      return min(e.src,e.dst) < min(f.src,f.dst);
    return max(e.src,e.dst) < max(f.src,f.dst);
  }
};
typedef set<Edge, UndirectionalCompare> Edgeset;
void visit(const Graph &g, int v, int u,
    set<int>& art, vector<Edgeset>& bcomp,
    stack<Edge>& S, vector<int>& num, vector<int>& low, int& time) {
  low[v] = num[v] = ++time;
  FOR(e, g[v]) {
    int w = e->dst;
    //if (num[w] < num[v]) S.push(*e);              // for bcomps
    if (num[w] == 0) {
      visit(g, w, v, art, bcomp, S, num, low, time);
      low[v] = min(low[v], low[w]);
      if ((num[v] == 1 && num[w] != 2) ||         // for arts
          (num[v] != 1 && low[w] >= num[v])) art.insert(v);
      /*if (low[w] >= num[v]) {                     // for bcomps
        bcomp.push_back(Edgeset());
        while (1) {
          Edge f = S.top(); S.pop();
          bcomp.back().insert(f);
          if (f.src == v && f.dst == w) break;
        }
      }*/
    } else low[v] = min(low[v], num[w]);
  }
}
void articulationPoint(const Graph& g,
    set<int>& art, vector<Edgeset>& bcomp) {
  const int n = g.size();
  vector<int> low(n), num(n);
  stack<Edge> S;
  REP(u, n) if (num[u] == 0) {
    int time = 0;
    visit(g, u, -1, art, bcomp, S, num, low, time);
  }
}

int main(){
	int V,E,s,t;
	scanf("%d%d",&V,&E);
	Graph g(V);
	set<int> art;
	vector<Edgeset> bcomp;
	for(;E--;)scanf("%d%d",&s,&t),g[s].push_back(Edge(s,t,0)),g[t].push_back(Edge(t,s,0));
	articulationPoint(g,art,bcomp);
	FOR(e, art)printf("%d\n",*e);
}

Measured memory_bytes: 4684
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

// agc018.contest.atcoder.jp/tasks/agc018_b

size_t agc018_b()
{
  size_t n, m;
  cin >> n >> m;
  vector<vector<size_t>> a(n, vector<size_t>(m));
  cin >> a;
  for(auto & r: a) --r;

  vector<bool> tag(m, true);
  vector<size_t> cnt(m);
  vector<size_t> idx;
  for(const auto & r: a)
  {
    ++cnt[r[0]];
    idx.push_back(0);
  }

  size_t out = n; // *max_element(begin(cnt), end(cnt));

  for(size_t k = 0; ; ++k)
  {
    const size_t j = max_element(begin(cnt), end(cnt)) - begin(cnt);
    DEBUG(cnt);
    DEBUG(j);

    out = min(out, cnt[j]);
    tag[j] = false;
    cnt[j] = 0;

    if(k + 1 == m) break;
    for(size_t i = 0; i < n; ++i)
      if(a[i][idx[i]] == j)
      {
        while(!tag[a[i][idx[i]]]) ++idx[i];
        ++cnt[a[i][idx[i]]];
      }
  }

  return out;
}

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << agc018_b();

  return EXIT_SUCCESS;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,T,c,t;
  cin >> N >> T;
  int m = 1001;
  for (int i = 0; i < N; i++){
    cin >> c >> t;
    if (t <= T) m = min(m,c);
  }
  if (m == 1001){
    cout << "TLE";
  } else {
    cout << m;
  }
}

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

int main()
{
    int a, b;

    cin >> a;

    string outStr = "";
    if (30 <= a)
    {
        outStr = "Yes";
    }
    else
    {
        outStr = "No";
    }
    
    cout << outStr << endl;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
const int maxn = 1e5 + 10;

vector<int> g[maxn];
bool visited[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	int fi, se;
	for (int i = 0; i < m; i++){
		int v, u;
		cin >> v >> u;
		fi = v, se = u;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	visited[fi] = visited[se] = 1;
	deque<int> deq;
	deq.push_front(fi);
	deq.push_back(se);
	while (true){
		bool flag = 0;
		for (auto v : g[fi]){
			if (!visited[v]){
				visited[v] = 1;
				deq.push_front(v);
				flag = 1;
				fi = v;
				break;
			}
		}
		if (flag == 0)
			break;
	}
	while (true){
		bool flag = 0;
		for (auto v : g[se]){
			if (!visited[v]){
				visited[v] = 1;
				deq.push_back(v);
				flag = 1;
				se = v;
				break;
			}
		}
		if (flag == 0)
			break;
	}
	cout << deq.size() << endl;
	for (int i = 0; i < deq.size(); i++)
		cout << deq[i] << " ";
	cout << endl;
}


Measured memory_bytes: 6784
#include <iostream>
#include <vector>
#define eol '\n'
using namespace std;

vector< vector<int> > list;
vector<int> d, f;
int t;

void dfs(int v) {
  if (d[v] != 0) {
    return;
  }
  
  d[v] = t++;
  for (int i = 0; i < list[v].size(); i++) {
    int visit = list[v][i];
    dfs(visit);
  }
  f[v] = t++;
}
  

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

  t = 1;
  
  int n;
  cin >> n;

  list.resize(n+1);
  d.resize(n+1, 0);
  f.resize(n+1, 0);

  for (int i = 0; i < n; i++) {
    int u,k;
    cin >> u >> k;
    
    vector<int> row(k);
    for (int j = 0; j < k; j++) {
      cin >> row[j];
    }
    
    list[u] = row;
  }

  for (int i = 1; i <= n; i++) {
    dfs(i);
  }
  
  for (int i = 1; i <= n; i++) {
    cout << i << " " << d[i] << " " << f[i] << eol;
  }

  return 0;
}

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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		 
		long []arr =new long[n];
		for(int i=0;i<n;i++){
			arr[i]=scn.nextLong();
		}
		Arrays.sort(arr);
		long ans=0;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(arr[i]==arr[j]){
					continue;
				}
				for(int k=j+1;k<n;k++){
					if(arr[i]==arr[k] || arr[j]==arr[k]){
						continue;
					}
					 long sum=arr[i]+arr[j];
					 if(sum>arr[k]){
						 ans++;
					 }
				}
			}
		}
		System.out.println(ans);
		

	}

}

Measured memory_bytes: 36440
//#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <tuple>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }


#define INF 100000000
using namespace std;
using ll = long long;



vector < pair<string, int>> p(100);
int order[100];

void allSwap(int a) {
	swap(p[a].first, p[a + 1].first);
	swap(p[a].second, p[a + 1].second);
	swap(order[a], order[a + 1]);
}

int main() {
	int n;
	cin >> n;
	rep(i, n) {
		string s; int a;
		cin >> s >> a;
		p[i].first = s;
		p[i].second = a;
		order[i] = i + 1;
	}
	int j = n - 1;
	while (j > 0) {
		rep(i, j) {
			if (p[i].first > p[i + 1].first) {
				allSwap(i);
			}
			else if (p[i].first == p[i + 1].first && p[i].second < p[i + 1].second) {
				allSwap(i);
			}
		}
		j--;
	}
	rep(i, n) {
		cout << order[i] << endl;
	}
}

Measured memory_bytes: 3624
n=int(input())
s=input()
if n%2==1:
    print("No")
elif n==2:
    if s[0]==s[1]:
        print("Yes")
    else:
        print("No")
else:
    if s[0:(n//2)-1]==s[(n//2):n-1]:
        print("Yes")
    else:
        print("No")

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

#pragma GCC optimize("O3")
#pragma GCC target("sse2,avx,avx2,fma")

const long long MOD = 998244353;

long long inv[10000005];
long long invFact[10000005];
//long long fact[10000005];

long long powmod(long long a, long long b){
    long long x = 1;
    long long y = a;
    while(b){
        if(b&1){ x = (x*y)%MOD; }
        y = (y*y)%MOD;
        b >>= 1;
    }
    return x;
}

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

    inv[1] = 1;
    for(int i = 2; i <= N; i ++){
        inv[i] = inv[MOD%i]*(MOD-MOD/i)%MOD;
    }

    //fact[0] = 1;
    //long long factN = 1;
    invFact[0] = 1;
    for(int i = 1; i <= N; i ++){
        //factN = (factN*i)%MOD;
        //fact[i] = (fact[i-1]*i)%MOD;
        invFact[i] = (invFact[i-1]*inv[i])%MOD;
    }

    long long tempPow2 = 1;
    long long ans = 0;
    for(int i = N; i > (N>>1); i --){
        ans += (((tempPow2*invFact[N-i])%MOD) * invFact[i])%MOD;

        tempPow2 += tempPow2;
        if(tempPow2 >= MOD){tempPow2 -= MOD;}
    }

    long long factN = powmod(invFact[N], MOD-2);

    ans = (ans+ans)%MOD;
    ans = ans*factN%MOD;
    long long finalAns = (powmod(3, N)-ans+MOD)%MOD;

    printf("%lld", finalAns);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

namespace Rho {
  ull mul (ull a, ull b, ull mod) {
    ll ret = a * b - mod * (ull) (1.L / mod * a * b);
    return ret + mod * (ret < 0) - mod * (ret >= (ll) mod);
  }

  ull bigMod (ull a, ull e, ull mod) {
    ull ret = 1;
    while (e) {
      if (e & 1) ret = mul(ret, a, mod);
      a = mul(a, a, mod), e >>= 1;
    }
    return ret;
  }
    
  bool isPrime (ull n) {
    if (n < 2 or n % 6 % 4 != 1) return (n | 1) == 3;
    ull a[] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022};
    ull s = __builtin_ctzll(n - 1), d = n >> s;
    for (ull x : a) {
      ull p = bigMod(x % n, d, n), i = s;
      while (p != 1 and p != n - 1 and x % n and i--) p = mul(p, p, n);
      if (p != n - 1 and i != s) return 0;
    }
    return 1;
  }
    
  ull pollard (ull n) {
    auto f = [&] (ull x) {return mul(x, x, n) + 1;};
    ull x = 0, y = 0, t = 0, prod = 2, i = 1, q;
    while (t++ % 40 or __gcd(prod, n) == 1) {
      if (x == y) x = ++i, y = f(x);
      if ((q = mul(prod, max(x, y) - min(x, y), n))) prod = q;
      x = f(x), y = f(f(y));
    }
    return __gcd(prod, n);
  }

  vector <ull> factor (ull n) {
    if (n == 1) return {};
    if (isPrime(n)) return {n};
    ull x = pollard(n);
    auto l = factor(x), r = factor(n / x);
    l.insert(l.end(), r.begin(), r.end());
    return l;
  }
};

const int N = 100003;

int n;
map <ll, int> f;
map <ll, ll> rev;

int main() {
  cin >> n;
  int ans = 0, one = 0;
  for (int i = 1; i <= n; ++i) {
    ll x, cur = 1, oth = 1;
    scanf("%lld", &x);
    vector <ull> facs = Rho::factor(x);
    sort(facs.begin(), facs.end());
    bool done = 0;
    for (int j = 0; j < facs.size();) {
      ll p = facs[j]; int k = j, e = 0;
      while (k < facs.size() and facs[k] == facs[j]) ++k, ++e;
      e %= 3, j = k;
      if (!e) continue;
      if (p >= N) {
        done = 1, ++ans; break;
      }
      // cout << p << " " << e << '\n';
      for (k = 0; k < e; ++k) cur *= p;
      e = 3 - e;
      while (e--) oth *= p;
    }
    if (done) continue;
    // cout << cur << " --- " << oth << '\n';
    if (cur == 1) ++one;
    else ++f[cur], f[oth], rev[cur] = oth, rev[oth] = cur;
  }
  ans <<= 1;
  for (auto it : f) {
    ll x = it.first;
    int cnt = it.second;
    // cout << x << " " << cnt << " " << f[rev[x]] << endl;
    ans += max(cnt, f[rev[x]]);
  }
  ans >>= 1, ans += !!one;
  cout << ans << '\n';
  return 0;
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

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

   int n, m, p;
   while(cin >> n >> m >> p){
      int a[n], buy = 0;
      if(n == 0 && m == 0 && p == 0) break;
      rep(i,n){
         cin >> a[i];
         buy += a[i];
      }
      if(a[m - 1] == 0) cout << 0 << endl;
      else cout << (100 * buy - buy * p) / a[m - 1] << endl;
   }

   return 0;
}


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

using namespace std;


int dfs(int v, vector< vector<bool> > &G, vector<bool> &visited){
    bool F = true;
    for(int i = 0; i < visited.size(); i++){
        if(visited[i] == false){
            F = false;
            break;
        }
    }

    if(F == true){
        return 1;
    }else{
        int res = 0;
        
        for(int i = 0; i < visited.size(); i++){
            if(G[v][i] == true && visited[i] == false){
                visited[i] = true;
                res += dfs(i, G, visited);
                visited[i] = false;
            }else{
                continue;
            }
        }
        return res;
    }
}


int main(){
    int N, M;
    cin >> N >> M;
    vector< vector<bool> > G(N, vector<bool>(N, false));
    int a, b;
    for(int i = 0; i < M; i++){
        cin >> a >> b;
        a--; b--;
        G[a][b] = true; G[b][a] = true;
    }

    vector<bool> visited(N, false);
    visited[0] = true;

    int ans = dfs(0, G, visited);
    cout << ans << endl;

    return 0;
}

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

int main(){
  int N,B=0;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    B^=A.at(i);
  }
  for(int i=0;i<N;i++){
    int C=B^A.at(i);
    cout << C;
    if(i==N-1){
      cout << endl;
    }
    else{
      cout << " ";
    }
  }
}
  

Measured memory_bytes: 4024
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll infll=(1ull<<63)-1,mod=1e9+7;
const int inf=(1ull<<31)-1;
int n,s=0;
int dp[13][100001];
string a;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>a;
	n=a.size();
	dp[0][0]=1;
	for (int i=0;i<n;i++)
		for (int j=0,t;j<13;j++)
			if (dp[j][i])
				if (a[i]=='?')
					for (int k=0;k<10;k++){
						t=(j*10+k)%13;
						dp[t][i+1]=(dp[t][i+1]+dp[j][i])%mod;
					}
				else {
					t=(j*10+(a[i]-'0'))%13;
					dp[t][i+1]=(dp[t][i+1]+dp[j][i])%mod;
				}
	cout<<dp[5][n];
	return 0;
}


Measured memory_bytes: 5584
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:1048576")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef tuple <int, int, int> t3;

int IT_MAX = 1 << 12;
const ll MOD = 1000000009;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)

int chk[200050];
int main() {
	int N, M, i;
	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		if (t1 > t2) swap(t1, t2);
		if (t1 == 1) chk[t2] |= 1;
		if (t2 == N) chk[t1] |= 2;
	}
	for (i = 2; i < N; i++) if (chk[i] == 3) return !printf("POSSIBLE\n");
	return !printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 1024
use std::collections::HashSet;

fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let abc = readn::<usize>(" ");
    let mut set = HashSet::new();
    for i in 0..3 {
        set.insert(abc[i]);
    }
    println!("{}", set.len());
}

Measured memory_bytes: 4352
num=int(input())
a_array=[]
b_array=[]
for n in range(2*num):
    elem=[int(n) for n in input().split()]
    if n < num:
        a_array.append(elem)
    else:
        b_array.append(elem)
a_array.sort(key=lambda x:x[1])
a_array.reverse()
b_array.sort(key=lambda x: x[0])
answer=0
for b_x, b_y in b_array:
    for a_x, a_y in a_array:
        if b_x > a_x and b_y > a_y:
            answer=answer+1
            a_array.remove([a_x,a_y])
            break;
print(answer)

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

#define rep(i, n) for(int i = 0; i < (n); i++)

using namespace std;
using lint = long long;

int main(void)
{
    lint x, K;
    cin >> x >> K;

    lint y = x / K * K;
    
    lint ans = min(abs(x - y), abs(y+K - x));
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <set>
#include <iostream>
#include <algorithm>

using namespace std;
#define REP(i, n)  for(int i=0;i<(int)(n);++i)
#define FOR(i, b, n)  for(int i=b;i<(n);++i)
#define ALL(c) (c).begin(),(c).end()
#define PB(c) push_back(c)
#define SS size()
#define ST first
#define ND second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

int main() {
    int n, a, b; cin >> n >> a>> b;
    cout << ((abs(b-a)%2==0)?"Alice":"Borys") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;

    ll left = 0,right = 0;
    ll answer = 0;
    int i = 0;
    while(i < s.length()){
        left = 0;
        right = 0;
        while(s[i] == '<'){
            left++;
            i++;
        }
        while(s[i] == '>'){
            right++;
            i++;
        }
        ll smaller,bigger;
        smaller = min(left,right);
        bigger = max(left,right);

        answer += smaller*(smaller-1)/2;
        answer += bigger*(bigger+1)/2;
        //cout << left << " " << right << endl;
    }
    cout << answer << endl;
    return 0;
} 

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
int a[1000010],n,r,s1,s2;
int main(){
	scanf("%d",&n);
	for(int i=0;i<(1<<n);i++)
		scanf("%d",&a[i]);
	for(int i=1;i<(1<<n);i++){
		s1=a[0],s2=0;
		for(int j=i;j;j=(j-1)&i){
			if(a[j]>s1){
				s2=s1;
				s1=a[j];
			}
			else if(a[j]>s2)
				s2=a[j];
		}
		r=max(r,s1+s2);
		printf("%d\n",r);
	}
}

Measured memory_bytes: 4096
package main

import (
	"fmt"
)

func isPrimeNumber(n int) bool {
	if n == 2 {
		return true
	}
	for i := 2; i < n; i++ {
		if n % i == 0 {
			return false
		}
	}
	return true
}
func main() {
	var x int
	fmt.Scanf("%d", &x)
	if isPrimeNumber(x) {
		fmt.Printf("%d", x)
		return
	}

	for i := x + 1 ; ; i++ {
		if isPrimeNumber(i) {
			fmt.Printf("%d", i)
			break
		}
	}
}

Measured memory_bytes: 512
//最悪O(Q^2) 最短O(N+Q)
//番号→名簿番号(hashT[]から検索) 名簿番号→番号(meibo2[]から検索)

#include<iostream>
#include<vector>
using namespace std;
typedef pair<int,int> P;

struct Pos{
	int num,cnt;
};
int N,Q;
int hashT[1000001];
int meibo[100001],meibo2[100001],mcor = 0;	//mcor = 登録人数,meibo[] = cnt,meibo2[] = num;
vector<P> ans;

int main(){
	int i;
	Pos pos;
	cin >> N >> Q;
	for(i = 1;i <= N;i++){
		hashT[i] = -1;
	}
	//pos(ランキング1位)の初期化っぽいこと
	{
		int a = 1,b = 0;
		hashT[a] = mcor;
		meibo[mcor] = b;
		meibo2[mcor] = a;
		pos.num = a;
		pos.cnt = b;
		//ans.push_back(P(a,b));
		mcor++;
	}
	//1回目の大会から
	for(i = 0;i < Q;i++){
		int a,b;
		cin >> a >> b;
		//meiboに登録されていなければ登録
		if(hashT[a] == -1){
			hashT[a] = mcor;
			meibo[mcor] = b;
			meibo2[mcor] = a;
			mcor++;
		}
		//登録されていたら指定された所を更新
		else{
			meibo[hashT[a]] += b;
		}
		//現在の1位の魚の数の更新
		pos.cnt = meibo[hashT[pos.num]];
		//今の更新について
		//1位のキャッチ、1位以外のリリースなら順位はそのまま
		if((b > 0 && a == pos.num) || (b < 0 && a != pos.num))
			goto SAVEPOS;
		//1位以外のキャッチの場合
		else if(b > 0){
			//今キャッチした人と今の1位を比べる
			if((meibo[hashT[a]] > pos.cnt)||(a < pos.num && meibo[hashT[a]] == pos.cnt)){
				//最高記録の塗り替え
				pos.num = a;
				pos.cnt = meibo[hashT[a]];
			}
		}
		//1位のリリースの場合
		else if(b < 0){
			//最高記録を愚直に調べる。(記録を調べる順番は番号昇順でなくてもよいはず(任意のはず))
			//追記:meibo2[j] < pos.num を meibo2[j] < pos.cntとしていた。カウントと番号間違えるなんて＞＜
			for(int j = 0;j < mcor;j++){
				if((meibo[j] == pos.cnt && meibo2[j] < pos.num)||(meibo[j] > pos.cnt)){
					pos.num = meibo2[j];
					pos.cnt = meibo[j];
				}
			}
			//全ての参加者が0匹の時は1番が1位
			/*if(pos.cnt == 0){
				pos.num = 1;
				pos.cnt = 0;
			}*/
		}
SAVEPOS:
		ans.push_back(P(pos.num,pos.cnt));
	}
	int size = ans.size();
	for(i = 0;i < size;i++){
		cout << ans[i].first << " " << ans[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 6712
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
const long long inf=6000000000000000000ll;
int Q,n,m,D,c[27],a[N][27],t[N],su[27],ans,i,j,x,y,as[N],s;
set<int> p[27];
int cal(int x,int y)
{
	int sum=ans;
	sum-=a[x][t[x]];
	sum+=a[x][y];
	auto it=p[t[x]].find(x);
	auto e=it;
	--e;
	++it;
	sum+=c[t[x]]*(-(*it-*e)*(*it-*e-1)/2+(x-*e)*(x-*e-1)/2+(*it-x)*(*it-x-1)/2);
	it=p[y].lower_bound(x);
	e=it;
	--e;
	sum-=c[y]*(-(*it-*e)*(*it-*e-1)/2+(x-*e)*(x-*e-1)/2+(*it-x)*(*it-x-1)/2);
	return sum;
}
void Change(int x,int y)
{
	ans-=a[x][t[x]];
	ans+=a[x][y];
	auto it=p[t[x]].find(x);
	auto e=it;
	--e;
	++it;
	ans+=c[t[x]]*(-(*it-*e)*(*it-*e-1)/2+(x-*e)*(x-*e-1)/2+(*it-x)*(*it-x-1)/2);
	p[t[x]].erase(x);
	t[x]=y;
	p[t[x]].insert(x);
	it=p[t[x]].find(x);
	e=it;
	--e;
	++it;
	ans-=c[t[x]]*(-(*it-*e)*(*it-*e-1)/2+(x-*e)*(x-*e-1)/2+(*it-x)*(*it-x-1)/2);
}
void up()
{
	if(s<ans)
	{
		s=ans;
		for(int i=1;i<=D;++i)
			as[i]=t[i];
	}
}
mt19937 rnd(time(0));
double rand_f() {return double(rnd())/double(RAND_MAX);}

void SA()
{
	double T=1000;
	while(T>0.01)
	{
		int a=rnd()%D+1,b=rnd()%26+1;
		while(b==t[a])
			b=rnd()%26+1;
		int tmp=cal(a,b);
		if(tmp>ans||rand_f()<exp((tmp-ans)/T))
		{
			Change(a,b);
			up();
		}
		T=T*0.999;
	}
	//cout<<ans<<endl;
}
int main()
{
	scanf("%d",&D);
	for(i=1;i<=26;++i)
	{
		scanf("%d",&c[i]);
		p[i].insert(D+1);
		p[i].insert(0);
	}
	for(i=1;i<=D;++i)
		for(j=1;j<=26;++j)
			scanf("%d",&a[i][j]);
	for(i=1;i<=D;++i)
		scanf("%d",&t[i]);
	for(i=1;i<=D;++i)
	{
		for(j=1;j<=26;++j)
			++su[j];
		t[i]=1;
		for(j=2;j<=26;++j)
			if(su[t[i]]*c[t[i]]+a[i][t[i]]<su[j]*c[j]+a[i][j])
				t[i]=j;
		ans+=a[i][t[i]];
		su[t[i]]=0;
		for(j=1;j<=26;++j)
			ans-=su[j]*c[j];
		p[t[i]].insert(i);
		as[i]=t[i];
	}
	s=ans;
	while(1.0*clock()/CLOCKS_PER_SEC<1.5)
		SA();
	//cout<<s<<endl;
	for(i=1;i<=D;++i)
		cout<<as[i]<<endl;
}

Measured memory_bytes: 4428
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	while(true) {
    		int n = sc.nextInt();
    		int q = sc.nextInt();
    		if(n==0 && q==0) break;
    		int [] date = new int[101];
    		for(int i=0;i<101;i++) {
    			date[i] = 0;
    		}
        	for(int i=0;i<n;i++) {
        		int m = sc.nextInt();
        		for(int j=0;j<m;j++) {
        			int a = sc.nextInt();
        			date[a] += 1;
        		}
        	}
        	int max = 0;
        	int day = 0;
        	for(int i=1;i<101;i++) {
        		if(date[i]>max) {
        			day = i;
        			max = date[i];
        		}
        	}
        	if(max>=q) {
        		System.out.println(day);
        	}else {
        		System.out.println("0");
        	}
    	}
    }
}



Measured memory_bytes: 69168
package main

import "fmt"

func main() {

	var A, B int
	fmt.Scan(&A , &B)

	if A % 2 == 1 && B % 2 == 1 {
		var k = (A + B) / 2
		fmt.Println( k )
	}else if A % 2 == 0 && B % 2 == 0 {
		var k = (A + B) / 2
		fmt.Println(k)
	}else {
		fmt.Println("IMPOSSIBLE")
	}
	
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int N, A, B;
int h[100100];

bool check(int cnt) {
    int n = cnt;
    int k[100100];
    rep(i, N) k[i] = h[i];
    rep(i, N) {
        k[i] -= B * n;
    }
    rep(i, N) {
        if(k[i] > 0) {
            n -= ((k[i] + A - 1) / A);
        }
    }
    if(n >= 0) return true;
    else return false;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    cin >> N >> A >> B;
    A -= B;
    rep(i, N) {
        cin >> h[i];
    }
    //魔物を倒す順は関係ない、回数だけわかればOK
    int ng = -1, ok = INF;
    while(ok - ng > 1) {
        int mid = (ok + ng) / 2;
        if(check(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N,M;
    cin >> N >> M;
    ll ans = 0;
    if (N * 2 > M){
        ans += M / 2;
    }
    else{
        M -= N * 2;
        ans += N;
        ans += M / 4;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn f(a: u64, b: u64) -> u64{
    let mut x = cmp::max(a, b);

    let mut ans = 0;
    while x > 0{
        ans += 1;
        x /= 10;
    }

    return ans;
}

fn main(){
    let n: u64 = read_as_vec()[0];
    let mut ans = std::u64::MAX;
    for a in 1..(n as f64).sqrt().floor() as u64 + 1{
        if n%a == 0{
            ans = cmp::min(ans, f(a, n/a));
        }
    }

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


Measured memory_bytes: 4352
A, B, K = gets.split.map(&:to_i)

ans = 0

t = [A, B].min
# p t
k = 0

t.downto(1) do |i|
  
  k+=1 if ( A % i == 0 && B % i == 0)
  # p [i,k] if ( A % i == 0 && B % i == 0)
  if k == K
    ans = i
    break
  end
  
end

# puts [t,k]
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e8;
const ll infl = 1LL << 60;


int main() {
  ll N; cin >> N;
  ll dif_n = N;
  ll dif = 10; 
  if(N % 2 != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0; 
  while(N>=dif){
    ans+=(N/dif);
    dif*=5;
  }
  cout << ans << endl;
}

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

using namespace std;

void solve(long N, vector<long> A) {
  vector<long> count(N);
  rep(i, N - 1) {
    count[A[i] - 1]++;
  }
  rep(i, N) {
    cout << count[i] << endl;
  }
}

int main(){
  // int 3E4
  // long 2E9
  // long long 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  long N;
  cin >> N;
  vector<long> A(N-2+1);
  for(int i = 0 ; i < N-2+1 ; i++){
    cin >> A[i];
  }
  solve(N, move(A));
  return 0;
}


Measured memory_bytes: 6372
#include <iostream>

using namespace std;

int main()
{
      char c;
      cin >> c;
      if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
            cout << "vowel";
      else
      {
            cout << "consonant";
      }
      return 0;
}


Measured memory_bytes: 256
import math
import itertools

n = int(input())
town_list = [list(map(int,input().split())) for _ in range(n)]
ave_list = []

for pattern in list(itertools.permutations(range(n))):
    dist = 0
    for i in range(len(pattern)-1):
        dist += math.sqrt((town_list[pattern[i]][0]-town_list[pattern[i+1]][0])**2 + (town_list[pattern[i]][1]-town_list[pattern[i+1]][1])**2)
    ave_list.append(dist)

print(sum(ave_list)/len(ave_list))

Measured memory_bytes: 9332
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	double res = 0.0;
	long N; cin >> N;
	double x[100];
	string u[100];

	for (long i = 0; i <= N - 1; i++) cin >> x[i] >> u[i];

	for (long i = 0; i <= N - 1; i++) if (u[i] == "JPY") res += x[i]; else res += x[i] * 380000.0;

	cout << res << endl;

}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)

min = 1
max = N

1.upto(M) do
  l, r = gets.split.map(&:to_i)

  min = l if min <= l
  max = r if max >= r
end

ans = max - min + 1
puts  ans.negative? ? 0 : ans

Measured memory_bytes: 1788
import java.util.*;

public class Main {
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
		int[] c = new int[n-1];
		int[] s = new int[n-1];
		int[] f = new int[n-1];
		int[] a = new int[n];

		for (int i = 0; i < n-1; i++) {
			c[i] = sc.nextInt();
			s[i] = sc.nextInt();
			f[i] = sc.nextInt();
		}

		for (int i = 0; i < n-1; i++) {
			int aa = 0;
			for (int j = i; j < n-1; j++) {
				int wait = 0;
				if (aa < s[j]) {
					wait += s[j] - aa;
				} else {
					wait += (f[j] - (aa % f[j])) % f[j];
				}
				aa += wait;
				aa += c[j];
			}
			a[i] = aa;
		}
		a[n-1] = 0;

		for (int i = 0; i < n; i++) {
			System.out.println(a[i]);
		}
	}
}


Measured memory_bytes: 26448
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    ll N;
    cin >> N;
    vector<ll> v(N);
    for(ll i = 0; i < N; i++){
        ll a;
        cin >> a;
        v[a-1] = i;
    }

    ll tmp = 0;
    ll maxi = 0;
    for(int i = 1; i < N; i++){
        if(v[i] > v[i-1]) tmp ++;
        else{
            maxi = max(maxi, tmp);
            tmp = 0;
        } 
    }
    maxi = max(maxi, tmp);

    cout << N - maxi - 1 << endl;

}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  int ans = 0;
  if(a < b){
    ans = b + b - 1;
  } else if(a > b){
    ans = a + a - 1;
  } else {
    ans = a + b;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int ans = 0;
    rep(i,n) ans += p[i];
    int mx = 0;
    rep(i,n) mx = max(mx, p[i]);
    ans -= mx*0.5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>

int main(){
    int n, k;
    std::cin >> n >> k;
    std::vector<int> a(200001, 0);
    std::set<int> st;
    for(int i = 0; i < n; i++){
        int tmp;
        std::cin >> tmp;
        a[tmp]++;
        st.insert(tmp);
    }

    std::sort(a.begin(), a.end());
    auto iter = std::lower_bound(a.begin(), a.end(), 1);
    int cnt = 0;
    if(st.size() < k){
        std::cout << cnt << std::endl;
        return 0;
    }
    for(int i = 0; i < st.size() - k; i++){
        cnt += *iter;
        iter++;
    }

    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 10368