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

typedef long long ll;
typedef  double ld;
#define rep(i,a,n) for(ll i=(a); i<(n); i++)
#define per(i,a,n) for(ll i=(n-1); i>=(a); i--)
#define F first
#define S second
#define maxx(a,b) a=max(a,b)
#define minn(a,b) a=min(a,b)
#define db(x) cerr<<#x<<" = "<<x<<endl
#define N 1111111
#define mod 1000000007
#define rt return
#define inf 12345678908761

using namespace std;

int main()
{

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

    //freopen("Ulug'bek","r",stdin);
    //freopen("Abdimanabov","w",stdout);

    int n;
    cin>>n;
    vector<int> v(n), ans(n,0);
    for(auto &x: v)
        cin>>x;
    ans[1]=abs(v[1]-v[0]);
    rep(i,2,n)
    ans[i]=min(abs(v[i]-v[i-1])+ans[i-1],abs(v[i]-v[i-2])+ans[i-2]);

    cout<<ans[n-1];

    rt 0;
}



















Measured memory_bytes: 1024
N = int(input())
if N < 105:
  print(0)
elif 105 <= N < 135:
  print(1)
elif 135 <= N < 165:
  print(2)
elif 165 <= N < 189:
  print(3)
elif 189 <= N < 195:
  print(4)
else:
  print(5)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,a,b;
  cin >> N >> M;
  vector<int>n(N,0);

  for (int i=0;i<M;i++){
    cin >> a >> b;
    n.at(a-1) += 1;
    n.at(b-1) += 1;
  }

  for (int i=0;i<N;i++){
    cout << n.at(i) << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long x = in.nextLong();
		if (x <= 6) {
			System.out.println(1);
		} else if (x % 11 == 0) {
			System.out.println(x / 11 * 2);
		} else {
			long count = x / 11 * 2;
			count += (x % 11 <= 6 ? 1 : 2);
			System.out.println(count);
		}
		in.close();
	}
}

Measured memory_bytes: 21588
def h():
    H, W = map(int, input().split())
    a = [input() for _ in range(H)]
    MOD = 10 ** 9 + 7
    memo = [[0] * W for _ in range(H)]
    memo[0][0] = 1
    for i in range(H):
        for j in range(W):
            if j + 1 < W and a[i][j + 1] == '.':
                memo[i][j + 1] += memo[i][j] % MOD
            if i + 1 < H and a[i + 1][j] == '.':
                memo[i + 1][j] += memo[i][j] % MOD
    return memo[-1][-1] % MOD


if __name__ == '__main__':
    ans = h()
    print(ans)

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

int main(){
  int n,k,count,a;
  cin >> n >> k;
  ll ans = 0;
  for(ll i=k;i<=n+1;i++)ans = (ans + (2*n-i+1)*i/2 - (i-1)*i/2 + 1)%1000000007;
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<stdio.h>
int main(){
	
	int i;
	char s[21];
	

	scanf("%s",s);
		
	for(i=0;s[i]!='\0';i++);
	if(i>0) i--;
	for(;i>=0;i--) std::cout<<s[i];

	std::cout<<std::endl;
		





	
	
	
	
	

	return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, 0, n) cin >> l[i];
    sort(all(l));
    ll ans = 0;
    rep(i, 0, n - 2) {
        rep(j, i + 1, n - 1) {
            int sum = l[i] + l[j];
            int tmp = lower_bound(all(l), sum) - l.begin();
            ans += tmp - j - 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, M, H, W;
int ans;
string s;

int main() {
    cin >> H >> W;
    int h, w;;
    cin >> h >> w;

    int cnt = H * W;
    cnt -= h * W;
    cnt -= (H - h) * w;
    write(cnt);
}

Measured memory_bytes: 256
n, m = map(int, input().split())
li_c = list(map(int, input().split()))

INF = 10**7
dp = [INF]*(50010)
dp[0] = 0
dp[1] = 1
# dp[i] : i 円支払う時の最小の枚数
for i in range(50001):
    for coin in li_c:
        if i+coin<50010:
            dp[i+coin] = min(dp[i]+1, dp[i+coin])
print(dp[n])




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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin >> n;
	vector<long long int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin() , a.end());
	long long int mul = 1;
	for(int i = 0; i < n; i++) {
		long long int x = a[i];
		long double x1= (long double) mul * x;
		if(x1 > 1e18 || x1 < 0) {
			cout << "-1";
			return 0;
		}
		mul = (long long int) x1;
	}
	cout << mul;
	return 0;
}


Measured memory_bytes: 3996
#include <stdio.h>
const int N=11;
void swap(int &a,int &b){
    int temp=a;
    a=b;
    b=temp;
    return ;
}
int main(){
    int n,temp,w[N],l[N],f[N];
    char c[10],a[N];
    while(true){
        scanf("%d",&n);
        if(n==0)return 0;
        for(int i=0;i<n;i++){
            scanf("%s",c);
            a[i]=c[0];
            f[i]=i;
            w[i]=l[i]=0;
            for(int j=1;j<n;j++){
                scanf("%d",&temp);
                if(temp==1)l[i]++;
                else if(temp==0)w[i]++;
            }
        }
        for(int i=0;i<n;i++)for(int j=1;j<n;j++)if(w[f[j]]==w[f[j-1]]?l[f[j]]<l[f[j-1]]:w[f[j]]>w[f[j-1]])swap(f[j],f[j-1]);
        
        
        for(int i=0;i<n;i++)printf("%c\n",a[f[i]]);
    }
}


Measured memory_bytes: 2616
#include<algorithm>
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	int R[100], n;
	cin >> n;
	int k = 0;
	bool flag = 1;
	for (int i = 0; i<n; i++){
		cin >> R[i];
	}
	for (int i = 0; flag; i++){
		flag = 0;
		for (int j = n - 1; j >= i+1; j--){
			if (R[j - 1] > R[j]){
				swap(R[j], R[j-1]);
				flag = 1;
                                k++;
			}
		}
	}
	for (int i = 0; i < n; i++){
		if (i != 0){
			cout << " ";
                }
		cout << R[i];
	}
        cout << endl;
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 3040
L=input()
N=len(L)
dp=[[0,0]for _ in range(N)]
dp[0][0]=1
dp[0][1]=2
mod=10**9+7
for i in range(1,N):
  dp[i][0]+=3*dp[i-1][0]
  dp[i][0]%=mod
  if L[i]=='0':
    dp[i][1]+=dp[i-1][1]
  else:
    dp[i][0]+=dp[i-1][1]
    dp[i][1]+=dp[i-1][1]*2
  dp[i][0]%=mod
  dp[i][1]%=mod
print(sum(dp[-1])%mod)

Measured memory_bytes: 24064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	cout << n * n*n << endl;
	return 0;
}

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

int compare(const void*a,const void *b) {
	return *(int*)a - *(int*)b;
}

int main() {
	int l,r,d,k = 0, n, a[100] = { 0 }, ans = 0;
	char s[3], cas[4][4] = {"AC","WA","TLE","RE"};
	scanf("%d", &n);

	printf("%d", 10 - n / 200); 
	return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>
long int m(int a){return a<0?0:a;}
int main(){
  long int i,n,k,x=0;
  scanf("%ld%ld",&n,&k);
  for(i=1;i<=n;i++)x+=n/i*m(i-k)+m(n%i-k+1)-(k==0);
  printf("%ld",x);
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N, K; cin >> N >> K;
  map<int,int> m;
  rep(i, N) {
    int a, b; cin >> a >> b;
    m[a] += b;
  }
  for(auto p : m) {
    if(p.second >= K) {
      cout << p.first << endl;
      return 0;
    } else {
      K -= p.second;
    }
  }
  
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T,typename U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int largest_rectangle(vector<int>& A){
    int N = A.size()-1;
    int ans = 0;
    stack<P<int,int>> s;
    for(int i=0;i<=N;i++){
        int pos = i;
        while(!s.empty() && s.top().first>=A[i]){
            P<int,int> p = s.top(); s.pop();
            ans = max(ans,p.first*(i-p.second+(i!=N)));
            pos = p.second;
        }
        s.push({A[i],pos});
    }
    return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    vvec<char> S(H,vec<char>(W));
    for(int i=0;i<H;i++) for(int j=0;j<W;j++) cin >> S[i][j];

    auto check = [&](int i,int j){
        if(i==H-1 || j==W-1) return true;
        int c = 0;
        for(int k=i;k<i+2;k++) for(int l=j;l<j+2;l++) c += (S[k][l]=='#');
        return (c==0 || c==2 || c==4);
    };

    int ans = 0;
    vvec<int> level(H,vec<int>(W,0));
    for(int i=0;i<H;i++){
        vec<int> hist(W+1,0);
        for(int j=0;j<W;j++){
            if(i==0){
                level[i][j] = 1;
                hist[j] = 1;
                continue;
            }
            level[i][j] = ((j==W-1 || check(i-1,j))? level[i-1][j]+1:1);
            hist[j] = level[i][j];
        }
        hist[W] = 0;
        ans = max(ans,largest_rectangle(hist));
    }
    cout << max({ans,H,W}) << endl;

//    cerr << endl;
//    for(int i=0;i<H;i++) for(int j=0;j<W;j++) cerr << level[i][j] << (j!=W-1? " ":"\n");
}

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

int N,W;
long dp[105][10005];
vector<long> v(100);
vector<long> w(100);


int main() {

cin>>N>>W;
for(int i=0;i<N;i++) cin>>v[i]>>w[i];

for(int i=0;i<=N;i++){
  for(int j=0;j<=W;j++){
    dp[i][j]=0;
  }
}

for(int i=0;i<=N;i++){
  for(int j=0;j<=W;j++){
     if(j>=w[i]) dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
     else dp[i+1][j]=dp[i][j];
  }
}

for(int i=1;i<=N;i++){
  for(int j=0;j<=W;j++){
  //  cout<<dp[i][j]<<" ";
  }
  //cout<<endl;
}

cout<<dp[N][W]<<endl;
}



Measured memory_bytes: 11112
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

struct Edge {
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

vector<bool> seen;
vector<ll> depth;
void dfs(const Graph &G, int v) {
    seen[v] = true;

    for (auto next_v : G[v]) { 
        if (seen[next_v.to]) continue;
		depth[next_v.to] = depth[v] + next_v.weight;
        dfs(G, next_v.to);
    }
}

void Main() {
	int N; cin >> N;
	Graph G(N);
	REP(i, N - 1) {
		int from, to;
		ll weight;
        cin >> from >> to >> weight;
		--from; --to;
        G[from].push_back(Edge(to, weight));
		G[to].push_back(Edge(from, weight));
	}
	int Q, K; cin >> Q >> K;
	--K;
	seen.assign(N, false);
	depth.assign(N, -1);
	depth[K] = 0;
    dfs(G, K);

	REP(i, Q) {
		int x, y; cin >> x >> y;
		--x; --y;
		cout << depth[x] + depth[y] << endl;
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 14336
/**
*
* Author: MARS
* Lang: GNU C++14
*
**/

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair<int,int>

typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl pi = acos(-1);
const ll inf = 1LL<<60;
const dbl eps = 1e-9;
const ll mod = 1e9+7;

/** /////////// ** Code ** /////////// **/

const int N=3030;
ll mem[N][N][4];
int a[N][N];
int n,m,k;

ll dp(int i, int j, int cnt){
    if(i > n) return -inf;
    if(j > m) return -inf;
    if(i == n && j == m){
        if(cnt < 3) return a[i][j];
        else return 0;
    }

    ll &ret=mem[i][j][cnt];
    if(ret != -1)
        return ret;

    if(cnt < 3)
        return ret=max({a[i][j]+dp(i+1, j, 0), a[i][j]+dp(i, j+1, cnt+1), dp(i, j+1, cnt)});

    else
        return ret=max(dp(i+1, j, 0), dp(i, j+1, cnt));
}

int main(){
    scanf("%d%d%d",&n,&m,&k);
    while(k--){
        int x,y,v;
        scanf("%d%d%d",&x,&y,&v);
        a[x][y]=v;
    }

    memset(mem, -1, sizeof mem);
    printf("%lld\n",dp(1,1,0));

}


Measured memory_bytes: 326620
// ABC125_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N;
    cin >> N;
    vector<ll> vec(N), C(N);
    REP(i, N) cin >> vec[i];
    REP(i, N) cin >> C[i];
    
    // calculation
    ll res = 0, diff;
    REP(i, N) {
        diff = vec[i] - C[i];
        if (diff > 0) res += diff;
    }
    
    cout << res << "\n";
    
    return 0;
}

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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

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

    if(abs(a-b)%2==0){
        cout << (a+b)/2 << endl;
    }else{
        puts("IMPOSSIBLE");
    }
}

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

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

int main() {
    ll h, n, power = 0, tmp;
    cin >> h >> n;
    rep(i, n) {
        cin >> tmp;
        power += tmp;
    }
    cout << (h <= power ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
//#pragma  GCC optimize("Ofast")

//#ifdef  DEBUG
//#define _GLIBCXX_DEBUG
//#endif

// -Ofast
// -O3
// -O2
// -fsanitize=address
// -fsanitize=undefined

// add_compile_options()

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <cmath>
#include <cassert>
#include <random>

using namespace std;

void solve();


int main() {
    srand(time(0));
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}



const int maxN = 2e5 + 10, K = 1e6 + 10;

long long inf = 2e18 + 10, mod = 1e9 + 7;

#define int long long

int n, k, ans;

void solve() {
    cin >> n >> k;
    for (int i = k; i <= n + 1; i++) {
        ans += (n - i + 1) * i + 1;
        ans %= mod;
    }
    cout << ans;
}

Measured memory_bytes: 3656
N=int(input())
*A,=map(int,input().split())
s=list(map(lambda x: x//400, A))

mm=len(set([i for i in s if i<8])) 
o=len([i for i in s if 8<=i]) # 色を変えられる人
print(mm if 1<=mm else 1,min(N,mm+o))

Measured memory_bytes: 9084
#include <stdio.h>

int main(void){
	int x,y,z;
	int A[3],B[3],C[3];
	int a[6],b[6],c[6];
	scanf("%d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]);
	scanf("%d %d %d %d %d %d",&b[0],&b[1],&b[2],&b[3],&b[4],&b[5]);
	scanf("%d %d %d %d %d %d",&c[0],&c[1],&c[2],&c[3],&c[4],&c[5]);
	x=(a[3]*3600+a[4]*60+a[5])-(a[0]*3600+a[1]*60+a[2]);
	y=(b[3]*3600+b[4]*60+b[5])-(b[0]*3600+b[1]*60+b[2]);
	z=(c[3]*3600+c[4]*60+c[5])-(c[0]*3600+c[1]*60+c[2]);
	A[0]=x/3600;
	A[1]=x/60-A[0]*60;
	A[2]=x-A[0]*3600-A[1]*60;
	B[0]=y/3600;
	B[1]=y/60-B[0]*60;
	B[2]=y-B[0]*3600-B[1]*60;
	C[0]=z/3600;
	C[1]=z/60-C[0]*60;
	C[2]=z-C[0]*3600-C[1]*60;
	printf("%d %d %d\n%d %d %d\n%d %d %d\n",A[0],A[1],A[2],B[0],B[1],B[2],C[0],C[1],C[2]);
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 512;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int path[MAX][MAX];
bool check[MAX][MAX];

void solve(void){
    int N;
    cin >> N;
    ll ans = 0LL;
    rep(N, i) rep(N, j) {
        scanf("%d", &path[i][j]);
        ans += path[i][j];
    }
    ans /= 2;
    bool f = true;
    rep(N, k) rep(N, i) rep(N, j) {
        if (path[i][j] > path[i][k] + path[k][j]) f = false;
        else if (i != k && j != k && path[i][j] == path[i][k] + path[k][j] && !check[i][j]) {
            ans -= path[i][j];
            check[i][j] = check[j][i] = true;
        }
    }
    cout << (f?ans:-1) << endl;
}

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define nn 1000008
#define pii pair<int,int>
#define mp make_pair
vector<int> v[nn];

int dfn[nn],DFN,bel[nn],vis[nn],low[nn],st[nn],size,tot,cir;
void dfs(int x){
	low[x]=dfn[x]=++DFN;st[++size]=x;vis[x]=1;
	for(int i=0;i<v[x].size();i++){
		int y=v[x][i];
		if(!dfn[y]) dfs(y),low[x]=min(low[x],low[y]);
		else if(vis[y]) low[x]=min(low[x],dfn[y]);
	}
	
	if(low[x]==dfn[x]){
		cir++;
		do{
			int y=st[size--];vis[y]=0;bel[y]=cir;
		}while(st[size+1]!=x);
	}
}
int n,xi[nn],yi[nn];
struct tree{
	int lc[nn],rc[nn];
	#define mid (l+r)/2
	int build(int l,int r,vector<pii> &vx){
		int p=++tot;
		if(l==r){
			v[p].push_back(vx[l].second^1);
			return p;
		}
		lc[p]=build(l,mid,vx);rc[p]=build(mid+1,r,vx);
		v[p].push_back(lc[p]);v[p].push_back(rc[p]);
		return p;
	}
	void link(int a,int b,int l,int r,int id,int y){
		if(l>=a and r<=b) {
			v[y].push_back(id);
			return ;
		}
		if(a<=mid) link(a,b,l,mid,lc[id],y);
		if(b>mid) link(a,b,mid+1,r,rc[id],y);
	}
	#undef mid
	
}tx,ty;
int rtx,rty;
void cc(vector<pii> vx,int dist,tree &t,int rt){
	int j=0;
	for(int i=0;i<n;i++){
		while(vx[i].first-vx[j].first>dist) j++;
		if(j<i) t.link(j,i-1,0,n-1,rt,vx[i].second);
	}
	
	j=n-1;
	for(int i=n-1;i>=0;i--){
		while(vx[j].first-vx[i].first>dist) j--;
		if(i<j) t.link(i+1,j,0,n-1,rt,vx[i].second);
	}
}
int li[nn];
void dd(vector<pii> vx,vector<pii> vy,int dist,tree &t,int rt){
	int j=0;
	for(int i=0;i<n;i++){
		while(j<vy.size() and vx[i].first-vy[j].first>dist) j++;
		li[i]=j;
	}
	
	j=n-1;
	for(int i=n-1;i>=0;i--){
		while(j>=0 and vy[j].first-vx[i].first>dist) j--;
		if(li[i]<=j) t.link(li[i],j,0,n-1,rt,vx[i].second);
	}
}

vector<pii> vx,vy;

int solve(int dist){
	for(int i=0;i<n*2;i++) v[i].clear();
	for(int i=0;i<=tot;i++) dfn[i]=0;
	DFN=cir=0;
	cc(vx,dist,tx,rtx);cc(vy,dist,ty,rty);
	dd(vx,vy,dist,ty,rty);dd(vy,vx,dist,tx,rtx);
	for(int i=0;i<=tot;i++) if(!dfn[i]) dfs(i);
	for(int i=0;i<n;i++) if(bel[i<<1]==bel[i<<1|1]) return 0;
	return 1;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d%d",&xi[i],&yi[i]);
	
	tot=n*2-1;
	for(int i=0;i<n;i++) vx.push_back(mp(xi[i],i<<1));
	for(int i=0;i<n;i++) vy.push_back(mp(yi[i],i<<1|1));
	sort(vx.begin(),vx.end());sort(vy.begin(),vy.end());
	
	rtx=tx.build(0,n-1,vx);rty=ty.build(0,n-1,vy);

	int l=0,r=1e9,res=-1;while(l<=r){
		int mid=(l+r)/2;
		if(solve(mid)) 
			l=mid+1,res=mid;
		else r=mid-1;
	}
	printf("%d\n",res+1);
	return 0;
}

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

const int MAX_RC = 300005;
std::set<std::pair<int, int>> ms;
std::map<int, int> rows, cols;

int main() {
  int R, C, M;
  scanf("%d %d %d", &R, &C, &M);
  int maxrow = 0, maxcol = 0;
  for (int i = 0; i  < M; ++i) {
    int r, c;
    scanf("%d %d", &r, &c);
    ms.insert({r, c});
    rows[r]++;
    maxrow = std::max(maxrow, rows[r]);
    cols[c]++;
    maxcol = std::max(maxcol, cols[c]);
  }

  std::vector<int> brows, bcols;
  for (auto& kv : rows)
    if (kv.second == maxrow) brows.push_back(kv.first);
  for (auto& kv : cols)
    if (kv.second == maxcol) bcols.push_back(kv.first);
  int64_t maxpos = brows.size() * bcols.size();
  int64_t cumpos = 0;
  for (auto& p : ms) {
    if (rows[p.first] == maxrow && cols[p.second] == maxcol) cumpos++;
  }
  if (cumpos < maxpos) printf("%lld\n", maxrow + maxcol);
  else printf("%lld\n", maxrow + maxcol - 1);
}


Measured memory_bytes: 49560
n = gets.to_i
a = gets.split.map(&:to_i).sort.reverse

ans = a[0]
def make_gcd(a,b)
  c = a % b
  if c == 0
    return b
  else
    make_gcd(b,c)
  end
end

a.each do |a|
  ans = make_gcd(a,ans)
end

p ans

Measured memory_bytes: 10104
N = int(input())
# N = 105

divisor_cnt = 0
num = 0
# Nは奇数と言う制約があるため、約数は奇数×奇数の組み合わせ
for i in range(1, N+1, 2):
    divisor_cnt = 0
    for j in range(1, i+1, 2):
        if i % j == 0:
            divisor_cnt += 1
    if divisor_cnt == 8:
        num += 1  #


print(num)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<string, int> P;

signed main(){
	int n, q;
	cin >> n >> q;
	queue<P> que;
	rep(i, 0, n){
		string name;
		int time;
		cin >> name >> time;
		que.push(P(name, time));
	}
	vector<P> ans;
	int now = 0;
	while(que.size() != 0){
		P p = que.front(); que.pop();
		if(p.second > q){
			now += q;
			que.push(P(p.first, p.second - q));
		}else{
			now += p.second;
			ans.push_back(P(p.first, now));
		}
	}
	rep(i, 0, ans.size()){
		cout << ans[i].first << " " << ans[i].second << endl;
	}
}

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

using E = System.Linq.Enumerable;

public class Program
{
    const long Mod = (long)1e9 + 7;

    public static void Main()
    {
        var s = int.Parse(Console.ReadLine());

        var k = 0L;
        var maxLength = s / 3;
        for (int i = 0; i < maxLength; ++i)
        {
            // H(n, k) where n = i + 1, k = s - (i + 1) * 3
            var r = s - (i + 1) * 3;
            k += Combination(i + 1 + r - 1, r, Mod); k %= Mod;
        }

        Console.WriteLine(k);
    }

    static long Combination(long n, long k, long mod)
    {
        var a = 1L;
        var b = 1L;
        for (int i = 0; i < n - k; ++i)
        {
            a *= n - i; a %= mod;
            b *= i + 1; b %= mod;
        }
        var inv = (new BézoutIdentity(b, mod).X + mod) % mod;
        return a * inv % mod;
    }
}

public struct BézoutIdentity
{
    public long X { get; }
    public long Y { get; }
    public long Gcd { get; }

    public BézoutIdentity(long a, long b)
    {
        long x = 1, y = 0;
        long u = 0, v = 1;
        while (b > 0)
        {
            var k = a / b;
            (a, b) = (b, a - k * b);
            (x, u) = (u, x - k * u);
            (y, v) = (v, y - k * v);
        }
        (X, Y, Gcd) = (x, y, a);
    }

    public void Deconstruct(out long X, out long Y, out long Gcd) => (X, Y, Gcd) = (this.X, this.Y, this.Gcd);
}


Measured memory_bytes: 27500
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    double a,b;
    cin>>a>>b;
    int ans=-1;
    
    for(int i=1;i<=1000000;i++){
        int A=i*0.08;
        int B=i*0.10;
        
        if(A==a && B==b){
            ans=i;
            break;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		String S = sc.next();
		
		if (S.length() <= K) {
			System.out.println(S);
		} else {
			System.out.println(S.substring(0, K) + "...");
		}

	}
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


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

    if(n%2 == 1) {
        cout << 0 << endl;
        return 0;
    } else {
        // 半分なので
        ll ans = 0;
        ll tmp = n/2;
        while(tmp) {
            tmp /= 5;
            ans += tmp;
        }
        cout << ans << endl;
    }
    return 0;
}



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

using namespace std;

using ll = long long int;

struct UnionFind {
    vector<ll> par;
    vector<ll> siz;

    UnionFind(ll n) : par(n), siz(n, 1ll) {
        for(ll i=0;i<n;i++) {
            par[i] = i;
        }
    }

    ll root(ll x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if(x == y) return;

        if(siz[x] < siz[y]) swap(x,y);
        siz[x] += siz[y];
        par[y] = x;
    }

    bool isSame(ll x, ll y) {
        x = root(x);
        y = root(y);

        return x == y;
    }

    ll size(ll x) {
        x = root(x);
        return siz[x];
    }
};

int main() {
    ll N,M; cin >> N >> M;
    vector<pair<ll,ll>> brg(M);

    for(auto& b : brg) {
        cin >> b.first >> b.second;
        b.first--;
        b.second--;
    }

    vector<ll> ans(M,0);

    ans[M-1] = (N*(N-1))/2;

    UnionFind uf(N);
    for(ll i=M-1;i>=1;i--) {
        ll n1 = brg[i].first;
        ll n2 = brg[i].second;

        if(uf.isSame(n1, n2)) {
            ans[i-1] = ans[i];
        } else {
            ans[i-1] = ans[i] - (uf.size(n1) * uf.size(n2));
            uf.unite(n1,n2);
        }
    }

    for(const auto& a : ans) {
        cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 5248
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int 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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<int, int> mp;
	rep(i,n){
		int d;
		cin >> d;
		++mp[d];
	}
	int m;
	cin >> m;
	rep(i,m){
		int t;
		cin >> t;
		if(--mp[t] < 0){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

int main() {
	string s;cin>>s;
	vector<vector<int>> v(26,vector<int>(s.size(),0));
	for(int i=0;i<s.size();i++){
		v[s[i]-'a'][i]=1;
	}
	int ans=0;
	while(1){
		for(int j=0;j<26;j++){
			int flag=1;
			for(int i=0;i<s.size()-ans;i++){
				if(v[j][i]==0){
					flag=0;
				}
			}
			if(flag){
				cout<<ans<<endl;
				return 0;
			}
		}

		ans++;
		for(int i=0;i<s.size()-1;i++){
			for(int j=0;j<26;j++){
				v[j][i]+=v[j][i+1];
			}
		}
		if(ans>s.size()){
			cout<<-1<<endl;
			break;
		}
	}

	return 0;
}


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

using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int x=0;
    for(int i=0;i<n;i++){
        if((s[i])=='A' & (s[i+1])=='B' & s[i+2]=='C'){
                x++;

        }

    }
    cout<<x;




    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long solve(int k)
{
	if(k<10)
		return k;
	vector<long long> v;
	for(int i=1;i<10;++i)
		v.push_back(i);
	int l = 0, r = v.size()-1;
	while(true)
	{
		for(int i=l;i<=r;++i)
		{
			if(v[i]%10-1>=0)
				v.push_back(v[i]*10LL+v[i]%10LL-1LL);
			v.push_back(v[i]*10LL+v[i]%10LL);
			if(v[i]%10+1<10)
				v.push_back(v[i]*10LL+v[i]%10LL+1LL);
			if(v.size()>=k)
				return v[k-1];
		}
		l = r+1,r = v.size()-1;
	}
	return 0;
}
int main()
{
	int k;
	cin>>k;
	cout<<solve(k);
	return 0;
}

Measured memory_bytes: 1400
# vim: set fileencoding=utf-8:


def main():
    A, B = map(int, raw_input().split())
    S = raw_input()

    if len(S) == A + B + 1 and S[A] == "-" and S[0:A].isalnum() and S[A + 1:].isalnum():
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll x;
	cin >> x;
	ll ans=0, tmp=100;
	while(tmp < x){
		tmp *= 1.01;
		++ans;
	}
	cout << ans;

}


Measured memory_bytes: 3636
n=int(input())
info=[[0,0,0]]
for i in range(n):
    t,x,y=map(int,input().split())
    info.append([t,x,y])
ans="Yes"
for i in range(1,n+1):
    t=info[i][0]-info[i-1][0]
    kyori=abs(info[i][1]-info[i-1][1])+abs(info[i][2]-info[i-1][2])
    zan=t-kyori
    if zan<0:
        ans="No"
        break
    if zan%2!=0:
        ans="No"
        break
print(ans)

Measured memory_bytes: 19572
def dfs(lft, rgt, x, L):
    if x < lft: return 0
    if rgt <= x: return numPs[L]
    mid = (lft + rgt) // 2
    ans = 1 if mid <= x else 0
    ans += dfs(lft + 1, mid - 1, x, L - 1)
    ans += dfs(mid + 1, rgt - 1, x, L - 1)
    return ans

N, X = map(int, input().split())

As, numPs = [1], [1]
for i in range(1, N + 1):
    As.append(As[-1] * 2 + 3)
    numPs .append(numPs[-1] * 2 + 1)

print(dfs(1, As[N], X, N))


Measured memory_bytes: 3064
#include<stdio.h>

int count=0;
void input(int table[10][10]){
	int i,j;
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			scanf("%d",&table[i][j]);
		}
	}
}

void output(int table[10][10]){
	int i,j;
	printf("output\n");
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			printf("%d ",table[i][j]);
		}
		printf("\n");
	}
}

void separate(int num,int sep[]){
	sep[0]=num/1000;
	sep[1]=num/100%10;
	sep[2]=num/10%10;
	sep[3]=num%10;
}

void make_checkdigit(int table[10][10],int sep[5]){
	int a,b,c,d;
	a=table[0][sep[0]];
	b=table[a][sep[1]];
	c=table[b][sep[2]];
	d=table[c][sep[3]];
	sep[4]=d;
}

int check_checkdigit(int table[10][10],int sep[5]){
	int a,b,c,d,e;
	a=table[0][sep[0]];
	b=table[a][sep[1]];
	c=table[b][sep[2]];
	d=table[c][sep[3]];
	e=table[d][sep[4]];
	if(e==0) return 1;
	else return 0;
}

int check_humanerror_altering(int table[10][10],int sep[5],int err[5]){
	int i,j,c=1,d=1;
	for(i=0;i<5;i++){
		err[i]=sep[i];
	}
	for(i=0;i<5&c==1;i++){
		if(i>0) err[i-1]=sep[i-1];
		for(j=0;j<10&&c==1;j++){
			if(j==sep[i]){d=0;}
			if(d==1){
				err[i]=j;
				if(check_checkdigit(table,err)) c=0;
			}
			d=1;
		}
	}
	if(c==0){
		return 0;
	}
	if(c==1){
		return 1;
	}
}

void transporting(int *a,int *b){
	int tmp;
	tmp=*a;
	*a=*b;
	*b=tmp;
}

int check_humanerror_transporting(int table[10][10],int sep[5],int err[5]){
	int i,c=1,d=1;;
	for(i=0;i<5;i++){
		err[i]=sep[i];
	}
	for(i=0;i<4&&c==1;i++){
		if(err[i]==err[i+1]) d=0;
		if(d==1){
			transporting(&err[i],&err[i+1]);
			if(check_checkdigit(table,err)) c=0;
			if(c==1) transporting(&err[i],&err[i+1]);
		}
		d=1;
	}
	if(c==0){
		return 0;
	}
	if(c==1){
		return 1;
	}
}

int main(void){
	int table[10][10];
	int num,sep[5],err[5];
	int alt,tra;
	input(table);
	for(num=0;num<10000;num++){
		separate(num,sep);
		make_checkdigit(table,sep);
		alt=check_humanerror_altering(table,sep,err);
		tra=check_humanerror_transporting(table,sep,err);
		if(alt*tra==1);
		if(alt*tra==0) count++;
	}
	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 2100
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)

def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, W = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    dp=[0]*(W+1)
    for i in range(N):
        w,v=S[i]
        j=W
        while j-w>=0:
            dp[j]=max(dp[j-w]+v,dp[j])
            j-=1

    print(dp[-1])



if __name__ == "__main__":
    main()

Measured memory_bytes: 39792
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector<int> h(n);
	for(int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	
	vector< vector<int> > G(n);
	for(int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		int x = G[i].size();
		int cnt = 0;

		for(int j = 0; j < x; ++j) {
			if( h[i] > h[G[i][j]] ) cnt++;
		}
		
		if( cnt == x ) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 8812
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
    long long int n,i,ans=0,small=0,big=0;
    cin>>n;
    long long int arr[n+5];
    cin>>arr[0];
    small=arr[0];
    big=arr[0];
    for(i=1;i<n;i++)
    {
       cin>>arr[i];
       if(arr[i]>big)
       {
           big=arr[i];
       }
       else if(arr[i]<small)
       {
           small=arr[i];
       }
    }
    sort(arr,arr+n);
    ans=arr[n-1]-arr[0];
    cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <cstdio>
using namespace std;

inline char nc()
{
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}

inline void read(double& sum)
{
    char ch; sum=0;
    ch=nc();
    while(!(ch>='0'&&ch<='9')) ch=nc();
    while(ch>='0'&&ch<='9') sum=sum*10+ch-48,ch=nc();
}

int main()
{
	double a,b;
	read(a),read(b);
	printf("%.6lf\n",(a*b)/(a+b));
	return 0;
}

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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007

#define TIME chrono::system_clock::now
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int m,n;

pair<int,int> raw[100005];
int data[100005];

int main(){
    int i,k;
    
    int miss=0;
    
    cin>>n;
    for (i=1;i<=n;i++){
        scanf("%d",&k);
        raw[i].first=k;
        raw[i].second=i;
    }
    sort(raw+1,raw+n+1);
    
    for (i=1;i<=n;i++){
        data[raw[i].second]=i;
    }
    
    for (i=1;i<=n;i++){
        if ((data[i]&1)^(i&1)){
            miss++;
        }
    }
    cout<<(miss/2)<<endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <fstream>
using namespace std;
typedef long long ll;

const int N = 10010;

int mean[N], buf[N];

void calc(int *a, int n, int r);
void add(int r);

int main()
{
	int n, k, m, r;

	while(cin >> n >> k >> m >> r && n)
	{
		calc(mean, n, r + 10);
		
		if(m)
		{
			for(int i = 1; i < n; i++)
			{ 
				calc(buf, n * i, r + 10);
				add(r + 10);

			}
		}

		for(int i = 0; i < r + 1; i++)
		{
			cout << mean[i];
			if(!i) cout << ".";
		}
		cout << endl;
	}
}

void calc(int *a, int n, int r)
{
	int now = 1;
	for(int i = 0; i < r; i++)
	{
		a[i] = now / n;
		now = now % n * 10;
	}
}

void add(int r)
{
	int carry = 0;
	for(int i = r; i >= 0; i--)
	{
		mean[i] = mean[i] + buf[i] + carry;
		carry = mean[i] / 10;
		mean[i] %= 10;
	}
}

Measured memory_bytes: 940
import sys
import math

def main():
    cells = sys.stdin.readline().strip()
    results = [0 for i in range(len(cells))]
    current = 0
    for index in range(len(cells)):
        if cells[index] == 'R':
            current += 1
        elif cells[index] == 'L':
            results[index - 1] += int(math.ceil(current / 2.0))
            results[index] += int(current / 2)
            current = 0
    for index in reversed(range(len(cells))):
        if cells[index] == 'L':
            current += 1
        elif cells[index] == 'R':
            results[index + 1] += int(math.ceil(current / 2.0))
            results[index] += int(current / 2)
            current = 0
    print(" ".join( [str(i) for i in results]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 10492
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t;
int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>n;
      pair<ll,ll>p[n];
      for(int i=0;i<n;i++){
        cin>>t;
        p[i]={t,i+1};
      }
      sort(p,p+n);
      for(int i=0;i<n;i++){
        cout<<p[i].second<<" ";
      }
      
}

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

int main() {
  
  int a, b;
  cin >> a >> b;
  
  if (a == 1) {a = a + 13;}
  if (b == 1) {b = b + 13;}
  
  if (a > b) {
    cout << "Alice" << endl;
  } else if (b > a) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
   
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector<vector<pair<ll,ll>>> p(n,vector<pair<ll,ll>>(0));
    vector<string> id(m);
    for(int i = 0;i < m;i ++){
        ll place,year;
        cin >> place >> year;
        p[place-1].push_back(make_pair(year,i));
    }
    for(int i = 0;i < n;i ++){
        sort(p[i].begin(),p[i].end());
    }
    for(int i = 0;i < n;i ++){
        for(int j = 0;j < p[i].size();j ++){
            ostringstream ss;
	        ss << setw(6) << setfill('0') << to_string(i+1);
            string idi(ss.str());
            ostringstream sl;
	        sl << setw(6) << setfill('0') << to_string(j+1);
	        string idj(sl.str());
            id[p[i][j].second] = idi + idj;
        }
    }
    for(int i = 0;i < m;i ++){
        cout << id[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 12416
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    ll h, n, s = 0;
    cin >> h >> n;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        s += a;
    }
    cout << (s >= h ? "Yes" : "No") << endl;
}

Measured memory_bytes: 764
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  constexpr array<array<int, 8>, 2> kNum = {
      {{{2, 10, 3, 9, 4, 8, 6, 12}}, {{6, 2, 10, 3, 9, 4, 8, 12}}}};
  set<int> ans;
  if (N == 3)
    ans.insert({2, 5, 63});
  else
    for (int i = 0; i < N; ++i) ans.insert(kNum[N % 2][i % 8] + i / 8 * 12);
  for (const auto& e : ans) cout << e << ' ';
  cout << '\n';
}


Measured memory_bytes: 1280
import numpy as np
(H, W) = tuple(map(int, input().split()))
(h, w) = tuple(map(int, input().split()))

tile = np.zeros([H, W])
for r in range(h):
  tile[r, :] = 1
for c in range(w):
  tile[:, c] = 1

num_white = int(H * W - tile.sum())
print(num_white)

Measured memory_bytes: 12504
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n / 4 + 1; i++) {
        for (int j = 0; j <n / 7 + 1; j++) {
            if (i * 4 + j * 7 == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

vs generate_cand(int l){
  vs res;
  if(l==0){
    res.eb(""); return res;
  }
  vs tmp = generate_cand(l-1);
  for(string x : tmp){
    rep(i,26){
      res.eb( x + (char)('a'+i));
    }
  }
  return res;
}

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int n; cin >> n;
  vs s(n);
  rep(i,n) cin >> s[i];

  set<string> ng;
  for(int l=1;l<=4;l++){
    for(string x : s){
      if(x.size()<l) continue;
      rep(i,x.size()-l+1){
        ng.em( x.substr(i,l) );
      }
    }
  }

  for(int l=1;l<=4;l++){
    vs cand = generate_cand(l);
    for(string x : cand){
      if(ng.count(x) == 0) {
        cout << x << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 68332
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define vec(a,n)  vector<int>a(n)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main(){
    int n;
    cin >> n;
    vec(a,n);
    vec(b,n);
    rep(i,n) cin >> a.at(i);
    rep(i,n) b.at(a.at(i) - 1) = i +1;
    rep(i,n) cout << b[i] << endl;
return 0;
}

Measured memory_bytes: 4036