akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N; string S;
    cin >> N >> S;
    long long r = 0, g = 0, b = 0;
    for (auto c : S) {
        if (c == 'R') ++r;
        else if (c == 'G') ++g;
        else ++b;
    }
    long long all = r * g * b;
    long long sub = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (S[i] == S[j]) continue;
            int k = j*2-i;
            if (k >= N || S[k] == S[i] || S[k] == S[j]) continue;
            ++sub;
        }
    }
    cout << all - sub << endl;
}

Measured memory_bytes: 3588
def f1(c, l):
    for i in range(3):
        if c*3 == l[i]:
            return 1
    return 0

def f2(c, l):
    for i in range(0, 7, 3):
        s = set(h[i:i+3])
        if c in s and len(s) == 1:
            return 1
    return 0

def f3(c, l):
    if c*3 == l[0]+l[4]+l[8]:
        return 1
    if c*3 == l[2]+l[4]+l[6]:
        return 1
    return 0

while True:
    try:
        w = [input() for _ in range(3)]
    except:
        break
    if f1('b', w):
        print('b')
        continue
    if f1('w', w):
        print('w')
        continue
    h = [w[j][i] for i in range(3) for j in range(3)]
    if f2('b', h):
        print('b')
        continue
    if f2('w', h):
        print('w')
        continue
    if f3('b', h):
        print('b')
        continue
    if f3('w' , h):
        print('w')
        continue
    print("NA")

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

const ULL M = 1000000007;

ULL powm(ULL a, ULL i) {
    if (!i) return 1;
    if (i & 1) return powm(a * a % M, i >> 1) * a % M;
    return powm(a * a % M, i >> 1);
}

ULL F[10001], I[10001], iF[10001];

ULL C(ULL n, ULL r) { return F[n] * iF[r] % M * iF[n - r] % M; }
ULL P(ULL n, ULL r) { return F[n] * iF[n - r] % M; }
ULL H(ULL n, ULL r) { return C(r + n - 1, n - 1); }

struct Problem {

    void Solve() {
        F[0] = 1; for (UL i = 1; i <= 10000; i++) F[i] = F[i - 1] * i % M;
        I[1] = 1; for (UL i = 2; i <= 10000; i++) I[i] = M - M / i * I[M % i] % M;
        iF[0] = 1; for (UL i = 1; i <= 10000; i++) iF[i] = iF[i - 1] * I[i] % M;
        ULL N, K; cin >> N >> K;
        cout << (N <= K ? 1 : 0) << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}



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

//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2027297#1
public class Main {

	static int vertex;
	static int edges;
	static boolean[] visited;
	static int[] cost;
	static int[] parent;
	static ArrayList<Edge>[] graph;
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static final int INFINITY = Integer.MAX_VALUE;
	static Main obj = new Main();

	class Edge implements Comparable<Edge> {

		int from;
		int to;
		int weight;

		public Edge(int from, int to, int weight) {
			this.from = from;
			this.to = to;
			this.weight = weight;
		}

		@Override
		public int compareTo(Edge other) {
			int diff = weight - other.weight;
			return diff;
		}

	}

	public static void main(String[] args) throws IOException {

		input();
		prim();

	}

	@SuppressWarnings("unchecked")
	public static void input() throws IOException {
		StringTokenizer st = new StringTokenizer(br.readLine());
		vertex = Integer.parseInt(st.nextToken());
		edges = Integer.parseInt(st.nextToken());
		visited = new boolean[vertex];
		cost = new int[vertex];
		parent = new int[vertex];
		graph = new ArrayList[vertex];
		for (int i = 0; i < graph.length; i++) {
			graph[i] = new ArrayList<Edge>();
		}
		for (int i = 0; i < edges; i++) {
			st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			int c = Integer.parseInt(st.nextToken());

			graph[a].add(obj.new Edge(a, b, c));
			graph[b].add(obj.new Edge(b, a, c));

		}
		for (int i = 0; i < cost.length; i++) {
			cost[i] = INFINITY;
		}

	}

	public static void prim() {

		int added = 1;
		int sum = 0;
		visited[0] = true;
		cost[0] = 0;
		PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
		for (Edge e : graph[0]) {
			pq.offer(e);
		}
		while (!pq.isEmpty()) {
			Edge e = pq.poll();
			if (visited[e.to]) {
				continue;
			}

			sum += e.weight;
			added++;
			cost[e.to] = e.weight;
			parent[e.to] = e.from;
			visited[e.to] = true;

			if (added == vertex) {
				break;
			}
			for (Edge q : graph[e.to]) {
				if (visited[q.to]) {
					continue;
				} else {
					pq.offer(q);
				}
			}

		}
		System.out.println(sum);

	}

}

Measured memory_bytes: 71116
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int q,n;
vl a;
string s;

int main(){
	cin>>q;
	while(q){
		cin>>n;
		a=vl(n);
		for(auto &i:a) cin>>i; 
		cin>>s;
		reverse(a.begin(),a.end());
		reverse(s.begin(),s.end());
		vl b;
		bool B=0;
		for(int i=0;i<n;i++){
			ll x=a[i];
			for(auto j:b) x=min(x,x^j);
			if(s[i]=='0') b.push_back(x);
			else if(x) B=1;
		}
		cout<<B<<endl;
		q--;
	}
}

Measured memory_bytes: 3516
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <functional>

using namespace std;

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

    stringstream m;

    m << n;

    string number = m.str();

    if((number[0] == number[1] && number[1] == number[2]) || (number[1] == number[2] && number[2] == number[3])){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
  return 0;
}


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

int main()
{
	const string str[100] = {
		"", "Man", "Oku", "Cho",
		"Kei", "Gai", "Jo", "Jou",
		"Ko", "Kan", "Sei", "Sai",
		"Gok", "Ggs", "Asg", "Nyt",
		"Fks", "Mts"
	};
	int m, n;
	while (scanf("%d %d", &m, &n), m){
		vector<int> res(100);
		res[0] = 1;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < 99; j++){
				res[j] *= m;
			}
			for (int j = 0; j < 99; j++){
				res[j + 1] += res[j] / 10000;
				res[j] %= 10000;
			}
		}
		for (int i = 99; i >= 0; i--){
			if (res[i]){
				printf("%d", res[i]);
				cout << str[i];
			}
		}
		puts("");
	}
	return 0;
}

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

int main() {
  long long A,B,K;
  cin >> A >> B >> K;
  if(A>K) cout << A-K << " " << B << endl;
  else cout << 0 << " " << max((long long)0,B-(K-A)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,d,r;
  scanf("%d %d",&a,&b);
  if(1<=a && a<=1000000000 && 1<=b && b<=1000000000){
  d = a	/ b;
  r = a	% b;
  double x = a;
  double y = b;
  double f = x / y;
  printf("%d %d %.5lf\n",d,r,f);
  }
  return 0;
}

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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
  int n;
  cin >> n;
  vector<int> A(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> A[i];
  }
  vector<int> take(n + 1);
  for (int i = n; i >= 1; --i) {
    int nxt = 0;
    for (int j = 2 * i; j <= n; j += i) {
      nxt += take[j];
    }
    nxt %= 2;
    take[i] = (nxt != A[i]);
  }
  cout << accumulate(take.begin() + 1, take.end(), 0) << "\n";
  for (int i = 1; i <= n; ++i) {
    if (take[i]) {
      cout << i << " ";
    }
  }
  cout << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  test_case();
  return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;
const ll inf = (ll) 1e18;
constexpr int maxn = 401;
ll dp[maxn][maxn];

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

  vector<ll> v(n);
  for (ll& e : v) cin >> e;

  vector<ll> w(n);
  partial_sum(begin(v), end(v), begin(w));

  for (int i = 0; i < n; i++) dp[i][i + 1] = v[i];

  for (int i = n - 1; i >= 0; i--) {
    for (int j = i + 2; j <= n; j++) {
      ll& ans = dp[i][j];
      ans = inf;

      for (int k = i; k <= j; k++) {
        ll tmp = w[j - 1] - (i > 0 ? w[i - 1] : 0);
        if (k > i) tmp += dp[i][k];
        if (k + 1 <= j) tmp += dp[k][j];
        ans = min(ans, tmp);
      }
    }
  }
  cout << dp[0][n] - w.back() << endl;

  return 0;
}


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

void search(vector<vector<int>> &g, queue<int> &q, vector<int> &f, vector<bool> &tr)
{
    int s = q.front(); q.pop();
    for (int t:g[s])
    {
        if (tr[t])
        {
            q.push(t); tr[t] = false;
            f.push_back(t);
        }
    }
    if (q.size() < 1) return;
    else
    {
        search(g, q, f, tr);
    }
}

int main(void)
{
    int n, m, k; cin >> n >> m >> k;
    vector<int> a(m), b(m), c(k), d(k);
    vector<vector<int>> g(n, vector<int>(0));
    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        g[a[i]-1].push_back(b[i]-1);
        g[b[i]-1].push_back(a[i]-1);
    }
    for (int i = 0; i < k; i++)
    {
        cin >> c[i] >> d[i];
    }
    vector<bool> tr(n, true); tr[0];
    queue<int> q;
    int fid = 0;
    vector<vector<int>> friends(0, vector<int>(0));
    vector<int> ids(n);
    for (int i = 0; i < n; i++)
    {
        if (tr[i])
        {
            tr[i] = false;
            q.push(i);
            vector<int> f; f.push_back(i);
            search(g, q, f, tr);
            friends.push_back(f);
            for (int s:f) ids[s] = fid;
            fid++;
        }
    }
    vector<int> cnt(n, 1);
    for (int i = 0; i < m; i++)
    {
        if (ids[a[i]-1] == ids[b[i]-1])
        {
            cnt[a[i]-1]++;
            cnt[b[i]-1]++;
        }
    }
    for (int i = 0; i < k; i++)
    {
        if (ids[c[i]-1] == ids[d[i]-1])
        {
            cnt[c[i]-1]++;
            cnt[d[i]-1]++;
        }
    }
    int ans;
    for (int i = 0; i < n; i++)
    {
        ans = friends[ids[i]].size() - cnt[i];
        cout << ans << " ";
    }
    cout << endl;
}

Measured memory_bytes: 21612
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

const int N=1e5+4;
int p[N],tam[N];

int find(int u){
	if(u==p[u])return u;
	return p[u]=find(p[u]);
}

void uni(int u,int v){
	int pu=find(u),pv=find(v);
	p[pu]=pv;
	tam[pv]+=tam[pu];
}

int main(){	
	fastio;
	int n,m;cin>>n>>m;
	vector<ii>vec;
	FER(i,0,m){
		int u,v;cin>>u>>v;
		u--,v--;
		vec.pb({u,v});
	}
	reverse(all(vec));
	vector<ll>ans;
	FER(i,0,n)p[i]=i,tam[i]=1;
	ll tot=(1LL*n*(n-1))/2;
	ans.pb(tot);
	FER(i,0,m-1){
		int pu=find(vec[i].ff);
		int pv=find(vec[i].ss);
		if(pu!=pv){
			tot-=tam[pu]*tam[pv];
			uni(vec[i].ff,vec[i].ss);
		}
		ans.pb(tot);
	}

	reverse(all(ans));
	for(ll uwu:ans)cout<<uwu<<endl;

	
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

struct node { int parent, left, right; };

node tree[25];

void preorder(int p) {
  cout << ' ' << p;
  if (tree[p].left != -1) {
    preorder(tree[p].left);
  }
  if (tree[p].right != -1) {
    preorder(tree[p].right);
  }
}

void inorder(int p) {
  if (tree[p].left != -1) {
    inorder(tree[p].left);
  }
  cout << ' ' << p;
  if (tree[p].right != -1) {
    inorder(tree[p].right);
  }
}

void postorder(int p) {
  if (tree[p].left != -1) {
    postorder(tree[p].left);
  }
  if (tree[p].right != -1) {
    postorder(tree[p].right);
  }
  cout << ' ' << p;
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, p = -1;
  cin >> N;
  REP(i, N) tree[i].parent = -1;
  REP(i, N) {
    int j, l, r;
    cin >> j >> l >> r;
    tree[l].parent = tree[r].parent = j;
    tree[j].left = l;
    tree[j].right = r;
  }
  REP(i, N) {
    if (tree[i].parent == -1) {
      p = i;
      break;
    }
  }
  cout << "Preorder" << endl;
  preorder(p);
  cout << endl;
  cout << "Inorder" << endl;
  inorder(p);
  cout << endl;
  cout << "Postorder" << endl;
  postorder(p);  
  cout << endl;
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <boost/foreach.hpp>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin>>N;
  ll A[N],B[N];
  vector< vector<ll> > v (N, vector<ll>(2) );
  for(int i=0;i<N;i++){
  cin>>v[i][2]>>v[i][1];
  }
  sort(v.begin(),v.end());
  ll count=0;
  bool flag=0;
  for(int i=0;i<N;i++){
    count+=v[i][2];
    if(count>v[i][1]){
      cout<<"No"<<endl;
      flag=1;
      break;
    }
    //  cout<<v[i][1]<<"  " <<v[i][2]<<endl;
  }
  if(flag!=1){
  cout<<"Yes"<<endl;
  }
}



Measured memory_bytes: 11136
N, M = map(int, input().split())
ans = 0
MOD = 10**9 + 7

def func(n):
    sum = 1
    for i in range(1, n+1):
        sum = sum*i % MOD
    return sum 

if abs(N - M) == 0:
    ans = 2 * func(N)*func(M)
elif abs(N - M) == 1:
    ans = func(N)*func(M)
    
print(ans % MOD)


Measured memory_bytes: 2940
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    mod = 1000000007

    for i in range(60):
        x = 0
        for j in range(n):
            if a[j] >> i & 1:
                x += 1
        
        now = x * (n - x) % mod
        for j in range(i):
            now = now * 2 % mod
        ans += now
        ans %= mod
    print(ans)

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

void convert(int x, int p){
	if( p == 12 ) return;
	convert(x/2, p+1);
	if( p == 3 ) cout << ".";
	cout << x%2;
}

int main(){
	for( double x; cin >> x && x >= 0; ){
		int shift = (int)(x*16);
		if( x == shift/16.0 && shift < 4096 ){
			convert( shift, 0 );
			cout << endl;
		} else {
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;
 
int main() {
    int M;
    cin >> M;
 
    cout << 48 - M << endl;
 
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    string s;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        mp[s]++;
    }
    int mx = 0;
    for (auto &x : mp){
        chmax(mx, x.second);
    }

    vector<string> res;
    for (auto &x : mp){
        if (x.second == mx) res.push_back(x.first);
    }
    sort(all(res));

    for (int i = 0; i < res.size(); ++i) {
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 27184
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;

    #define MAXN 1000005
    int spf[MAXN];
    void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;

        for (int i=3; i*i<MAXN; i++)
        {
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)

                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }


    vector<int> gf(int x)
    {
        vector<int> ret;
        while (x != 1)
        {
            ret.push_back(spf[x]);
            x = x / spf[x];
        }
        return ret;
    }
    int BIT[100050];
    void upd(int x) { ++x;  while(x<=MAXN)  {  BIT[x]++;  x+=(x&-x);  } }
    int cal(int x) {  ++x;  int res=0;  while(x>0)  {  res+=BIT[x];  x-=(x&-x);  } return res; }

    ll mod=hell;
    ll pr( ll x , ll y)
    {
        ll ans=1;
        if(y==0) return ans;
        while(y>1)
        {
            if(y&1) ans*=x;
            x*=x;
            y/=2;
            x%=mod;
            ans%=mod;
        }
        ans*=x;
        ans%=mod;
        return ans;
    }
    ll inv(ll n)
    {
        return pr(n,mod-2);
    }
    ll stoi(string s)
    {
        int n=s.size();
        ll k=0; int i;
        rep(i,0,n)
        {
            k+=s[i]-'0';
            k*=10;
        }
        return k/10;
    }
    string to_string(ll n)
    {  if(!n) return "0";
        string s=""; int a,b;
        while(n>0)
        {
            b=n%10;
            s+=(b+'0');
            n/=10;
        }
        reverse(all(s));
        return s;
    }
  ll invvf[1000500],fact[1000500];
  void pre()
  {
      ll i,j,n=1000050;
      fact[0]=1; fact[1]=1;
      rep(i,2,n) {fact[i]=fact[i-1]*i; fact[i]%=hell;}
      invvf[1]=1; invvf[0]=1;
      rep(i,2,n)
      {
          invvf[i]=inv(fact[i]);
      }

  }
 ll ncr(ll n , ll r)
 {
     ll y=fact[n];
     y*=invvf[r];
     y%=hell;
     y*=invvf[n-r];
     y%=hell;
     return y;
 }


int phi(int n) {
    int result = n;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}
    void solve()
    {
    long long  i,j=0,r=200,p,q,k=0,d,y=0,n,h=100000000000000,flag=0,m=0,a=hell,b=hell,id,h1,h2,a1,b1,a2,w,x,u,f,l,c=0,e,ans=0;
      cin>>n>>m;
      if(abs(n-m)%2) {cout<<"IMPOSSIBLE";}
      else cout<<abs(n-m)/2+min(n,m);


    }
    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        //sieve();
        //pre();
       // cin>>t;
        while(t--)
        solve();
    }


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

using namespace std;

struct RadixHeap {
  using uint = unsigned;
  vector< uint > v[33];
  uint size, last;

  RadixHeap() : size(0), last(0) {}

  bool empty() const { return size == 0; }

  inline int getbit(int a) {
    return a ? 32 - __builtin_clz(a) : 0;
  }

  void push(uint key) {
    ++size;
    v[getbit(key ^ last)].emplace_back(key);
  }

  uint pop() {
    if(v[0].empty()) {
      int idx = 1;
      while(v[idx].empty()) ++idx;
      last = *min_element(begin(v[idx]), end(v[idx]));
      for(auto &p : v[idx]) v[getbit(p ^ last)].emplace_back(p);
      v[idx].clear();
    }
    --size;
    auto ret = v[0].back();
    v[0].pop_back();
    return ret;
  }
};

int main() {
  int N, M, X[100000], Y[100000];

  scanf("%d %d", &N, &M);
  vector< int > ev[400];
  for(int i = 0; i < M; i++) {
    scanf("%d %d", &X[i], &Y[i]);
    --X[i], --Y[i];
    ev[X[i]].emplace_back(i);
    ev[Y[i]].emplace_back(i);
  }

  int ret = 0;

  int beet[100000];
  int uku[400];
  memset(beet, -1, sizeof(beet));
  memset(uku, -1, sizeof(uku));

  auto add = [&](int x, int done, int ptr, RadixHeap &que) {
    if(uku[x] == ptr) return true;
    uku[x] = ptr;
    for(int j = 0; j < ev[x].size(); j++) {
      if(ev[x][j] >= done) break;
      if(beet[ev[x][j]] == ptr) return false;
      beet[ev[x][j]] = ptr;
      que.push(M - 1 - ev[x][j]);
    }
    return true;
  };

  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      int vv = i * N + j;
      bool ok = true;
      RadixHeap que;
      ok &= add(i, M, vv, que);
      ok &= add(j, M, vv, que);
      while(!que.empty() && ok) {
        auto p = M - 1 - que.pop();
        ok &= add(X[p], p, vv, que);
        ok &= add(Y[p], p, vv, que);
      }
      ret += ok;
    }
  }
  printf("%d\n", ret);
}


Measured memory_bytes: 2688
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")



int main() {
	ll D, T, S;
  cin >>D>>T>>S;
	if (S * T >= D)PRIY;
	else PRIN;
	return 0;
}




Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;

int main() {
	int N, K;
	string S;
	cin >> N >> K >> S;

	int happy = 0;
	for (int i = 1; i < N; i++)if (S[i] == S[i - 1])happy++;

	int cnt = 0;
	for (int i = 1; i < N;i++) {
		if (S[i] != S[i - 1])cnt++;
	}
	cout << min(N - 1, happy + min(cnt, 2 * K)) << endl;

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>

using namespace std;

int main() {
  string S;
  int K;
  cin >> S;
  cin >> K;
  if(S[0] == '1') {
    int cnt = 1;
    while(cnt < K) {
      if (S[cnt] != '1') {
        cout << S[cnt] << endl;
        exit(0);
      }
      cnt++;
    }
    cout << S[cnt-1] << endl;
    exit(0);
  } else {
    cout << S[0];
  }
  return 0;
}

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

int main(){
  int N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;
  string T;cin >> T;
  for(int i = 0;i < K;++i){
    int j = i + K;
    while(j < N){
      if(T[j - K] == T[j])
        T[j] = 'x';
      j += K;
    }
  }

  int score = 0;
  for(int i = 0;i < N;++i){
    if(T[i] == 'r')
      score += P;
    else if(T[i] == 's')
      score += R;
    else if(T[i] == 'p')
      score += S;
  }

  cout << score;
}


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

int main(){
    int k,x;
    cin>>k>>x;
    
    if(500*k>=x) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

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

/// Constant:
#define         eps         10e-9
#define         pi          2*acos(0)
#define         P1          1e9+7
#define         P2          1e9+9
#define         lli         long long int
/// Loop:
#define         f1(a,b)     for (int i=a; i<=b; i++)
#define         f2(a,b)     for (int j=a; j<=b; j++)
#define         f-1(a,b)     for (int i=b; i>=a; i--)
#define         f-2(a,b)     for (int j=b; j>=a; j--)
///Print:
#define         pY          cout<<"YES"<<endl;
#define         pN          cout<<"NO"<<endl;
#define         py          cout<<"Yes"<<endl;
#define         pn          cout<<"No"<<endl;

using namespace std;
///ISNNJB

/// Functions:
//lli bigmod(lli b, lli p, lli m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ lli res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//lli mod_inverse(lli a, lli mod) { return bigmod(a,mod-2,mod); }
//lli LCM(lli a, lli b){ return a*b/ __gcd(a,b);}

///Global Variable:
int ara[300005],brr[100004];

/**int fx[]={+1,-1,+0,+0};
int fy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};*/

int main() {

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    lli a,b,c,d,t,n,m,x,y,q,ctn=0,l1,l2,total=0;
    string s,p;
    cin>>s>>p;
    l1=s.length();

    f1(0,l1-1) {
        if(s[i]!=p[i])
            ctn++;
    }
    cout<<ctn<<endl;

    return 0;
}



Measured memory_bytes: 3884
n = int(input())
score = 0
outcount = 0
first = 0
second = 0
third = 0
for i in range(n):
	while outcount < 3:
		event = input()
		if event == 'HIT':
			if third == 1:
				score += 1
			third = second
			second = first
			first = 1
		if event == 'HOMERUN':
			score = score + first + second + third + 1
			first = second = third = 0
		if event == 'OUT':
			outcount += 1
	print(score)
	score = 0
	outcount = 0
	first = 0
	second = 0
	third = 0
	

Measured memory_bytes: 7572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[100][100];
int h, w;
bool chk(int x, int y){

  if(x<0 || y<0 || h<=x || w<=y || s[x][y]!='#') return false;
  return true;
}
int main(){

  cin >> h >> w;
  string ans="Yes";
    for(int i=0; i<h; i++)
      for(int j=0; j<w; j++) cin >> s[i][j];

    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
        if(s[i][j] == '#'){
          if(chk(i+1, j)) continue;
          if(chk(i-1, j)) continue;
          if(chk(i, j+1)) continue;
          if(chk(i, j-1)) continue;
          
           ans = "No";
        }
      }
    }
      cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll find(vll &r,vll &g, vll &b,string &s,char c ){
    ll ans=0;
     for(int i=0;i<r.size();i++){
        
        ll  j=lower_bound(g.begin(),g.end(),r[i])-g.begin();
        for(;j<g.size();j++){
              ans+=b.end()-lower_bound(b.begin(),b.end(),g[j]);
              if((2*g[j]-r[i])<s.size() && s[2*g[j]-r[i]]==c)
              ans--;
        }
    
    }
    return ans;

}
int main(){
    boost;
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vll r,g,b;
    fr(i,0,s.size()){
        if(s[i]=='R')
        r.pb(i);
        else if(s[i]=='G')
        g.pb(i);
        else b.pb(i);  
           }
    ll ans=0;
     
     ans+=find(r,g,b,s,'B');
     ans+=find(r,b,g,s,'G');
     ans+=find(g,b,r,s,'R');
     ans+=find(g,r,b,s,'B');
     ans+=find(b,r,g,s,'G');
     ans+=find(b,g,r,s,'R');
    cout<<ans<<endl;
  
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

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

ll n, w, w1, wc[4];
vector<ll> v[4], vs[4];

ll solve(int i, ll rem) {
	if (rem < 0) return 0;
	if (i == 4) return 0;
	ll res = 0;
	REP(j, min(wc[i], rem / (w1 + i)) + 1) res = max(res, vs[i][j] + solve(i + 1, rem - (w1 + i) * j));
	return res;
}

int main(int argc, char **argv) {
	cin >> n >> w;
	CLEAR(wc);
	REP(i, n) {
		ll tw, tv;
		cin >> tw >> tv;
		if (i == 0) w1 = tw;
		tw -= w1;
		++wc[tw];
		v[tw].push_back(tv);
	}
	REP(i, 4) {
		sort(ALL(v[i]));
		reverse(ALL(v[i]));

		vs[i].push_back(0);
		REP(j, v[i].size()) {
			vs[i].push_back(vs[i][j] + v[i][j]);
		}
	}
	cout << solve(0, w) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}
 
int32_t main()
{
    fast;
    int n; cin >> n;
    Rep(i, 1, n) cin >> x[i] >> y[i];
    double ans = 0;

    Rep(i, 1, n) {
        Rep(j, i+1, n) ans += dist(i, j) * 2 / n;
    }

    cout << ps(ans, 10) << "\n";

    
    
    
    return 0;
}

Measured memory_bytes: 4100
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,p;
  while(cin>>n>>m>>p,n){
    int sum=0;
    int x[n+1];
    for(int i=1;i<=n;++i){
      cin>>x[i];
      sum+=x[i];
    }
    sum*=100-p;
    if(x[m])
      cout<<sum/x[m]<<endl;
    else
      cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 3084
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int main(){
	string red,green,bottom;
	while(cin>>red,red!="-"){
		cin>>green>>bottom;
		string right;
		int len=green.length();
		int cur=0;
		vs rg;
		rg.push_back(green);
		rg.push_back(red);
		while(!rg[0].empty()||!rg[1].empty()){
			if(bottom.empty()||rg[cur][0]!=bottom[0]){
				right.push_back(rg[cur][0]);
				rg[cur].erase(rg[cur].begin(),rg[cur].begin()+1);
				cur=0;
			}else{
				rg[cur].erase(rg[cur].begin(),rg[cur].begin()+1);
				bottom.erase(bottom.begin(),bottom.begin()+1);
				cur=1;
			}
		}
		cout<<right<<endl;
	}

}

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

int main () {
  //freopen(".inp", "r", stdin);
  //freopen(".out", "w", stdout);
  ios_base :: sync_with_stdio (0);
  cin.tie (nullptr);
  cout.tie (nullptr);
  int a, b;
  cin >> a >> b;
  cout << max (a + b, max (a - b, a * b));
}


Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let k: usize = read();
    let s = read::<String>().as_bytes().to_vec();

    println!(
        "{}",
        std::cmp::min(s.windows(2).filter(|x| x[0] == x[1]).count() + 2 * k, n - 1)
    );
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();

    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
using namespace std;
int main(){
    int c=0,d=0;
    string a,b;
    cin >> a;
    cin >> b;
    for(int l=0;a[l]!='\0';l++){
        d++;
    }
    for(int i=0;i<d;i++){
        if(a[i]!=b[i]){
            c++;
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3736
import math


n, k = [int(i) for i in input().split()]
prob = 0
for i in range(1, n + 1):
    if i >= k:
        exp = 0
    else:
        exp = math.ceil(math.log2(k) - math.log2(i))
    prob += (1 / n) * (1 / 2) ** exp
print(prob)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <map>
#include <unordered_set>

using namespace std;

// DFS on tree
void count(vector<int> &counter, map<int, unordered_set<int>> &edges, int number) {
    int v = counter[number];

    for(auto child: edges[number]) {
        counter[child] += v;
        edges[child].erase(number);
        count(counter, edges, child);
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;

    map<int, unordered_set<int>> edges;

    for(int i = 1; i < N; ++i) {
        int a, b;
        cin >> a >> b;

        edges[a].insert(b);
        edges[b].insert(a);
    }

    vector<int> counter(N+1);
    for(int i = 1; i <= Q; ++i) {
        int p, x;
        cin >> p >> x;

        counter[p] += x;
    }

    count(counter, edges, 1); // DFS the root

    for(int i = 1; i <= N; ++i)
        cout << counter[i] << " ";
    cout << endl;
    return 0;
}



Measured memory_bytes: 68736
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

int rad[400010];

void longest_palindrome(const char *text, int n) {
    int i, j, k;
    for (i = 0, j = 0; i < 2*n; i += k, j = max(j-k, 0LL)) {
        while (i-j >= 0 && i+j+1 < 2*n && text[(i-j)/2] == text[(i+j+1)/2]) ++j;
        rad[i] = j;
        for (k = 1; i-k >= 0 && rad[i]-k >= 0 && rad[i-k] != rad[i]-k; ++k)
            rad[i+k] = min(rad[i-k], rad[i]-k);
    }
}


void solve(std::string A){
    int N = A.size();
    map<char,int> mp;
    for(int i = 0; i < N; ++i) {
        mp[A[i]]++;
    }
    int res = N * (N - 1) / 2 + 1;
    for(auto p: mp) {
        res -= p.second * (p.second - 1) / 2;
    }
    cout << res << endl;
}

signed main(){
	ios::sync_with_stdio(false);
    std::string A;
    std::cin >> A;
    solve(A);
    return 0;
}

Measured memory_bytes: 788
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		String result = "Three";
		for(int i = 0; i < n; i++){
		    String s = sc.next();
		    if(s.equals("Y")) result = "Four";
		}
		
		// 計算
		
		// 出力
		System.out.println(result);
	}
}




Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

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

//max:2192

unsigned short int dp[5][32770];

int main(){
  unsigned short int i,j,k;
  int n;
  for(i=1; i*i<(1<<15); i++){
    dp[1][i*i] = 1;
    for(j=i*i+1; j<(1<<15); j++){
      for(k=1; k<4; k++){
	dp[k+1][j] += dp[k][j-i*i];
      }
    }
  }
#if DEB
  int mx = 0;
  rep(i,1<<15){
    rep(j,5){
      mx = max(mx, dp[j][i]);
    }
  }
  printf("max:%d\n",mx);
#endif
  while(scanf("%d",&n),n){
    printf("%d\n",dp[1][n]+dp[2][n]+dp[3][n]+dp[4][n]);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,M;
  cin>>A>>B>>M;
  vector<int> P(A),Q(B);
  for(int i=0;i<A;i++){
    cin>>P.at(i);
  }
  for(int i=0;i<B;i++){
    cin>>Q.at(i);
  }
  vector<int> cost;
  for(int i=0;i<M;i++){
    int x,y,c;
    cin>>x>>y>>c;
    cost.push_back(P.at(x-1)+Q.at(y-1)-c);
  }
  sort(P.begin(),P.end());
  sort(Q.begin(),Q.end());
  for(int i=0;i<min(A,B);i++){
    cost.push_back(P.at(i)+Q.at(i));
  }
  sort(cost.begin(),cost.end());
  cout<<cost.at(0)<<endl;
  return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
#define E 0.0000001

int main(){
    ll N, K;
    cin >> N >> K;
    vl H(N);

    for(int i=0; i<N; i++) cin >> H.at(i);

    sort(H.begin(), H.end());
    reverse(H.begin(), H.end());

    ll sum = 0;

    for(int i=K; i<N; i++){
        sum += H.at(i);
    }

    cout << sum << endl;

}

Measured memory_bytes: 2304
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DNonDecreasing solver = new DNonDecreasing();
        solver.solve(1, in, out);
        out.close();
    }

    static class DNonDecreasing {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            out.println(2 * n - 1);

            int max = 0;
            int index = 0;
            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                if (Math.abs(max) < Math.abs(a)) {
                    max = a;
                    index = i;
                }
            }
            for (int i = 0; i < n; i++) {
                out.print(index + 1);
                out.print(' ');
                out.println(i + 1);
            }

            if (max < 0) {
                for (int i = n; i > 1; i--) {
                    out.print(i);
                    out.print(' ');
                    out.println(i - 1);
                }
            } else {
                for (int i = 1; i < n; i++) {
                    out.print(i);
                    out.print(' ');
                    out.println(i + 1);
                }
            }
        }

    }
}



Measured memory_bytes: 24916
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 100000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;
const int MAXN = 201+5;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int n;
	cin >> n;
	std::vector<int> a(n);
	std::vector<int> b(n);
	for(int i=0; i<n; i++)cin >> a[i];
	for(int i=0; i<n; i++)cin >> b[i];
	if(a == b){
		cout << 0 << "\n";
		return 0;
	}
	if(a>b)swap(a,b);
	int cnt = 0;
	while(a<b){
		next_permutation(a.begin(),a.end());
		cnt++;
	}
	cout << cnt << "\n";
    return 0;
}




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

int main(void)
{
  std::string s;
  std::cin >> s;

  std::list<int> ans;

  int cnt = 0;
  while (cnt < s.size()) {
    if (s[cnt] == '0') {
      ans.push_back(0);
    }
    else if (s[cnt] == '1') {
      ans.push_back(1);
    }
    else {
      if (!ans.empty()) {
        ans.pop_back();
      }
    }
    cnt++;
  }

  while (!ans.empty()) {
    std::cout << ans.front();
    ans.pop_front();
  }
  std::cout << std::endl;

  return 0;
}

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

using namespace std;

int n;

char str[50];

map<pair<string, string>, int> ss; 

int main()
{
	scanf("%d", &n);
	scanf("%s", str);
	for (int i = 0; i < (1 << n); ++i)
	{
		string s, t;
		s.clear(), t.clear();
		for (int j = 0; j < n; ++j)
			if (i & (1 << j))
				s.push_back(str[j]);
			else
				t.push_back(str[j]);
		++ss[make_pair(s, t)];
	}
	long long ans = 0;
	for (int i = 0; i < (1 << n); ++i)
	{
		string s, t;
		s.clear(), t.clear();
		for (int j = 0; j < n; ++j)
			if (i & (1 << j))
				s.push_back(str[(n << 1) - 1 - j]);
			else
				t.push_back(str[(n << 1) - 1 - j]);
		ans += ss[make_pair(s, t)];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 91904
let change n m d =
  let dp = Array.make (n + 1) max_int in
  dp.(0) <- 0;
  for i = 0 to m - 1 do
    for x = 0 to n - d.(i) do
      let v = x + d.(i) in
      if dp.(x) + 1 < dp.(v) then dp.(v) <- dp.(x) + 1;
    done
  done;
  dp.(n)

let () =
  let (n, m) = Scanf.scanf "%d %d " (fun n m -> (n, m)) in
  let d = Array.init m (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  change n m d |> Printf.printf "%d\n"

Measured memory_bytes: 2812
/* Ashish Joshi
   NIT Hamirpur */

#include<bits/stdc++.h>
using namespace std;
#define ll long long
void test(){
	ll a,b,c,d;cin>>a>>b>>c>>d;
	cout<<max({a*c,b*d,a*d,b*c});
}

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

    int t=1;
    //cin>>t;
    for(int tc=1;tc<=t;tc++){
    	// cout<<"Case #"<<tc<<": ";
    	cout<<fixed<<setprecision(15);
    	test();
    }
}

Measured memory_bytes: 3652
from decimal import Decimal
a,b,c = map(int,input().split())
a = a ** Decimal("0.5")
b = b ** Decimal("0.5")
c = c ** Decimal("0.5")
a_b = Decimal(a) + Decimal(b)
#print(a,b,c,a_b)
if c > a_b:
    print("Yes")
else:
    print("No")


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

int main() {
long long int N;
  cin >> N;
  vector<long long int> H(N+3,1000000000);
      rep (i, N)
    cin >> H.at(i);
  rep(i,N){
  if(H.at(i) - H.at(i+1) >= 2){
    cout << "No" << endl;
    return 0;
  }
    if(H.at(i) - H.at(i+1)==1 && H.at(i+1) - H.at(i+2)==1){
        cout << "No" << endl;
    return 0;
    }
    if(H.at(i) - H.at(i+1)==1 && H.at(i+1) - H.at(i+2)==0){
    rep2(j, i+1, N){
    if(H.at(j) - H.at(j+1) < 0 )
      break;
     else if(H.at(j) - H.at(j+1) == 1){
              cout << "No" << endl;
    return 0;
      }
    }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <time.h>
#include <algorithm>
using namespace std;
#define INF 2147483647


/********************************* Main *********************************/
int main() {
	ios_base::sync_with_stdio(false);

	int n, k; cin >> n >> k; 
	int a[100000]; 
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i]; 
		if (a[i] >= k) {
			cnt += 1; 
		}
	}
	cout << cnt << "\n"; 

	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

int main() {
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			cout << i << 'x' << j << '=' << i * j << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

int main()
{

    string s;
    cin >> s;

    ll n = s.size() - 1;

    if (s[n] == 's')
    {
        s += "es";
    }
    else
    {
        s += "s";
    }

    cout << s << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int N = (int)1e5+5;

long long int arr[N];
int main()
{
    int t,a,b,n,i,j=0,m1,m2,d1,d2;
  cin>>n;
  m1=n/100;
   m2=5*m1+m1*100;

  if(m2>=n)
  {
       cout<<"1"<<endl;
  }

  else
  {
       cout<<"0"<<endl;

  }


    return 0;
}



Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd);
#endif

struct Node{
    int x;
    vector<Node*> dests;
    void add(Node* n){
        dests.push_back(n);
    }
    void add2(Node* n){
        add(n);
        n->add(this);
    }
    pair<int, int> dfs(){
        prints(x);
        vector<pair<int, int>> ps;
        for(Node* d : dests){
            ps.push_back(d -> dfs());
        }
        int c = dests.size(), sum = 0;
        // vector<vector<int>> dp(c, vector<int> (x + 1));
        vector<int> dp(x + 1);
        dp[0] = 1;
        for(int i = 0; i < c; i++){
            sum += ps[i].first + ps[i].second;
            vector<int> next(x + 1);
            for(int j = 0; j <= x; j++){
                if(dp[j]){
                    // next[j] = 1;
                    if(j + ps[i].first <= x){ next[j + ps[i].first] = 1; }
                    if(j + ps[i].second <= x){ next[j + ps[i].second] = 1; }
                }
            }
            dp.swap(next);
        }
        for(int i = x; i >= 0; i--){
            if(dp[i]){
                printd(i, x, sum - i);
                return {x, sum - i};
            }
        }
        cout << "IMPOSSIBLE" << '\n';
        exit(0);
        // return {x, 
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<Node> nodes(n);
    for(int i = 1; i < n; i++){
        int p; cin >> p;
        p--;
        // nodes[i].add(&nodes[p]);
        nodes[p].add(&nodes[i]);
    }
    for(int i = 0; i < n; i++){
        cin >> nodes[i].x;
    }
    nodes[0].dfs();
    // cout << (nodes[0].dfs() ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
    cout << "POSSIBLE" << '\n';
    return 0;
}


Measured memory_bytes: 384