akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>	
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define forit(st) for(set<int> :: iterator it = st.begin(); it != st.end(); ++it)
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
using namespace std;
typedef long long ll;
typedef long double ld;
const double PI = acos(-1.0);
const int inf = int(2e9);
const int _inf = -inf;
const int mod = inf + 7;
const int N = 100100;
using namespace std;
int num[10];
void solve()
{
	
	long double a, b, t;
	cin >> a >> b >> t;
	int cnt = 0;
	for(int i = 0; i <= t + 0.5; i += a){
		cnt++;
	}
	cout << (cnt - 1) * b;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  int N; cin >> N;
  string S; cin >> S;
  int cnt1=0,cnt2=0;
  rep(i,N){
    char c=S[i];
    if(c==')') cnt1++;
    if(c=='(') cnt2++;
    if(c==')' && cnt2!=0){
      cnt1--;
      cnt2--;
    }
  }
  string s1="",s2="";
  rep(i,cnt1) s1+='(';
  rep(i,cnt2) s2+=')';
  cout << s1+S+s2 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

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

		int n = Integer.parseInt(scan.next());

		int counter = 0;
		int min = Integer.MAX_VALUE;
		ArrayList<Integer> pi = new ArrayList<Integer>();
		for(int i=0; i<n; ++i) {
			int numPi = Integer.parseInt(scan.next());
			// 初回はインクリメントonly
			if(i==0) {
				counter++;
			} else {
				if(numPi <= min) {
					counter++;
				}
			}
			if(min > numPi) {
				min = numPi;
			}

//			pi.add(numPi);
//			boolean clear = true;
//			for(int j=0; j<i; ++j) {
//				// 満たさない物があったため、falseにしてbreak
//				if(numPi > pi.get(j)) {
//					clear = false;
//					break;
//				}
//			}
//			// 条件を満たした場合はインクリメント
//			if(clear) {
//				++counter;
//			}
		}
		System.out.println(counter);
	}

}


Measured memory_bytes: 50588
#include<stdio.h>
#include<utility>
#include<queue>
#include<vector>
#include<algorithm>
#define INF 10000000
using namespace std;
void solve();
typedef pair<int,int> pii;
typedef pair<int,pii > pipii;

int N,M,K,ANS = 0;
int G[3010][3010] = {0};
int D[3010];
priority_queue<pipii,vector<pipii>,greater<pipii> > que;

int main()
{
    scanf("%d%d%d",&N,&M,&K);
    for(int i = 1 ; i < N + 1; i++)D[i] = INF;
    for(int i = 0; i < M; i++)
    {
        int a,b,l;
        scanf("%d%d%d",&a,&b,&l);
        G[a][b] = G[b][a] = l;
    }
    for(int i = 0 ; i < K; i++)
    {
        int a;
        scanf("%d",&a);
        for(int j = 1; j < N + 1; j++)
        {
            if(G[a][j] != 0)
            {
                D[a] = 0;
                pipii test;
                test.first = G[a][j];test.second.first = a;test.second.second = j;
                que.push(test);
            }
        }
    }
    solve();
    printf("%d\n",ANS);
    return 0;
}
void solve()
{
    while(que.size())
    {
        pipii now = que.top();
        que.pop();
        if(D[now.second.second] == INF)
        {
            D[now.second.second] = now.first;
            ANS = max(ANS,now.first);
            for(int i = 1; i < N + 1; i++)
            {
                if(G[now.second.second][i] != 0 && i != now.second.first && i != now.second.second)
                {
                    pipii test;
                    test.first = now.first + G[now.second.second][i];
                    test.second.first = now.second.second;
                    test.second.second = i;
                    que.push(test);
                }
            }
        }
        else
        {
            ANS = max(ANS,(int)((double)(now.first + D[now.second.second]) / 2 + 0.5));
        }
    }
    return;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    map<ll, ll> M;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(!M.count(A[i])) M[A[i]] = 1;
        else M[A[i]]++;
    }
    ll Max = 0, preMax = 0;
    for(auto p: M) {
        if(p.second >= 4) {
            if(p.first > Max) {
                preMax = p.first;
                Max = p.first;
            }
            else if(p.first > preMax) {
                preMax = p.first;
            }
        }
        else if(p.second >= 2) {
            if(p.first > Max) {
                preMax = Max;
                Max = p.first;
            }
            else if(p.first > preMax) {
                preMax = p.first;
            }
        }
    }
    ll ans = Max * preMax;
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
int main()
{
 int n,k;
 cin>>n>>k;
 int arr[n];
 for(int i=0;i<n;i++) cin>>arr[i];
 sort(arr,arr+n);
 int sum=0;
 for(int i=0;i<k;i++)
 {
     sum+=arr[i];
 }
 cout<<sum<<endl;
   return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int n,k,r[105]={0},c1,c2,ans=0;
int main(){
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		cin>>c1;
		for(int j=1;j<=c1;j++){
			cin>>c2;
			r[c2]=1;
		}
	}
	for(int i=1;i<=n;i++){
		if(r[i]==0){
			ans++;
		}
	}
	cout<<ans;
}

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

using namespace std;

int x, y, ans;

int main()
{
  	ios::sync_with_stdio(false);
  	cin.tie(NULL);
  	
  	cin >> x >> y;
  	
  	ans = 21e8;
  
  	if(x <= y) ans = min(ans, y - x);
  	if(-x <= y) ans = min(ans, y + x + 1);
  	if(x <= -y) ans = min(ans, -y - x + 1);
  	if(-x <= -y) ans = min(ans, -y + x + 2);
  	
  	cout << ans << endl;
  	
  	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

const double pi = 3.141592653589793;
// -------------------------------------------------------
ll N, M;

int main() {
  cin >> N >> M;
  if (N == 1 && M == 1) {
    cout << 1 << endl;
    return 0;
  }

  if (N == 1) {
    cout << M - 2 << endl;
    return 0;
  }

  if (M == 1) {
    cout << N - 2 << endl;
    return 0;
  }

  cout << (N - 2) * (M - 2) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if (a==b) {
		cout<<"Draw"<<endl;
	} else if (a==1) {
		cout<<"Alice"<<endl;
	} else if (b==1) {
		cout<<"Bob"<<endl;
	} else if (a>b) {
		cout<<"Alice"<<endl;
	} else {
		cout<<"Bob"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        int a = Int32.Parse(Console.ReadLine());
        ulong h = 1;
        for (int s = 1; s <= a; s++) { h = h * (ulong)s % 1000000007; }
        Console.WriteLine(h);
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	ios_base :: sync_with_stdio(false);
	int n, m, x;
	cin >> n >> m >> x;
	vector < int > c(n, 0);
	vector < vector < int > > a(n, vector < int >(m, 0));
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	int ans = -1;
	for (int mask = 0; mask < (1 << n); mask++) {
		vector < int > b(m, 0);
		int cs = 0;
		for (int i = 0; i < n; i++) {
			if ((mask >> i) & 1) {
				cs += c[i];
				for (int j = 0; j < m; j++) {
					b[j] += a[i][j];
				}
			}
		}
		bool ok = true;
		for (int j = 0; j < m; j++) {
			if (b[j] < x)
				ok = false;
		}
		if (ok) {
			if (ans == -1)
				ans = cs;
			ans = min(ans, cs);
		}
	}
	cout << ans;
	return 0;
}

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

int main() {
	long long a;
	string b;
	cin >> a >> b;
	
	long long mul = 0;
	for (const char &c : b) {
		if (c == '.') continue;
		const int d = (c - '0');
		mul = mul * 10LL + d;
	}
	
	long long ans = a * mul;
	ans /= 100;
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main()
{
    int S;
    int h;
    int m;
    int s;
    int a;
    cin>>S;
    if(S>=0&&S<=86400)
    {
        h=S/3600;
        a=S%3600;
        m=a/60;
        s=a%60;
    }
    cout<<h<<":"<<m<<":"<<s<<endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

// union by size + path having
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> p(n);
    vector<P> a(m);
    rep(i, n) {cin >> p[i];}
    rep(i, m){ cin >> a[i].first >> a[i].second;}

    UnionFind uni(n+1);
    rep(i, m){
        int id = i+1;
        uni.unite(a[i].first,a[i].second);
    }
    int ans = 0;
    rep(i,n){
        int id = i+1;
        if(uni.same(p[i], id)) ans++;
    }
    cout << ans << endl;

}



Measured memory_bytes: 1792
A, B, C, X, Y = map(int, input().split())

ans = 100000000000
if X > Y:
    for n_a in range(X+1):
        n_c = 2 * (X - n_a)
        n_b = Y - (n_c // 2)
        if n_b < 0:
            n_b = 0
        temp = A * n_a + B * n_b + C * n_c
        if ans > temp:
            ans = temp
    print(ans)
    exit()
else:
    for n_b in range(Y+1):
        n_c = 2 * (Y - n_b)
        n_a = X - n_c // 2
        if n_a < 0:
            n_a = 0
        temp = A * n_a + B * n_b + C * n_c
        if ans > temp:
            ans = temp
    print(ans)
    exit()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  string s, t; cin >> s >> t;
  if (s == t.substr(0, s.size())) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
N, Y = map(int, input().split() )
for yukichi in range(N+1,-1, -1):
  for higuchi in range(N-yukichi+1,-1, -1):
    zansa = Y - (10000*yukichi+5000*higuchi)
    if (zansa%1000 == 0) and 0<=zansa//1000==(N-yukichi-higuchi):
      print(yukichi, higuchi, zansa//1000)
      break
  else:
    continue
  break
else:
  print(-1, -1, -1)

Measured memory_bytes: 3064
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>


#define EPSILON 1e-9


class vector_t {
public:
  double x;
  double y;
  double z;

public:
  vector_t(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {};

public:
  double operator*(const vector_t& v) const {
    return x * v.x + y * v.y + z * v.z;
  };

  vector_t operator^(const vector_t& v) const {
    return vector_t(y * v.z - z * v.y,
                    z * v.x - x * v.z,
                    x * v.y - y * v.x);
  };

public:
  double length() const {
    return sqrt(*this * *this);
  };
};


class point_t {
public:
  double x;
  double y;
  double z;
  double w;

public:
  point_t(double x = 0, double y = 0, double z = 0, double w = 1) : x(x), y(y), z(z), w(w) {};
  
public:
  vector_t operator-(const point_t& p) const {
    return vector_t(x - p.x, y - p.y, z - p.z);
  };
};


class point_circle_intersect : public std::unary_function<point_t, bool>
{
public:
  point_circle_intersect(const point_t& o, double r) : o_(o), rr_(r * r + EPSILON) {};

public:
  bool operator()(const point_t& p) const {
    vector_t v(p - o_);

    return v * v < rr_;
  };

private:
  point_t o_;
  
  double rr_;
};


class segment_circle_intersect : public std::binary_function<point_t, point_t, bool>
{
public:
  segment_circle_intersect(const point_t& o, double r) : o_(o), rr_(r * r)
  {
  };

public:
  bool operator()(const point_t& p1, const point_t& p2) {
    vector_t p(p1 - o_), v(p2 - p1);

    double a = v * v;
    double b = v * p;
    double c = p * p - rr_;

    double d = b * b - a * c;

    if (d < 0)
      return false;
    
    d = sqrt(d);

    double t1 = (- b + d) / a;
    double t2 = (- b - d) / a;

    return ! (std::max(t1, t2) < -EPSILON || 1 + EPSILON < std::min(t1, t2));
  };

private:
  point_t o_;

  double rr_;
};


int main(int argc, char** argv)
{
  while (1) {
    int n, m;

    std::cin >> n;

    if (n == 0)
      break;
    
    std::vector<point_t> ws(n);
    std::vector<double>  rs(n);

    for (int i = 0; i < n; i ++)
      std::cin >> ws[i].x >> ws[i].y >> rs[i];

    std::cin >> m;

    for (int j = 0; j < m; j ++) {
      point_t t, s;

      std::cin >> t.x >> t.y >> s.x >> s.y;

      bool safe = false;

      for (int i = 0; i < n; i ++) {
        point_circle_intersect fn(ws[i], rs[i]);

        if (fn(t) && fn(s)) {
          ;
        }
        else if ((safe = segment_circle_intersect(ws[i], rs[i])(t, s))) {
          break;
        }
      }

      std::cout << (safe ? "Safe" : "Danger") << std::endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

int main(){
    string s,t;
    cin >> s >> t;
    int ans=0;
    rep(i,3){
        if (s.at(i)==t.at(i)) ans++;
    }
    cout << ans << endl;
}


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

int main(){
  string S;
  cin >> S;
  char befchar = S[0];
  int count = 0;
  for (int i=1; i<S.size(); i++){
    if (S[i] != befchar){
      count++;
      befchar = S[i];
    }
  }
  cout << count << endl;
}


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

using namespace std;

long long p5(long long b){
	return b*b*b*b*b;
}

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	long long x;
	cin>>x;
	map <long long,int> mm;
	long long i=0;
	while(true){
		long long k = p5(i);
		if(k>x)break;
		if(mm.count(x-k)>0){
			cout<<mm[x-k]<<' '<<-i<<endl;
			return 0;
		}
		mm[k]  =i;
		i++;
	}
	for(long long x1 = 1;x1<=500;x1++){
		long long y  =1;
		long long b = p5(x1);
		while(p5(x1+y)-b<x)y++;
		if(p5(x1+y)-b==x){
			cout<<(x1+y)<<' '<<x1<<endl;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3196
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;
	vector<int> a( n );
	for( int i = 0; i < n; ++i ) { cin >> a[i]; }
	int q;
	cin >> q;
	while( q-- ) {
		int b, e, k;
		cin >> b >> e >> k;
		cout << count( a.begin()+b, a.begin()+e, k ) << '\n';
	}

	return 0;
}



Measured memory_bytes: 3212
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		DjSet djs = new DjSet(n);

		int q = scan.nextInt();
		for (int i = 0; i < q; i++)
			switch (scan.nextInt()) {
			case (0):
				djs.union(scan.nextInt(), scan.nextInt());
				break;
			case (1):
				if (djs.isSame(scan.nextInt(), scan.nextInt()))
					System.out.println("1");
				else
					System.out.println("0");
			}

		scan.close();
		System.exit(0);
	}
}

class DjSet {
	int[] parent;
	int[] height;

	public DjSet(int n) {
		parent = new int[n];
		height = new int[n];
		for (int i = 0; i < n; i++)
			parent[i] = i;
	}

	public boolean isSame(int s1, int s2) {
		if (findSet(s1) == findSet(s2))
			return true;
		else
			return false;
	}

	public void union(int u1, int u2) {
		int p1 = findSet(u1);
		int p2 = findSet(u2);
		if (p1 == p2)
			return;
		if (height[p1] > height[p2])
			parent[p2] = p1;
		else if (height[p1] == height[p2]) {
			height[p1]++;
			parent[p2] = p1;
		} else
			parent[p1] = p2;
	}

	private int findSet(int id) {
		if (parent[id] != id)
			parent[id] = findSet(parent[id]);
		return parent[id];
	}
}

Measured memory_bytes: 102940
fun main(args:Array<String>) {
    val line = readLine()!!.split(" ").map { it.toInt() }
    val n = line[0]
    val k = line[1]
    val l = readLine()!!
    var result = 0
    var b = 0
    var before = 'x'
    for(i in 0..n-1){
        if(before == l[i]){
            result++
        }else{
            b++
        }
        before = l[i]
    }
    if(b%2==1){
        val x = (b-1)/2
        result += 2 * if(x>k)k else x
    }else{
        val x = b/2
        if(x<=k){
            result+= 2*x - 1
        }else{
            result += 2*k
        }
    }
    println(result)
}

Measured memory_bytes: 38148
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  string s;
  cin >> s;
  bool heisei;
  if (s.substr(0, 4) != "2019") {
    heisei = s.substr(0, 4) < "2019";
  } else {
    heisei = s.substr(5, 2) <= "04";
  }
  cout << (heisei ? "Heisei" : "TBD") << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n)
	fmt.Scan(&m)

	var lma, rmin int

	rmin = 9999999999999

	for index := 0; index < m; index++ {
		var l, r int
		fmt.Scan(&l)
		fmt.Scan(&r)

		if lma < l {
			lma = l
		}
		if rmin > r {
			rmin = r
		}
	}

	var re int

	for index := 1; index <= n; index++ {
		if lma <= index && rmin >= index {
			re++
		}
	}

	fmt.Println(re)
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
static const int INF=100000;
using namespace std;
int d[50][50];
typedef pair<int, int> P;

int H,W;
char s[51][51];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void bfs(){
    queue<P> q;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            d[i][j]=INF;
        }
    }
    q.push(P(0,0));
    d[0][0]=1;
    while(!q.empty()){
        P u=q.front();q.pop();
        for(int i=0;i<4;i++){
            s[u.first][u.second]=0;
            int nx=u.first+dx[i];
            int ny=u.second+dy[i];
            if(0<=nx&&nx<H&&0<=ny&&ny<W
                &&s[nx][ny]=='.'&&d[nx][ny]==INF){
                q.push(P(nx,ny));
                d[nx][ny]=d[u.first][u.second]+1;
            }
        }    
    }                            
}
int main(){
    scanf("%d %d",&H,&W);
    char c;
    int cunt2=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>c;
            if(c=='#')cunt2++;
            s[i][j]=c;
        }    
    }
    bfs();
    if(d[H-1][W-1]==INF){
        cout<<-1<<"\n";
        return 0;
    }
    int ans=H*W-d[H-1][W-1]-cunt2;;
    cout<< ans<<"\n"; 
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define rp(i,n) for(long long i=1;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000000007;
vel rui(19, 1);
vel par;
int root(int ser) {
	if (par[ser] == -1) { return ser; }
	int ans = root(par[ser]);
	par[ser] = ans;
	return ans;
}
bool marge(pin a) {
	int x = root(a.first);
	int y = root(a.second);
	if (x != y) {par[x] = y;}
	return x != y;
}
signed main() {
	int n; cin >> n;
	vel a(n);
	rep(i, n) { cin >> a[i]; }
	a.push_back(0);
	vel sz(0);
	int ba = a[0];
	int ko = 0;
	rep(i, n + 1) {
		if (ba == a[i]) { ko++; }
		else { sz.push_back(ko); ko = 1; ba = a[i]; }
	}
	int ans = 0;
	rep(i, sz.size()) {
		int ze = 0;
		ans += sz[i]/2;
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define mod 1000000007
#define ALL(v) (v).begin(),(v).end()
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
typedef long long ll;

template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }

int a,b,c;
ll n,m;
main()
{
        cin>>n>>m;
        if(n==1&&m==1)cout<<1<<endl;
        else if(n==1||m==1)cout<<n+m-3<<endl;
        else cout<<(n-2)*(m-2)<<endl;
}

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

const int nm = 1e5, mod = 1e9 + 7;
int n, c[nm + 1];
long long ans = 1;

int main() {
	c[0] = 3;
	cin >> n;
	for (int i = 0, a; i < n; i++) {
		cin >> a;
		ans = ans * c[a] % mod;
		c[a]--, c[a + 1]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
import collections
N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
Q = int(input())
ans = sum(A)
for q in range(Q):
  B, C = map(int, input().split())
  count = c[B]
  c[B] -= count
  c[C] += count
  ans += (C-B)*count
  print(ans)



Measured memory_bytes: 24324
/**
*    created: 23.06.2020 23:17:01
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#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++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

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

    int n;
    cin >> n;
    if (n == 1) cout << "Hello World" << endl;
    else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N,P; cin >> N >> P;
	vector<int> A(N);
	rep(i,N){
		cin >> A[i];
		A[i] %= 2;
	}
	int cnt0 = 0;
	int cnt1 = 0;
	rep(i,N){
		if(A[i] == 0) cnt0++;
		else cnt1++;
	}
	ll ans0 = pow(2,cnt0)*(max((ll)(pow(2,cnt1)+1)/2,1LL));
	ll ans1 = pow(2,N) - ans0;
	cout << (P ? ans1 : ans0) << endl;
}


Measured memory_bytes: 256
var
        v,s,a,l,i:longint;
begin
        readln(s,a);
        l:=a;
        repeat
            l:=l div 10;
            inc(v);
        until l=0;
        for i:=1 to v do
            s:=s*10;
        s:=s+a;
        if sqr(trunc(sqrt(s)))=s then writeln('Yes')
        else writeln('No');
end.

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

//#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i) = 0; (i) <= (n); (i)++)
using namespace std;

int N;
int bit[40010];
void add(int a, int w) {
	for (int x = a; x <= N; x += x & -x) bit[x] += w;
}
int sum(int a) {
	int ret = 0;
	for (int x = a; x > 0; x -= x & -x) ret += bit[x];
	return ret;
}

int A[40000];
int B[40000];
int C[40000];

typedef struct St
{
	int index;
	double val;
	bool  operator <(const St& p)
	{
		return val < p.val;
	}
};

vector<St> vx;
vector<St> vy;

int count_x(double pos)
{
	vector<St> v;

	for (int i = 0; i < N; i++)
	{
		St st;
		st.index = i;
		int a = vx[i].index;
		st.val =  - A[a] / (double)B[a] * pos + C[a] / (double)B[a];
		v.push_back(st);
	}
	RSORT(v);

	memset(bit, 0, sizeof(bit));
	int s = 0;
	for (int i = N - 1; i >= 0; i--)
	{
		add(v[i].index + 1, 1);
		s += sum(v[i].index);
	}
	return s;
}

int count_y(double pos)
{
	vector<St> v;

	for (int i = 0; i < N; i++)
	{
		St st;
		st.index = i;
		int a = vy[i].index;
		st.val = -B[a] / (double)A[a] * pos + C[a] / (double)A[a];
		v.push_back(st);
	}
	RSORT(v);

	memset(bit, 0, sizeof(bit));
	int s = 0;
	for (int i = N - 1; i >= 0; i--)
	{
		add(v[i].index + 1, 1);
		s += sum(v[i].index);
	}
	return s;
}


signed main()
{
	cin >> N;
	REP(i, N) cin >> A[i] >> B[i] >> C[i];

	for (int i = 0; i < N; i++)
	{
		St stx;
		stx.index = i;
		stx.val = -A[i] / (double)B[i];
		vx.push_back(stx);

		St sty;
		sty.index = i;
		sty.val = -B[i] / (double)A[i];
		vy.push_back(sty);
	}
	SORT(vx);
	SORT(vy);

	int all = (N * (N - 1) / 2);
	int target = all / 2;
	if (all % 2 == 0) target--;

	double x, y;

	double max_k = 10000000000;
	double min_k = -10000000000;
	for (int i = 0; i < 100; i++)
	{
		double k = (max_k + min_k) / 2;
		int c = count_x(k);

		if (c > target)
		{
			max_k = k;
		}
		else
		{
			min_k = k;
		}
	}

	x = min_k;

	max_k = 10000000000;
	min_k = -10000000000;
	for (int i = 0; i < 100; i++)
	{
		double k = (max_k + min_k) / 2;
		int c = count_y(k);

		if (c > target)
		{
			max_k = k;
		}
		else
		{
			min_k = k;
		}
	}

	y = min_k;

	cout << fixed << setprecision(10);
	cout << x << " " << y << endl;
}

Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  string ans;
  if (s.size() <= k) cout << s << endl;
  else {
    rep(i, k){
      ans.push_back(s[i]);
    }
    rep(i, 3) ans.push_back('.');
    // ans.push_back("...");
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3584
#include<stdio.h>

int main()
{
  int n,y;
  
  scanf("%d%d",&n,&y);
  
  int i,j,k;
  
  for(i=0;i<=n;i++)
  {
    for(j=0;j<=n;j++)
    {
      k=n-i-j;
      if(10000*i+5000*j+1000*k==y)
      {
        if(k>=0)
        {
        printf("%d %d %d\n",i,j,n-i-j);
        return 0;
        }
      }
    }
  }
  
  printf("-1 -1 -1\n");
  
  return 0;
}

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

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

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  char a,b;cin>>a>>b;
  a=='H' ? flagfunc(b=='H',"H","D") : flagfunc(b=='D',"H","D");
}


Measured memory_bytes: 256
import sys
s=input()
a=int(s[0]);b=int(s[1]);c=int(s[2]);d=int(s[3])
if a+b+c+d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a+b+c-d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a+b-c+d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a+b-c-d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a-b+c+d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a-b+c-d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a-b-c+d==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a-b-c-d==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
  sys.exit()


Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int a[] = new int[10000];
		int b[] = new int[10000];
		for(int i = 1; i <= n*(n-1)/2; i++){
			for(int h = 1; h <= 4; h++){
				b[h] = in.nextInt();
			}
			if(b[3] > b[4]){
				a[b[1]] += 3;
			}else if(b[3] < b[4]){
				a[b[2]] += 3;
			}else if(b[3] == b[4]){
				a[b[1]] += 1;
				a[b[2]] += 1;
			}
		}
		for(int j = 1; j <= n; j++){
			int an = n;
			for(int k = 1; k <= n; k++){
				if(j == k){
					continue;
				}else if(a[j] >= a[k]){
					an--;
				}
			}
			System.out.println(an);
		}
	}

}

Measured memory_bytes: 43664
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 10;

string n;
int dp[MAX_N][10][8][2];

void dpSub(int i, int k, int eq, int num, int pow)
{
	if (eq == 1)
	{
		if (n[i] == num)
			dp[i + 1][num][k | pow][1] += dp[i][0][k][eq] + dp[i][3][k][eq] + dp[i][5][k][eq] + dp[i][7][k][eq];
		else if (num < n[i])
			dp[i + 1][num][k | pow][0] += dp[i][0][k][eq] + dp[i][3][k][eq] + dp[i][5][k][eq] + dp[i][7][k][eq];
	}
	else
		dp[i + 1][num][k | pow][0] += dp[i][0][k][eq] + dp[i][3][k][eq] + dp[i][5][k][eq] + dp[i][7][k][eq];
}
int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < (int)n.length(); i++)
		n[i] -= '0';

	for (int i = 0; i < (int)n.length(); i++)
		dp[i][0][0][i == 0 ? 1 : 0] = 1;
	for (int i = 0; i < (int)n.length(); i++)
		for (int k = 0; k < 8; k++)
			for (int eq = 0; eq < 2; eq++)
			{
				dpSub(i, k, eq, 3, 1);
				dpSub(i, k, eq, 5, 2);
				dpSub(i, k, eq, 7, 4);
			}

	int result = dp[n.length()][3][7][0] + dp[n.length()][5][7][0] + dp[n.length()][7][7][0] + dp[n.length()][3][7][1] + dp[n.length()][5][7][1] + dp[n.length()][7][7][1];
	cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int P[N];

    for (int i = 0; i < N; i++) {
        cin >> P[i];
        P[i]++;
    }

    int ans, sum = 0;

    for (int i = 0; i < K; i++) {
        sum += P[i];
    }

    ans = sum;

    for (int i = K; i < N; i++) {
        sum = sum - P[i - K] + P[i];
        ans = max(ans, sum);
    }

    cout << fixed << ans / 2.0 << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

#define INPUT_LIM ( 1000000 )

/** Application main entry point. */
int main (
  int argc,
  char *argv[ ]
  )
{
  int table[ INPUT_LIM ] = { 0 };
  int n;
  int i, j;

  for ( j = 2; j < INPUT_LIM; ++j )
  {
    if ( table[ j ] ) continue;

    for ( i = j << 1; i < INPUT_LIM; i += j )
    {
      table[ i ] = 1;
    }
  }

  while ( scanf ( "%d", &n ) == 1 )
  {
    int res = n - 1;
    
    for ( i = 2; i <= n; ++i )
    {
      res -= table[ i ];
    }
    printf ( "%d\n", res );
  }

  return ( 0 );
}

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

int main(){
  int n,d;
  cin >> n >> d;
  cout << (n + (d*2+1) - 1) / (d*2+1) << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;

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

	P lis[100000];

	for (int i = 0; i < M; i++) {
		int a, b; cin >> a >> b;
		lis[i] = P(b, a);
	}

	sort(lis, lis+M);

	int ans = 0, now = -1;

	for (int i = 0; i < M; i++) {
		if (lis[i].second >= now) {
			now = lis[i].first;
			ans++;
		}
	}

	cout << ans << endl;
}

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

namespace MyProgram{
    class AtCoder{
        static void Main(){
            int N = int.Parse(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            int min = 1000000000;
            for(var i=a.Min();i<=a.Max();i++){
                int sum=0;
                int st = i;
                for(var j=0;j<N;j++){
                    sum += (a[j] -st)*(a[j]-st);
                }
                min = Math.Min(sum,min);
            }
            Console.WriteLine(min);
        }
    } 
}

Measured memory_bytes: 13268
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

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

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let (n, l): (isize, isize);
    let mut v = vec![];
    input!(n, l);
    for i in 0..n {
        v.push(i + l);
    }
    v.sort_by(|x, y| x.abs().cmp(&y.abs()));
    println!("{}", v.iter().skip(1).sum::<isize>());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  vector<ll> As(3);
  cin >> As[0] >> As[1] >> As[2];
  sort(As.begin(), As.end());
  cout << (As[1] - As[0] + As[2] - As[1]) << 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;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }
ll MOD = 1000000007;

int main(void){
  int n,m; cin >> n >> m;
  vector<int> prc(m,0);
  rep(i,n){
    int k; cin >> k;
    rep(j,k){
      int a; cin >> a;
      a--;
      prc.at(a)++;
    }
  }
  int ans = 0;
  rep(i,m){
    if(prc.at(i) == n) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class H> void rsz(V<T> &v, H h) { v.resize(h); }
template<class T, class H, class... R> void rsz(V<T> &v, H h, R... r) { v.resize(h); for (auto&& i : v) rsz(i, r...); }
using P = pair<int, int>;
const lint mod = 1e9 + 7;
lint emod(lint a) { return (a % mod + mod) % mod; }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<P> a(2 * n);
  for (int i = 0; i < 2 * n; i++) {
    int x; cin >> x;
    a[i] = P(x, i / n);
  }
  sort(a.begin(), a.end());
  lint res = 1;
  int t = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (a[i].second == 1) {
      if (t < 0) res = res * -t % mod;
      t++;
    } else {
      if (t > 0) res = res * t % mod;
      t--;
    }
  }
  cout << emod(res) << '\n';
}

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

using namespace std;

int main()
{
    int a,a2,a3,ans;
    scanf("%d",&a);
    a2=a*a;
    a3=a2*a;
    ans = a+ a2+a3;

    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3820
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
void read (int &x) {
	char ch = getchar(); int f = 0; x = 0;
	while (!isdigit(ch)) { if (ch == '-') f = 1; ch = getchar(); }
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); if (f) x = -x;
} const int N = 2e5 + 10, M = 1e6 + 10;
int n, res, a[N], k[M], c[M];
signed main() {
	read (n);
	for (int i = 1; i <= n; ++i) read (a[i]);
	sort (a + 1, a + n + 1); int num = 1; c[a[1]] = 1;
	for (int i = 2; i <= n; ++i)
		if (a[i] != a[i - 1]) c[a[i]] = 1, a[++num] = a[i];
		else ++c[a[i]];
	for (int i = 1; i <= num; ++i) {
		if (!k[a[i]] && c[a[i]] == 1) ++res;
		for (int j = a[i] + a[i]; j <= 1e6; j += a[i]) k[j] = 1;
	} return printf ("%d\n", res), 0;
}

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

typedef long long ll;
const int N = 100005;
int ar[N][4];
ll dp[N][4];
int n;

long long f(int pos, int work){
	if (pos > n)
		return 0;
	if (dp[pos][work] != -1)
		return dp[pos][work];
	ll x = -1000;
	ll y = x;
	ll z = x;
	if (work == 0){
		x = f(pos + 1, 1) + ar[pos][1];
		y = f(pos + 1, 2) + ar[pos][2];
		z = f(pos + 1, 3) + ar[pos][3];
	}
	if (work == 1){
		x = f(pos + 1, 2) + ar[pos][2];
		y = f(pos + 1, 3) + ar[pos][3];
	}
	if (work == 2){
		x = f(pos + 1, 1) +  ar[pos][1];
		y = f(pos + 1, 3) + ar[pos][3];
	}
	if(work == 3){
		x = f(pos + 1, 1) + ar[pos][1];
		y = f(pos + 1, 2) + ar[pos][2];
	}
	return dp[pos][work] = max(x , max(y, z));
}

int main(){
	cin >> n;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= 3; j++){
			cin >> ar[i][j];
		}
	}
	memset(dp, -1, sizeof(dp));
	cout << f(1, 0) << '\n';
	return 0;
}

Measured memory_bytes: 11136
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int[] d = new int[N];

        for (int i = 0 ; i < N ; i++) {
            d[i] = scanner.nextInt();
        }

        int sum = 0;
        for (int i = 0 ; i < N ; i++) {
            for (int j = i + 1; j < N ; j++) {
                sum += d[i] * d[j];
            }
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 35568
import bisect

A, B, Q = map(int, input().split())
S = [-float('inf')] + [int(input()) for _ in range(A)] + [float('inf')]
T = [-float('inf')] + [int(input()) for _ in range(B)] + [float('inf')]

for _ in range(Q):
    answer = float('inf')
    x = int(input())
    si = bisect.bisect_left(S, x)    
    ti = bisect.bisect_left(T, x)
    for s in [S[si-1], S[si]]:
        for t in [T[ti-1], T[ti]]:
            d1 = abs(s - x) + abs(t - s)
            d2 = abs(t - x) + abs(t - s)
            answer = min(answer, d1, d2)
    print(answer)

Measured memory_bytes: 14220
#include<iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    int d = a / b;
    int r = a % b;
    double f = ((double) a / (double) b) * 100000000;
    cout << d << " "<< r << " " << fixed << f/100000000 << endl;
}


Measured memory_bytes: 3288
package main

import (
	"fmt"
	"os"
)

func run() int {
	var n int
	fmt.Scanf("%d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}

	j := 1
	del := 0
	for i := 0; i < n; i++ {
		if a[i] == j {
			j++
			continue
		}
		del++
	}

	if del == n {
		fmt.Println(-1)
	} else {
		fmt.Println(del)
	}

	return 0
}

func main() {
	os.Exit(run())
}


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

int main() {
  int X,A,B;
  cin>>X>>A>>B;
  if(A>=B){
    cout<<"delicious"<<endl;
  }
  else if(X+A>=B){
    cout<<"safe"<<endl;
  }
  else{
    cout<<"dangerous"<<endl;
  }
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc159/tasks/abc159_e
import sys

ans = sys.maxsize
H, W, K = map(int, input().split())
s = [input() for _ in range(H)]

for h in range(1 << (H - 1)):
    g = 0
    ids = [-1 for _ in range(H)]
    for i in range(H):
        ids[i] = g
        if (h >> i) & 1:
            g += 1

    g += 1
    c = [[0 for _ in range(W)] for _ in range(g)]
    for i in range(H):
        for j in range(W):
            c[ids[i]][j] = c[ids[i]][j] + (s[i][j] == '1')

    num = g - 1
    now = [0 for _ in range(g)]


    def add(j):
        for i in range(g):
            now[i] += c[i][j]

        for i in range(g):
            if now[i] > K:
                return False

        return True

    if num >= ans:
        continue

    for j in range(W):
        if not add(j):
            num += 1
            if num >= ans:
                continue
            now = [0 for _ in range(g)]
            if not add(j):
                num = sys.maxsize
                break

    ans = min(ans, num)

print(ans)


Measured memory_bytes: 3188
h,w,m=map(int,input().split())
a=[0]*h;b=[0]*w
s=set()
for _ in range(m):
  x,y=map(lambda x:int(x)-1,input().split())
  a[x]+=1;b[y]+=1
  s.add(x*10**6+y)
ma=max(a);mb=max(b)
c=[i for i,v in enumerate(a) if v==ma]
d=[i for i,v in enumerate(b) if v==mb]
for x in c:
  for y in d:
    if not(x*10**6+y in s):
      print(ma+mb)
      exit()
print(ma+mb-1)

Measured memory_bytes: 169824