akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3,typename T4> inline void print4(T1 a, T2 b, T3 c, T4 d){
	cout << a << " " << b << " " << c << " " << d << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll a,b,c; cin >> a >> b >> c;
	swap(a,b);
	swap(a,c);
	cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $p = [];
  for ($i=0; $i<$n; $i++) {
    list($p[]) = explode(" ", trim(fgets(STDIN)));
  }


  rsort($p);

  $p[0] = $p[0] / 2;

  $sum = array_sum($p);

  echo $sum;

Measured memory_bytes: 16128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

template <class T>
T gcd(T a, T b) {
  return (b == 0) ? a : gcd(b, a % b);
}

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

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  const auto lcm_ans = accumulate(cbegin(A), cend(A), 1LL, lcm<ll>);
  ll sum = 0;
  for (ll i = 0; i < N; i++) {
    sum += lcm_ans / A[i];
  }
  double ans = (double)lcm_ans / sum;

  printf("%0.6lf\n", ans);

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  long long la,lb,lc,lx;
  double da,db,dc;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> la >> lb >> lc;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------
lx = la;
  la = la - lc;
  if(la < 0) la = 0;
  lc = lc - lx;
  if(lc < 0) lc = 0;
  lb = lb - lc;
  if(lb < 0) lb = 0;
  
  cout << la << " " << lb << endl;

}

Measured memory_bytes: 256
program A320B
    implicit none
    integer(8)::N,ans,i,Ns
    read*,N
    Ns=int(sqrt(real(N)))+1
    ans=N
    do i=1,Ns
        if(mod(N,i)==0)ans=min(ans,i+N/i-2)
    end do

    print'(i0)',ans
end program A320B

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

int main() {
	int D,G,r=INF;
	cin >> D >> G;
	vector<int> p(D),c(D),s(D);

	rep(i,D) {
		cin >> p.at(i) >> c.at(i);
		s.at(i) = p.at(i)*(i+1)*100 + c.at(i);
	}
	
	rep(i,(int)pow(2,D)-1) {
		int tq=0,ts=0,m=-1;
		rep(j,D)
			if(i>>j & 1) {
				tq += p.at(j);
				ts += s.at(j);
			} else
				m = j;

		if(ts >= G) {
			r = min(r,tq);
			continue;
		}

		rep(i,p.at(m)) {
			++tq;
			ts += (m+1)*100;
			if(i == p.at(m)-1)
				ts += c.at(m);
			if(ts >= G) {
				r = min(r,tq);
				break;
			}
		}
	}

	cout << r << endl;
}

Measured memory_bytes: 256
table = dict()
mx = 0

for i in range(int(input())):
    s = input()
    tmp = table.get(s, 0) + 1
    table[s] = tmp
    if mx < tmp: mx = tmp

items = sorted(table.items(), key = lambda x: (-x[1], x[0]))

for item in items:
    if item[1] < mx: break
    print(item[0])


Measured memory_bytes: 59228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<double> a(n);
	rep(i,n) cin >> a.at(i);
	sort(all(a));
	double ans = a.at(0);
	rep(i,n - 1){
		ans = (ans + a.at(i + 1)) / 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


ll n;
#define N 1000
ll ans[N][N];
ll c=1;
bool dfs(vector<ll>v){
    if(v.size()<=1)return 0;
    vector<ll>s,t;
    rep(i,0,v.size()-1){
        if(i%2==0)s.pb(v[i]);
        else t.pb(v[i]);
    }
    for(auto x:s){
        for(auto y:t){
            ans[x][y]=c;ans[y][x]=c;
        }
    }
    c++;
    ll k=c;
    dfs(s);
    c=k;
    dfs(t);
    return 0;
}

int main(){fastio
    cin>>n;
    vector<ll>v;rep(i,0,n-1)v.pb(i);
    dfs(v);
    rep(i,0,n-1){
        rep(j,i+1,n-1){
            cout<<ans[i][j]<<" ";
        }cout<<endl;
    }
    return 0;
}


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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll K, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> K;
    for(int i=0;i<K;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    if(A.back()!=2) {
        cout << -1 << endl;
        return 0;
    }
    A.pop_back();
    ll minv = 2;
    ll maxv = 3;
    while(!A.empty()) {
        tmp = A.back();
        A.pop_back();
        minv = minv+tmp-1;
        minv = minv-minv%tmp;
        maxv = maxv-maxv%tmp;
        //cout << minv << " 1 " << maxv << endl;
        if(minv>maxv) {
            cout << -1 << endl;
            return 0;
        }
        maxv += tmp-1;
        //cout << minv << " 2 " << maxv << endl;
    }
    cout << minv << " " << maxv << endl;
    return 0;
}

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

#define ll long long
#define llong long long
#define REP(i,n) for(auto i=0;i<n;++i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define FOR(i,a,b) for(auto i=a;i<b++i)
#define ALL(v) v.begin(),v.end()
#define pb push_back

using namespace std;

int dx[] = {0,1,1,0,-1,-1};
int dy[] = {1,1,0,-1,-1,0};

int main(){
  while(true){
    int t,n;cin >> t >> n;
    if(t == 0 && n == 0)break;
    vector<vector<int> > m(1024, vector<int>(1024,0));
    int x0 = 512, y0 = 512;
    for(int i = 0; i < n; i++){
      int x,y; cin >>x >> y;
      x += x0; y += y0;
      m[x][y] = -1;
    }
    int sx,sy;cin >> sx >> sy;
    sx += x0; sy += y0;
    queue<pair<int, int> > q;
    q.push(make_pair(sx,sy));
    int ans = 1;
    while(!q.empty()){
      auto now = q.front();
      int turn = m[now.first][now.second];
      if(now == make_pair(sx,sy)){
        m[sx][sy] = -1;
      }
      q.pop();
      for(int i = 0;i < 6; i++){
        int nextx = now.first + dx[i];
        int nexty = now.second + dy[i];
        if(m[nextx][nexty] == 0 && turn < t){
          //if(abs(nextx-x0) > 30 || abs(nexty-y0) > 30)continue;
          q.push(make_pair(nextx,nexty));
          ans++;
          m[nextx][nexty] = turn+1;
        }
      }
    }
    cout << ans << endl;
  }

          

  return 0;
}




Measured memory_bytes: 7120
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] arr = new int[n];
        String[] input = br.readLine().split(" ");
        for(int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(input[i]);
        }
        Arrays.sort(arr);

        int max = arr[n-1];

        int selectValue = Integer.MAX_VALUE;
        int distance = Integer.MAX_VALUE;

        int l;
        if(max % 2 == 0){
            l = max / 2;
        }else{
            l = max / 2 + 1;
        }
        int r = max / 2 + 1;

        for(int i = 0; i < n-1; i++){
            int dist = Math.abs(l-arr[i]);
            if(distance > dist){
                distance = dist;
                selectValue = arr[i];
            }
            dist = Math.abs(r-arr[i]);
            if(distance > dist){
                distance = dist;
                selectValue = arr[i];
            }
        }

        System.out.println(max + " " + selectValue);
    }
}

Measured memory_bytes: 36200
#include<cstdio>
#define Z int
#define V void
#define L long long
#define S(n) scanf("%lld",&n)
#define P(n) printf("%lld",(n+p)%p)
#define F(i,a,b) for(L i=a;i<=b;i++)
#define I if
#define nx 51
#define p (L)(1e9+7)
L n,fn,f[nx][nx][nx],v[nx],ans;
Z main(){
	v[0]=v[1]=1;
	F(i,2,nx-1)v[i]=-p/i*v[p%i]%p;
	F(i,2,nx-1)(v[i]*=v[i-1])%=p;
	S(n),fn=1;
	F(i,1,n)(fn*=i)%=p;
	f[1][0][1]=1;
	F(i,1,n)F(x,0,n)F(y,0,n)I(f[i][x][y])
	F(a,0,n)F(b,0,n)I(x-a+b>=0&&y+a-b>=0&&a+b>0&&i+a+b<=n)(f[i+a+b][a][b]+=f[i][x][y]*v[x-a+b]%p*v[y+a-b])%=p;
	F(x,0,n)F(y,0,n)(ans+=f[n][x][y]*v[x]%p*v[y])%=p;
	F(i,1,n)(ans*=i)%=p;
	P(ans);
}

Measured memory_bytes: 2176
#include <iostream>
#include <math.h>
using namespace std;
#define debug freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
int main()
{
	//debug;
	bool arr[110];
	for (int i = 0; i < 110; arr[i++] = false);
	int xnum[5][5];
	for (int i = 1; i <= 3; i++)
	{
		for (int j = 1; j <= 3; j++)
		{
			cin >> xnum[i][j];
		}
	}
	int N;
	int num[20];
	cin >> N;
	int i;
	for (i = 0; i < N; i++)
	{
		cin >> num[i];
		arr[num[i]] = true;
	}
	//for (int i = 1; i <= 3; i++)
	//{
	//	for (int j = 1; j <= 3; j++)
	//	{
	//		cout << arr[xnum[i][j]] << " ";
	//	}
	//	cout << endl;
	//}
	if(arr[xnum[1][1]]==1&&arr[xnum[2][2]]==1&&arr[xnum[3][3]]==1)
		cout<<"Yes"<<endl;
	else if(arr[xnum[3][1]]==1&&arr[xnum[2][2]]==1&&arr[xnum[1][3]]==1)
		cout<<"Yes"<<endl;
	
	else if(arr[xnum[1][1]]==1&&arr[xnum[1][2]]==1&&arr[xnum[1][3]]==1)
		cout<<"Yes"<<endl;
	else if(arr[xnum[2][1]]==1&&arr[xnum[2][2]]==1&&arr[xnum[2][3]]==1)
		cout<<"Yes"<<endl;
	else if(arr[xnum[3][1]]==1&&arr[xnum[3][2]]==1&&arr[xnum[3][3]]==1)
		cout<<"Yes"<<endl;
	
	else if(arr[xnum[1][1]]==1&&arr[xnum[2][1]]==1&&arr[xnum[3][1]]==1)
		cout<<"Yes"<<endl;
	else if(arr[xnum[1][2]]==1&&arr[xnum[2][2]]==1&&arr[xnum[3][2]]==1)
		cout<<"Yes"<<endl;
	else if(arr[xnum[1][3]]==1&&arr[xnum[2][3]]==1&&arr[xnum[3][3]]==1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void){
    long long int n,k;
    (void)scanf("%lld %lld",&n,&k);
    n=n%k;
    while(n>llabs(n-k)){
    n=llabs(n-k);
    }
    printf("%lld\n",n);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

    if(a<b)
    {
        cout<<a<<endl ;
    }
    if(a==b)
    {
        cout<<a<<endl ;
    }
    if(a>b)
    {
        cout<<a-1<<endl ;
    }

}

    

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static int dfs(std::vector<int>& len, int now, std::vector<std::vector<int>> sel, int A, int B, int C)
{
	int ans = MOD_NUM;
	if (now >= len.size()) {
		if (sel[0].size() == 0 || sel[1].size() == 0 || sel[2].size() == 0) {
			return MOD_NUM;
		}
		ans = 0;
		int a = 0;
		for (int i = 0; i < sel[0].size(); i++) {
			a += sel[0][i];
		}
		ans += (sel[0].size() - 1) * 10;
		ans += tp_abs(A - a);
		int b = 0;
		for (int i = 0; i < sel[1].size(); i++) {
			b += sel[1][i];
		}
		ans += (sel[1].size() - 1) * 10;
		ans += tp_abs(B - b);
		int c = 0;
		for (int i = 0; i < sel[2].size(); i++) {
			c += sel[2][i];
		}
		ans += (sel[2].size() - 1) * 10;
		ans += tp_abs(C - c);
	}
	else {
		for (int i = 0; i < 4; i++) {
			if (i < 3) {
				sel[i].push_back(len[now]);
			}
			ans = std::min(ans, dfs(len, now + 1, sel, A, B, C));
			if (i < 3) {
				sel[i].erase(sel[i].end() - 1);
			}
		}
	}
	return ans;
}

static void exec()
{
	int N, A, B, C;
	get(N);
	get(A, B, C);

	std::vector<int> len(N);
	for (int i = 0; i < N; i++) {
		get(len[i]);
	}
	std::vector<std::vector<int>> sel(3);
	printf("%d\n", dfs(len, 0, sel, A, B, C));
}


Measured memory_bytes: 3708
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdio>

const double EPSILON = 1e-10;

inline bool equals(double a, double b) {
    return std::fabs(a - b) < EPSILON;
}

struct Point {
    double x;
    double y;

    bool operator < (const Point& p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point& p) const {
        return equals(x, p.x) && equals(y, p.y);
    }
};

Point operator + (const Point& p1, const Point& p2) {
    return Point{p1.x + p2.x, p1.y + p2.y};
}

Point operator - (const Point& p1, const Point& p2) {
    return Point{p1.x - p2.x, p1.y - p2.y};
}

Point operator * (const Point& p1, double k) {
    return Point{p1.x * k, p1.y * k};
}

struct Segment {
    Point p1, p2;
};

struct Circle {
    Point center;
    double radius;
};

using Vector = Point;
using Line = Segment;
using Polygon = std::vector<Point>;


double norm(const Vector& p) {
    return p.x * p.x + p.y * p.y;
}

double abs(const Vector& p) {
    return std::sqrt(norm(p));
}

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x;
}

Vector projection(const Segment& s, const Point& p) {
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / norm(base);
    return s.p1 + base * r;
}

Vector reflection(const Segment& s, const Point& p) {
    using namespace std;
    auto proj = projection(s, p);
    return p + (projection(s, p) - p) * 2.0;
}

int main() {
    using namespace std;

    Point p1, p2;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;
    Segment s{p1, p2};

    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        double x, y;
        cin >> x >> y;
        auto p = reflection(s, Point{x, y});
        cout << setprecision(20) << p.x << " " << p.y << endl;
    }

    return 0;
}


Measured memory_bytes: 3292
X, K, D = map(int, input().split())

d = abs(X) // D
if d >= K:
  if X >= 0:
    ans = X - K * D
  else:
    ans = X + K * D
  print(abs(ans))
  exit()

if X >= 0:
  ans = X - d * D
else:
  ans = X + d * D

n = K - d
if n % 2 == 1:
  if ans >= 0:
    ans -= D
  else:
    ans += D

print(abs(ans))


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n + 1); i++)
int main() {
    string S;
    cin>>S;
    int a=S.size();
    
    for(int i=a; 0<i; i--){
      	if(i!=a){
        if(i%2==0){
            bool t=true;
            rep(j,i/2){
                if(S[j]!=S[j+i/2]){
                    j+=i;
                    t=false;
                }
            }
            if(t==true){
                cout<<i<<endl;
                break;
            }
        }
        else{
            continue;
        }
        }
    }
}

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

int main(){
  int n, u, k, x;
  int m[101][101]={0};

  cin >> n;

  for (int i=1; i<=n; i++){
    cin >> u >> k;
    for (int j=1; j<=k; j++){
      cin >> x;
      m[i][x]=1;
    }
  }

  for (int i=1; i<=n; i++){
    for (int j=1; j<=n; j++){
      cout << m[i][j];
      if (j!=n) cout << " ";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3120
#include<stdio.h>

int main(){
  int i,k,j,n,m,l;
  int a[110][110],b[110][110];
  long c[110][110] = {};

  scanf("%d %d %d", &n, &m, &l);

  for(i=0;i<n;++i){
    for(k=0;k<m;++k){
      scanf("%d", &a[i][k]);
    }
  }

  for(i=0;i<m;++i){
    for(k=0;k<l;++k){
      scanf("%d", &b[i][k]);
    }
  }

  
  for(i=0;i<n;++i){
    for(k=0;k<l;++k){
      for(j=0;j<m;++j){
	c[i][k] += a[i][j]*b[j][k];
      }

      printf("%ld", c[i][k]);
      if(k != l-1) printf(" ");
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2104
#define _GLIBCXX_DEBUG

#include <unistd.h>
#include <stdlib.h>

void get_nums(int *array, char *s, int count)
{
    int num;
    int i;
    int j;
    
    i = -1;
    while (s[++i] != 10)
    {
        if (s[i] != 32)
        {
            num = 0;
            while ('0' <= s[i] && s[i] <= '9')
            {
                num = num * 10 + s[i++] - '0';
                if (!s[i])
                {
                    array[count++] = num;
                    return ;                    
                }
            }
            array[count++] = num;
            i--;
        }
    }  
}

void get_stirngs(char *s, char *tmp, int pass_flag, int count)
{
    int i;
    int j;
    
    i = -1;
    while (count < pass_flag)
    {
        while (tmp[++i] != 10)
            ;
        count++;
    }
    j = 0;
    while (tmp[++i] != 10)
    {
        while (31 < tmp[i] && tmp[i] < 127)
        {
            s[j++] = tmp[i++];
            if (!tmp[i])
            {
                s[j] = 0;
                return ;                    
            }
        }
        s[j] = 0;
        i--;
    }  
}

void get_ans(int x, int y, char *tmp)
{
    int i;
    int j;
    char s[x + 1];
    
    j = -1;
    while (++j < y + 2)
    {
        if (0 < j  && j <= y)
            get_stirngs(s, tmp, j, 0);
        i = -1;
        while (++i < x + 2)
        {
            if (0 < j  && j <= y && 0 < i && i <= x)
                write(1, &s[i - 1], 1);
            else
                write(1, "#", 1);
        }
        write(1, "\n", 1);
    }
}

char *create_array(char *s, char *new_arr, char *t, int size)
{
    int i;
    int j;
    
    i = -1;
    while (s[++i])
        new_arr[i] = s[i];
    free(s);
    j = -1;
    while (++j < size)
        new_arr[i++] = t[j];   
    new_arr[i] = 0;
    return (new_arr);
}

char *get_data(char *s)
{
    int size;
    int sum_size;
    char t[5];
    char *new_arr;
    
    sum_size = 0;
    while ((size = read(0, t, 5)))
    {
        if (size == -1)
            return (NULL);
        sum_size += size;
        if (!(new_arr = (char*)malloc(sum_size + 1)))
            return (NULL);
        s = create_array(s, new_arr, t, size);
    }
    return (s);
}

int main(void){
    int num[2];
    char *s;
    
    s = malloc(1);
    s = get_data(s);
    
    //printf("%s\n\n",s);
    //write(1,s,6);
    get_nums(num, s, 0);
    //printf("num[0]=%d,num[1]=%d\n",num[0],num[1]);
    get_ans(num[1],num[0], s);
    return (0);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int n;
double v[50000];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(v, v + n);
    double kek = (v[0] + v[1]) / 2;
    for (int i = 2; i < n; i++)
    {
        kek = (kek + v[i]) / 2;
    }
    printf("%.9f", kek);
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int NOT(int x)
{
    if(x==0) return 2;
    else if(x==1) return 1;
    else return 0;
}

int AND(int x, int y)
{
    if(x==0 || y==0) return 0;
    else if(x==1 || y==1) return 1;
    else return 2;
}

int OR(int x, int y)
{
    if(x==2 || y==2) return 2;
    else if(x==1 || y==1) return 1;
    else return 0;
}

int formula(string s)
{
    if(s.size()==1) return s[0]-'0';
    else
    {
        if(s[0]=='(' && s[s.size()-1]==')')
        {
            string t=s.substr(1,s.size()-2);
            //cout << "er : "<<t<<endl;
            int b=0;
            int op=-1;
            int now=0;
            while(now<t.size())
            {
                if(t[now]=='(') ++b;
                else if(t[now]==')') --b;
                else if(b==0)
                {
                    if(t[now]=='+')
                    {
                        op=0;
                        break;
                    }
                    if(t[now]=='*')
                    {
                        op=1;
                        break;
                    }
                }

                ++now;
            }

            string x=t.substr(0,now), y=t.substr(now+1);

            if(op==0) return OR(formula(x),formula(y));
            if(op==1) return AND(formula(x),formula(y));
        }
        else if(s[0]=='-') return NOT(formula(s.substr(1)));
    }

    return 0;
}

int main()
{
    string s;
    while(cin >>s)
    {
        if(s==".") break;

        int ans=0;
        rep(i,3)rep(j,3)rep(k,3)
        {
            string t=s;
            rep(x,s.size())
            {
                if(t[x]=='P') t[x]=i+'0';
                if(t[x]=='Q') t[x]=j+'0';
                if(t[x]=='R') t[x]=k+'0';
            }

            if(formula(t)==2) ++ans;
        }

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

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

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

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

const ll maxn=2e5+10, maxm=5e4+10, lg=21, mod=1e9+7, inf=1e18;

ll H,W,n,mn[maxn];

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	memset(mn,69,sizeof(mn));
	cin>>H>>W>>n;
	while(n--){
		ll x,y; cin>>x>>y;
		mn[x]=min(mn[x],y);
	}
	for(int x=2,y=1;x<=H;x++){
		if(y>=mn[x]) return cout<<x-1,0;
		y+=(y+1<mn[x]);
	}
	cout<<H;
	
	return 0;
}



 


Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
map<long,long>mp;
int main()
{
    long i,j,t,a,b,n,c,y,m,prev,sum,ans=1,count,k;
    t=1;
    // cin>>t;
    while(t--)
    {
        cin>>n;
        ans=0;
        for(i=0;i<n;i++)
        {
            cin>>a>>b;
            ans+=b-a+1;
        }
        cout<<ans;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q; cin >> N >> Q;
  string S; cin >> S;
  vector<int> cnt(N, 0);
  REP(i, N-1){
    if(S[i] == 'A' && S[i+1] == 'C'){
      cnt[i+1] = cnt[i] + 1;
    }else{
      cnt[i+1] = cnt[i];
    }
  }
  REP(i, Q){
    int l, r; cin >> l >> r; l--; r--;
    int ans = cnt[r]-cnt[l];
    cout << ans << endl;
  }
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

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

    bool ok = true;
    rep(i,s.size()) {
        if(i%2) {
            if(s[i]=='R') { ok = false; }
        } else {
            if(s[i]=='L') { ok = false; }
        }
    }
    if(ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
} /*atcoder*/



Measured memory_bytes: 3600
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

func main() {
	nextReader = newScanner()
	n := nextInt()
	as := make([]int64, n)

	zero := false
	for i := 0; i < n; i++ {
		a := nextInt()
		if a == 0 {
			zero = true
		}
		as[i] = int64(a)
	}

	ans := big.NewInt(1)
	if zero {
		fmt.Println(0)
		return
	} else {
		for _, a := range as {
			ans = ans.Mul(ans, big.NewInt(a))
			if ans.Cmp(big.NewInt(int64(1e18))) == 1 {
				fmt.Println(-1)
				return
			}
		}
		fmt.Println(ans)
	}
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


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

using namespace std;

int main()
{
  int n, a, b;
  bool t[1000001];
  while(cin>>n>>a>>b && (n+a+b)){
    fill(t, t+1000001, false);
    t[0] = true;
    for(int i = 0; i <= n; i++){
      if(t[i]){
	if(i+a <= n){
	  t[i+a] = true;
	}
	if(i+b <= n){
	  t[i+b] = true;
	}
      }
    }
    a = 0;
    for(int i = 1; i <= n; i++){
      if(!t[i]){
	a++;
      }
    }

    cout << a << endl;
  }

  return 0;
}

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

#define FOR(N) for(int i=0;i<N;i++)

int main(){
    long long K=3,N,x,max=0,num=7;
    cin >> N;
    vector<long>A(N);
    FOR(N){
        cin >> A[i];
    }
    sort(A.rbegin(),A.rend());
    if((N-1)%2==0){
        max = A[0];
        for(int i=1;i<(N-1)/2;i++){
            max += 2*A[i];
        }
        max += A[(N-1)/2];
    }else{
        max = A[0];
        for(int i=1;i<N/2;i++){
            max += 2*A[i];
        }
    }
    cout << max;

}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, ans;

struct node {
    int id, od;
    bool operator <(const node &oth) const {
        return od < oth.od;
    }
} e[N];

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> e[i].od, e[i].id = i;
    sort(e + 1, e + 1 + n);
    for (int i = 1; i <= n; ++i) printf("%d ", e[i].id);
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>



using namespace std;

int a[100005];


int main() {
	int n, nn;
	int i;
	cin >> n >> nn;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	int s = 1;
	n -= nn;
	nn--;
	s += n / nn + (n % nn != 0);
	cout << s << endl;
	
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rei register int
#define lson (id << 1)
#define rson ((id << 1) + 1)
using namespace std;
const int maxn = 200010;
int h,w;
int tree[maxn << 3],tag[maxn << 3],p[maxn << 3];
void pushdown(int id,int l,int r){
	if(tag[id] != -1){ int mid(l + r >> 1);
//		tag[lson] = max(tag[id],tag[lson]);
//		tag[rson] = max(tag[id],tag[rson]);
		tag[lson] = tag[lson] == -1 ? tag[id] : min(tag[lson],tag[id]);
		tag[rson] = tag[rson] == -1 ? tag[id] : min(tag[rson],tag[id]);
		p[lson] = min(p[lson],tag[id]),p[rson] = min(p[rson],tag[id]);
		tree[lson] = max(tree[lson],l - p[lson]);
		tree[rson] = max(tree[rson],mid + 1 - p[rson]);
		tag[id] = -1;
	}
}
void build(int id,int l,int r){
	if(l == r){
		tree[id] = 0,p[id] = l,tag[id] = -1;
		return;
	} int mid(l + r >> 1); tag[id] = -1;
	build(lson,l,mid),build(rson,mid + 1,r);
	tree[id] = min(tree[lson],tree[rson]),p[id] = max(p[lson],p[rson]);
}
void cg(int id,int l,int r,int cl,int cr,int k){
	if(tag[id] != -1 && l != r) pushdown(id,l,r);
	if(cl <= l && cr >= r) {
		p[id] = k,tree[id] = max(tree[id],l - k),tag[id] = tag[id] == -1 ? k : min(tag[id],k); return;
	} int mid(l + r >> 1);
	if(cl <= mid) cg(lson,l,mid,cl,cr,k);
	if(cr > mid) cg(rson,mid + 1,r,cl,cr,k);
	tree[id] = min(tree[lson],tree[rson]),p[id] = max(p[lson],p[rson]);
} int qry(int id,int l,int r,int ql,int qr){
//	cerr << id << " " << l << " "  << r << " " << ql << " " << qr << " " << p[id] << endl;
	if(tag[id] != -1 && l != r) pushdown(id,l,r);
	if(ql <= l && qr >= r) return p[id]; int ans(0);
	int mid(l + r >> 1);
	if(ql <= mid) ans = qry(lson,l,mid,ql,qr);
	if(qr > mid) ans = max(ans,qry(rson,mid + 1,r,ql,qr));
	return ans;
}
int main(){
	cin >> h >> w; build(1,1,w);
//	cerr << p[1] << endl;
	for(rei i = 1;i <= h;++i){
		int l,r; scanf("%d%d",&l,&r);
		int x; 
		if(l == 1) x = -9999999;
		else x = qry(1,1,w,1,l - 1);
//		cerr << x << endl;
		cg(1,1,w,l,r,x); 
		if(p[1] > 0) printf("%d\n",i + tree[1]);
		else puts("-1");
	} return 0;
}

Measured memory_bytes: 9936
#include<iostream>
#include<vector>
#define M 1299709
using namespace std;
void make(vector<bool>& a){
a[0]=false;
a[1]=false;
for(int i=2;i<a.size();i++){
	if(a[i]){
		for(int j=2;j*i<a.size();j++){
			a[i*j]=false;
		}
	}

}
return;
	}

int main(void){
	vector<bool> a(M,true);
	make(a);
	
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		int up=0,down=0;
		while(1){
			if(a[n+up]){
				break;
			}else{
				up++;
			}
		}
		while(1){
			if(a[n-down]){
				break;
			}else{
				down++;
			}
		}
		cout<<up+down<<endl;
	}
	return 0;
}

Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>



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


map<string, int> mp;
#define ll long long



int main() {
    string  a, b;
    cin >> a >> b;
    if (a.size() > b.size()) cout << "GREATER" << endl;
    else if (a.size() < b.size())cout << "LESS" << endl;
    else {
        int c = 0;
        rep(i, a.size()) {
            if (a[i] > b[i]) { cout << "GREATER" << endl;
            break;
            }
            else if (a[i] < b[i]) { cout << "LESS" << endl;
            break;
            }
            c++;
        }
        if (c == a.size())cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 256
from collections import deque

def solve():
	n,c,k,*t = map(int,open(0).read().split())
	d = deque(sorted(t)+[float("inf")])
	fir = d[0]
	cnt = ans = 0
	while d:
		if d[0]-fir <= k:
			del d[0]
			cnt += 1
			if cnt == c:
				fir = d[0]
				cnt = 0
				ans += 1
		else:
			fir = d.popleft()
			cnt = 1
			ans += 1
	print(ans-(c==1))

	
if __name__=="__main__":
	solve()

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

int main(){
	int n;
	cin>>n;
	map<string,int>mp;
	rep(i,n){
		string s;
		cin>>s;
		mp[s]++;
	}
	int mx=0;//これはmax
	for(auto p:mp)mx=max(mx,p.second);
	for(auto p:mp){
		if(mx==p.second)
			cout<<p.first<<endl;
	}
	
	return 0;

}


Measured memory_bytes: 25224
import numpy as np

eparams = []
eparams.append(np.array([[-0.001544158, -0.0015717662, 0.9984003], [1.0011895, 0.0012099787, 0.0012313314], [-0.0013096533, 0.99866664, -0.001356594]]))
eparams.append(np.array([0.26188788, -0.20163265, 0.22211806]))

def relu(x):
    return np.maximum(0,x)

def emodel(x):
    x = eparams[0].dot(np.array(x))
    x = x + eparams[1]
    #x = relu(x)
    #x = eparams[2].dot(np.array(x))
    #x = x + eparams[3]
    #x = relu(x)
    #x = eparams[4].dot(np.array(x))
    #x = x + eparams[5]
    return x

x = np.array(list(map(int,input().split())))

y = np.round(emodel(x)).astype(np.int)

print(*y)

Measured memory_bytes: 12504
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n,&s)
	
	nowSlime := s[0]
	cnt := 1
	for i := 1; i < n; i++ {
		if nowSlime != s[i] {
			cnt++
			nowSlime = s[i]
		}
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

public class Program
{
    public static void Main()
    {
        string[] inputSplit = ReadLine().Split(' ');
        int a = int.Parse(inputSplit[0]);
        int b = int.Parse(inputSplit[1]);
        int difference = a - b;
        int originA = difference*(difference + 1) / 2;
        int x = originA-a;

        WriteLine(x);
    }
}

Measured memory_bytes: 13140
K = int(input())

N = 50

ans = [i for i in range(N)]
x,y = divmod(K,N)

ans = list(map(lambda a:a+x,ans))

for i in range(y):
    ans[i] += N + 1
    ans = list(map(lambda a:a-1,ans))

print(N)
print(*ans)

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

int main()
{
    int N;
    cin >> N;
    
    int m = 1000000;
    for (int i = 1; i <= N * 0.5; ++i)
    {
        int n = N - i;
        string str1 = to_string(i);
        string str2 = to_string(n);
        vector<string> strs;
        strs.push_back(str1);
        strs.push_back(str2);
        int res = 0;
        for (string str : strs)
        {
            for (int j = 0; j < str.size(); ++j)
            {
                res += str[j] - '0';
            }
        }
        if (m > res)
        {
            m = res;
        }
    }
    cout << m << endl;
    
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<ll> L(N);
    for (int i=0;i<N;i++) cin >> L[i];
    int cnt=0;
    for (int i=0;i<N;i++)
    {
        for (int j=i+1;j<N;j++)
        {
            for (int k=j+1;k<N;k++)
            {
                if (L[k]<L[i]+L[j] && L[i]<L[k]+L[j] && L[j]<L[i]+L[k] && L[i]!=L[j] && L[j]!=L[k]  && L[k]!=L[i]) cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main()
{
  int temp,i,j,N,K,l[50],use=0;
  scanf("%d %d",&N,&K);
  for(i=0;i<N;i++)
    {
      scanf("%d",&l[i]);
    }
  for (i=0;i<N-1;i++)
    {
      for (j=N-1; j > i; j--)
	{
	  if (l[j-1] > l[j])
	    {
	      temp = l[j-1];
	      l[j-1] =l[j];
	      l[j] = temp;
	    }
	}
    }
  for(i=N-1;i>N-1-K;i--)
    {
      use+=l[i];
    }
  printf("%d\n",use);
  return 0;
}


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

typedef long long ll;
using namespace std;

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

  N -= K * ((N - K) / K);
  
  while(1) {
    if (N <= K && abs(N - K) > N) break;
    N = abs(N - K);
  } 

  cout << N << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
char m;
while(1){
scanf("%c",&m);
if(m=='\n')break;
if(m>='A'&&m<='Z')m+=0x20;
else if(m>='a'&&m<='z')m-=0x20;
printf("%c",m);
}
printf("\n");
return 0;
}


Measured memory_bytes: 2104
N=int(input())
A=list(map(int,input().split()))
cnt=-1
h=0
while h==0:
 for i in range(N):
  if A[i]%2==0:
    A[i]=A[i]/2
  else:
    h=h+1
    break
 cnt=cnt+1
print(cnt)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct
{
	int A;
	int B;

}integer;


int main()
{
  int N , M;
  scanf("%d %d",&N,&M);
  int H[N+1];
  H[0]=0;

  for (int i =1;i<=N;i++)
  {
  	scanf("%d",&H[i]);
  }

  integer Road[M];
  int Counters[N+1];
  memset(Counters,0,sizeof(Counters[0]) * (N+ 1));

  for (int i = 0;i<M;i++)
  {
  	scanf("%d %d",&Road[i].A,&Road[i].B);
    
  }

   for (int i = 1;i<=N;i++)
   Counters[i]=2;
  
 

  int count = 0;
  for (int i = 0;i<M;i++)
  {
  	if (H[	Road[i].A	] > H[Road[i].B])Counters[Road[i].A]*=1;
    else Counters[Road[i].A]*=0;
  }

  for (int i = 0;i<M;i++)
  {
  	if (H[	Road[i].B	] > H[Road[i].A])Counters[Road[i].B]*=1;
    else Counters[Road[i].B]*=0;
  }
 

  for (int i = 1;i<=N;i++)
  {
   if (Counters[i]==2)
  	count++;
  }

   printf("%d",count);

   return 0;
}


Measured memory_bytes: 3280
//nikkei2019_c.cpp
//Sun Jan 27 20:54:10 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n;
	cin >> n;
	ll total[n];
	ll btotal = 0;
	for (int i=0;i<n;i++){
		ll a,b;
		cin >> a >> b;
		total[i] = a+b;
		btotal -= b;
	}

	sort(total,total+n,greater<int>());

	for (int i=0;i<n;i++){
		if (i%2==0){
			btotal = btotal+total[i];
		}
	}

	cout << btotal << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

int main() {
    int ab, bc, ca;

    std::cin >> ab >> bc >> ca;
    
    int s = (ab + bc + ca) / 2;
    int area = sqrt(s * (s - ab) * (s - bc) * (s - ca));

    std::cout << area << std::endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int n, m;
    cin >> n >> m;
    ll ans =1;
    rep(i,m){
        ans *= 2;
    }
    ans *= (m * 1900 + (n - m) * 100);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
n = gets.to_i

result = 0
for i in 1..n do
    count = 0
    if i % 2 != 0
        for k in 1..n do
            if i % k == 0
                count += 1
            end
        end
        if count == 8
            result += 1
        end
    end
end

puts result


Measured memory_bytes: 1788
/*
 	author:: tamajit banerjee
*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include <iomanip>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>
ll a[200001];
ll k,n;
bool check(ll mid){
	ll cnt=0;
	for(int i=0;i<n;i++){
		cnt+=(a[i]-1)/mid;
	}
	if(cnt<=k)
	return true;
	else 
	return false;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  	cin>>n>>k;
  	for(int i=0;i<n;i++){
  		cin>>a[i];
	  }
	ll l=1,r=1e9;
	ll ans=-1;
	while(l<=r){
		ll mid=(l+r)/2;
		if(check(mid)){
			r=mid-1;
			ans=mid;
		}else{
			l=mid+1;
		}
	}
	cout<<ans;
	return 0;
}
    

Measured memory_bytes: 5160
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;

using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;


const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

int main()
{
  string s;
  cin >> s;
  if (s[s.size() - 1] == 's') {
    cout << s + "es" << endl;
  }else{
    cout << s + "s" << endl;
  }
}


Measured memory_bytes: 3564
MOD = 10**9 + 7
dp = [-1] * 2001
dp[0] = 1
dp[1] = 0
dp[2] = 0

def f(n):
    for i in range(3, n+1):
        dp[i] = sum(dp[i-j] for j in range(3, i+1)) % MOD
    return dp[n]

assert f(7) == 3
assert f(2) == 0
assert f(1729) == 294867501

s = int(input())
print(f(s))

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

int n, k;
vector<int>p, q, A, ans;

vector<int> operator * (const vector<int>&a,const vector<int>&b){
    vector<int>c; c.resize(n+1);
    for (int i=1;i<=n;++i) c[i]=a[b[i]];
    return c;
}
vector<int> ni(const vector<int>&a){
    vector<int>c; c.resize(n+1);
    for (int i=1;i<=n;++i) c[a[i]]=i;
    return c;
}

vector<int> K(vector<int>x,int y){
    --y; vector<int>t=x;
    for (;y;y>>=1,x=x*x)
        if (y&1) t=t*x;
    return t;
}

vector<int> gao(int m){
    vector<int>f[100];
    f[1]=p; f[2]=q;
    for (int i=3;i<=m;++i) f[i]=f[i-1]*ni(f[i-2]);
    return f[m];
}

int main(){
    cin>>n>>k;
    p.resize(n+1); q.resize(n+1);
    for (int i=1;i<=n;++i) cin>>p[i];
    for (int i=1;i<=n;++i) cin>>q[i];
    A=q*ni(p)*ni(q)*p;
    if (k<30) ans=gao(k);
    else{
        int t=k/6-3;
        ans=K(A,t)*gao(k-t*6)*K(ni(A),t);
    }
    for (int i=1;i<=n;++i) cout<<ans[i]<<' ';
    cout<<endl;
}

Measured memory_bytes: 11488
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N,X;
    cin >> N >> X;
    vector<int> L(N), D(N+1);
    for(int i=0; i<N; i++){
        cin >> L[i];
    }
    D[0]=0;
    for(int i=1; i<N+1; i++){
        D[i]=D[i-1]+L[i-1];
    }
    int ans=0;
    for(int i=0; i<N+1; i++){
        if(D[i]<=X)ans++;
    }

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

Measured memory_bytes: 256
n, m = map(int, input().split())
D = [[] for _ in range(n)]
for i in range(m):
    p,y = map(int, input().split())
    D[p-1].append((y,i))
ans = [None] * m
for i,d in enumerate(D):
    d.sort()
    for j, (k,l) in enumerate(d):
        ans[l] = str(i+1).zfill(6) + str(j+1).zfill(6)
for i in ans:
    print(i)

Measured memory_bytes: 35920
//In The Name Of The God

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define F first
#define S second
#define X first.first
#define Y first .second
#define A second.first
#define B second.second
#define mp make_pair
#define pb push_back
#define pf push_front
#define P push
#define pob pop_back
#define pof pop_front
#define PO pop
#define rep(i,j,k) for(int i = j ; i <= k ; ++ i)
#define rrep(i,j,k) for(int i = j ; i>=k ; --i)
#define FR(i,j,k) for(int i = j ; i < k ; ++ i )
#define rFR(i,j,k) for(int i = j ; i > k ; -- i )
#define lb(x) x&-x;
#define SZ size()
#define LB lower_bound
#define UB upper_bound
#define IT iterator
#define RIT reverse_iterator
#define E end()
#define BE begin()
#define RE rend()
#define RBE rbegin()
#define UN unsigned

typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll ;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<int,pll> pipl;
typedef pair<pll,int> ppli ;
typedef pair<pll,pll> plpl ;
typedef pair<ll,pii> lpip;
typedef pair<pii,ll> lppi;
typedef pair<pii,pii> lppp;
typedef pair<ll,pll> lpipl;
typedef pair<pll,ll> lppli ;
typedef pair<pll,pll> lplpl ;
typedef vector<int> vi ;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii > stpi;
typedef set<pll> stpl;
typedef vi::IT vit;
typedef vl::IT vlt;
typedef vpi::IT vpit;
typedef vpl::IT vplt;
typedef sti::IT stit;
typedef stl::IT stlt;
typedef stpi::IT stpit;
typedef stpl::IT stplt;
typedef vpi::RIT rvpit;
typedef vpl::RIT rvplt;
typedef sti::RIT rstit;
typedef stl::RIT rstlt;
typedef stpi::RIT rstpit;
typedef stpl::RIT rstplt;

const int MAXN = 500000;
const int SUPERN = 5000000;
const int MD = 1e9+7;
//......Variables........
string a,b;
//......Funcs............

//......Code.............
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>a>>b;
    if(a.SZ>b.SZ)
    {
        cout<<"GREATER";
    }
    else if(a.SZ<b.SZ)
    {
        cout<<"LESS";
    }
    else
    {
        if(a>b)
        {
            cout<<"GREATER";
        }
        else if(a<b)
        {
            cout<<"LESS";
        }
        else
        {
            cout<<"EQUAL";
        }
    }
    return 0;
}


Measured memory_bytes: 384