akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define N 100
const int infty = 1<<28;
struct Node{
  vector<int> con;
  vector<int> cost;
};
struct State{
  int now;
  int cost;
  State():now(-1),cost(infty){}
  State(int pos,int c):now(pos),cost(c){}
  bool operator>(const State &t)const{return cost>t.cost;}
};
typedef vector<Node> Graph;
int dijkstra(int s, int g, Graph &G)
{
  int A[G.size()];
  bool vis[G.size()];
  priority_queue< State,vector<State>,greater<State> > qs;
  fill(A,A+G.size(),infty);
  fill(vis,vis+G.size(),false);
  qs.push(State(s,0));
  A[s]=0;
  while(!qs.empty()){
    State now=qs.top();qs.pop();
    if(vis[now.now])continue;
    vis[now.now]=true;
    for(int i=0;i<G[now.now].con.size();++i){
      int next_id=G[now.now].con[i];
      if(now.cost+G[now.now].cost[i]<A[next_id]){
	A[next_id]=now.cost+G[now.now].cost[i];
	if(!vis[next_id]){
	  qs.push(State(next_id,A[next_id]));
	}
      }
    }
  }
  return A[g];
}
int main()
{
  int n,m,s,g1,g2;
  while( (cin >> n >> m >> s >> g1 >> g2) && n && m && s && g1 && g2 ){
    int ans=infty;
    --s;--g1;--g2;
    Graph G(n);
    for(int i = 0; i < m; ++i){
      int src,dst,cost;
      cin >> src >> dst>> cost;--src;--dst;
      G[src].con.push_back(dst);
      G[src].cost.push_back(cost);
    }
    for(int i = 0; i < n; ++i){
      int tmp=dijkstra(s,i,G)+dijkstra(i,g1,G)+dijkstra(i,g2,G);
      if(tmp<ans)ans=tmp;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 928
#include <cstdio>
#include <string>
#include <map>
#include <utility>

using namespace std;

static const pair<string,char> t2[ 32 ] = {
  make_pair ( "101"     , ' ' ),
  make_pair ( "000000"  , '\'' ),
  make_pair ( "000011"  , ',' ),
  make_pair ( "10010001", '-' ),
  make_pair ( "010001"  , '.' ),
  make_pair ( "000001"  , '?' ),
  make_pair ( "100101"  , 'A' ),
  make_pair ( "10011010", 'B' ),
  make_pair ( "0101"    , 'C' ),
  make_pair ( "0001"    , 'D' ),
  make_pair ( "110"     , 'E' ),
  make_pair ( "01001"   , 'F' ),
  make_pair ( "10011011", 'G' ),
  make_pair ( "010000"  , 'H' ),
  make_pair ( "0111"    , 'I' ),
  make_pair ( "10011000", 'J' ),
  make_pair ( "0110"    , 'K' ),
  make_pair ( "00100"   , 'L' ),
  make_pair ( "10011001", 'M' ),
  make_pair ( "10011110", 'N' ),
  make_pair ( "00101"   , 'O' ),
  make_pair ( "111"     , 'P' ),
  make_pair ( "10011111", 'Q' ),
  make_pair ( "1000"    , 'R' ),
  make_pair ( "00110"   , 'S' ),
  make_pair ( "00111"   , 'T' ),
  make_pair ( "10011100", 'U' ),
  make_pair ( "10011101", 'V' ),
  make_pair ( "000010"  , 'W' ),
  make_pair ( "10010010", 'X' ),
  make_pair ( "10010011", 'Y' ),
  make_pair ( "10010000", 'Z' ) };

int strcmp2 (
  const char * s,
  const char * d
  )
{
  const char * it;

  for ( it = s; *it != '\0'; ++it )
  {
    if ( *it != *d ) break ;
    ++d;
  }

  return ( *it == '\0'
         ? it - s : 0 );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  map<char,string> t1;
  string sb;
  int i;

  t1[ 'A' ] = "00000";
  t1[ 'B' ] = "00001";
  t1[ 'C' ] = "00010";
  t1[ 'D' ] = "00011";
  t1[ 'E' ] = "00100";
  t1[ 'F' ] = "00101";
  t1[ 'G' ] = "00110";
  t1[ 'H' ] = "00111";
  t1[ 'I' ] = "01000";
  t1[ 'J' ] = "01001";
  t1[ 'K' ] = "01010";
  t1[ 'L' ] = "01011";
  t1[ 'M' ] = "01100";
  t1[ 'N' ] = "01101";
  t1[ 'O' ] = "01110";
  t1[ 'P' ] = "01111";
  t1[ 'Q' ] = "10000";
  t1[ 'R' ] = "10001";
  t1[ 'S' ] = "10010";
  t1[ 'T' ] = "10011";
  t1[ 'U' ] = "10100";
  t1[ 'V' ] = "10101";
  t1[ 'W' ] = "10110";
  t1[ 'X' ] = "10111";
  t1[ 'Y' ] = "11000";
  t1[ 'Z' ] = "11001";
  t1[ ' ' ] = "11010";
  t1[ '.' ] = "11011";
  t1[ ',' ] = "11100";
  t1[ '-' ] = "11101";
  t1[ '\'' ]= "11110";
  t1[ '?' ] = "11111";

  for ( ; ; )
  {
    sb = "";

    for ( ; ; )
    {
      const char ch = getchar ( );

      if ( ch == EOF ) return ( 0 );
      if ( ch == '\n' ) break ;
      sb += t1[ ch ];
    }

    while ( !sb.empty ( ) )
    {
      for ( i = 0; i < 32; ++i )
      {
        const int f = strcmp2 ( t2[ i ].first.c_str ( ), sb.c_str ( ) );

        if ( f )
        {
          putchar ( t2[ i ].second );
          sb.erase ( 0, f );
          break ;
        }
      }

      if ( i == 32 ) break ;
    }

    puts ( "" );
  }

  return ( 1 );
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if (n<1200)
        cout<<"ABC";
    else if (n<2800||n<=1200)
        cout<<"ARC";
    else if (n>=2800)
        cout<<"AGC";




    return 0;
}


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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b and b < c) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 3100
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static Scanner sc = new Scanner(System.in);
	
	
	void run() {
		int n, ans;
		boolean[] sieve;
		while (sc.hasNextInt()) {
			n = sc.nextInt();
			ans = 0;
			sieve = new boolean[n+1];
			if (n <= 1) System.out.println(0);
			else {
				for (int i = 2; i <= n; i++) {
					if (!sieve[i]) {
						ans++;
						for (int j = 2; j * i <= n; j++)
							sieve[j*i] = true;
					}
				}
				System.out.println(ans);
			}
		}
		
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}

Measured memory_bytes: 35036
#include <bits/stdc++.h>
#define ms(x, n) memset(x,n,sizeof(x));
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define rep1(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define PI acos(-1.0)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

string s, t;

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> s;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == t[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}


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

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);
	int[] ar = new int[6];
	final int n = stdin.nextInt();
	for ( int i = 0; i < n; i++ ) {
	    final double w = stdin.nextDouble();
	    if ( w < 165.0 ) {
		ar[0]++;
	    } else if ( 165.0 <= w && w < 170.0 ) {
		ar[1]++;
	    } else if ( 170.0 <= w && w < 175.0 ) {
		ar[2]++;
	    } else if ( 175.0 <= w && w < 180.0 ) {
		ar[3]++;
	    } else if ( 180.0 <= w && w < 185.0 ) {
		ar[4]++;
	    } else {
		ar[5]++;
	    }
	}
	for ( int i = 0; i < 6; i++ ) {
	    System.out.printf( "%d:", i + 1 );
	    for ( int j = 0; j < ar[i]; j++ ) {
		System.out.print( "*" );
	    }
	    System.out.println();
	}
    }    
}

Measured memory_bytes: 18624
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mod 1000000007
#define vll vector<ll>
#define inf 1e18
#define pll pair<ll,ll>
#define ff first 
#define ss second 
#define PI acos(-1)
using namespace std;
ll binpow(ll x, ll y) {
    ll int res = 1;
    for(int i = 1; i <= y; i++) {
        res = (res * x) % mod;
    }
    return res;
} 
int main() 
{
    fastio; 
    ll T=1;
    //cin>>T; 
    while(T--)
    { 	
    ll n;
	cin>>n;
	
    ll f[4][n];
    
    for(int i=0;i<n;++i)
    {
    	int x,y;
    	cin>>x>>y;
    	f[0][i]= x+y;
    	f[1][i]= x-y;
    	f[2][i]=-x+y;
    	f[3][i]=-x-y;
    }
    
    for(int i=0;i<4;++i)
    {
    	sort(f[i],f[i]+n);
    }
    
    ll mx=-1;
    
    for(int i=0;i<4;++i)
    mx=max(mx,abs(f[i][0]-f[i][n-1]));
	
	cout<<mx<<endl;
	}
}
 

Measured memory_bytes: 9896
fun main(args : Array<String>) {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }

    for (i in 1..1000) {
        if ((i * 0.08).toInt() == a && (i * 0.1).toInt() == b) {
            println(i)
            return
        }
    }

    println(-1)
}

Measured memory_bytes: 38072
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


class UnionFind
{
	//par[i]：ノードiの親
	//count[i]：iが親の時、iが属するグループのノード数
	vector<int> par;
	vector<int> count;

	int m_groupCount = 0;

public:
	UnionFind(int N)
	{
		par.push_back(0);
		count.push_back(0);

		m_groupCount = N;

		for (int i = 1; i <= N; i++)
		{
			//最初は全てが根であるとして初期化
			par.push_back(i);
			count.push_back(1);
		}
	}

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

		//ついでに親を張り替え
		return par[x] = root(par[x]);
	}

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

		//要素数の変更
		count[ry] += count[rx];
		count[rx] = 0;

		//木の併合によってグループが1つ減る
		m_groupCount--;
	}

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

	//指定したデータxが属するグループの要素数を返す
	int size(int x)
	{
		return count[root(x)];
	}

	//UnionFindのグループの個数を返す
	int groupCount()
	{
		return m_groupCount;
	}
};


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

	UnionFind uf(n);
	rep(i, m)
	{
		int x, y, z;
		cin >> x >> y >> z;

		uf.unite(x, y);
	}

	cout << uf.groupCount() << endl;

	return 0;
}

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

int nextanother(int& i, const int &N, const int &One) {
	int Another;
	cin >> Another;
	i++;
	while (i < N && Another == One) {
		cin >> Another;
		i++;
	}
	return Another;
}

int main() {
	int N;
	cin >> N;
	int ans = 1;
	int A1, A2, A3;
	cin >> A1;
	int i = 1;
	A2 = nextanother(i, N, A1);
	while (i < N) {
		A3 = nextanother(i, N, A2);
		if (((A3 < A2) & (A2 > A1)) || ((A3 > A2)& (A2 < A1))) {
			ans++;
			if (i < N) {
				A1 = A3;
				A2 = nextanother(i, N, A1);
			}
		}
		else {
			A1 = A2;
			A2 = A3;
		}
	}
	cout << ans;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if ((a+b)%3==0||a%3==0||b%3==0)
	{
		printf("Possible\n");
	}
	else
	{
		printf("Impossible\n");
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
c = {str(i)+str(j):0 for i in range(10) for j in range(10)}
for i in range(1,N+1):
  i = str(i)
  c[i[0]+i[-1]]+=1
cnt = 0
for i in range(10):
  for j in range(10):
    cnt+=c[str(i)+str(j)]*c[str(j)+str(i)]
print(cnt)

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll = V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define INF 1e16
#define mod 1e9+7


int main(){
  ldb n,k;
  cin>>n>>k;
  cout<<fixed<<setprecision(15);
  ldb ans=0;
  ldb bns=1/n;
  FOR(i,1,n+1){
    for(ll j=i;j<k;j*=2){
      bns/=2;
    }
    ans+=bns;
    bns=1/n;
  }
  co(ans);
}



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

int dp[100002][3], c, k, deger[100002][3];

int mutlak(int e, int r){
	if(e>r)return e-r;
	else return r-e;
}

int recursive(int konum, int last){
	if(konum>c)return 0;
	if(dp[konum][last])return dp[konum][last];
	if(last==0){
		dp[konum][last]=max(deger[konum][1]+recursive(konum+1, 1), deger[konum][2]+recursive(konum+1, 2));}
	if(last==1){
		dp[konum][last]=max(deger[konum][0]+recursive(konum+1, 0), deger[konum][2]+recursive(konum+1, 2));}
	if(last==2){
		dp[konum][last]=max(deger[konum][1]+recursive(konum+1, 1), deger[konum][0]+recursive(konum+1, 0));}
	return dp[konum][last];
}

int main(void){
	cin>>c;
	for(int i=0;i<c;i++)cin>>deger[i][0]>> deger[i][1]>>deger[i][2];
	memset(dp, 0, sizeof(int)*(c+1));
	cout<<max(max(deger[0][1]+recursive(0+1, 1), deger[0][0]+recursive(0+1, 0)),deger[0][2]+recursive(0+1, 2));
	return 0;
}

Measured memory_bytes: 8832
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  ll K, A, B;
  cin >> K >> A >> B;

  ll N = 1;

  if (B - A > 2) {
    if (K >= A + 1) {
      // change YEN
      // beat
      N += A - 1;
      K -= A - 1;
      // change
      N += (K / 2) * (B - A);
      N += K % 2;
    } else {
      // No change
      N += K;
    }
  } else {
    N += K;
  }

  cout << N << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
    if(N==i*j){
    ans = true;
    break;
    }
   }
  }
  if(ans){
    cout << "Yes"<< endl;
  }
  else{
    cout << "No"<< endl;
  }
}


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

const int MAX_N = 1e5 + 5, inf = 1e9 + 7;
int n;
int dp[MAX_N][3];

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		dp[i][0] = a + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c + max(dp[i - 1][0], dp[i - 1][1]);
	}

	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << "\n";
	return 0;
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func perm(head []string, rest []string) []string {
	var ans []string
	if len(rest) == 0 {
		return []string{strings.Join(head, "")}
	} else {
		for i, v := range rest {

			restx := make([]string, len(rest))
			copy(restx, rest)

			restx = append(restx[:i], restx[i+1:]...)
			headx := append(head, v)

			ans = append(ans, perm(headx, restx)...)
		}
	}
	return ans
}

func main() {
	var n int
	var p string
	var q string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a string
		fmt.Scan(&a)
		p = p + a
	}
	for i := 0; i < n; i++ {
		var a string
		fmt.Scan(&a)
		q = q + a
	}
	var a int
	var b int
	var nn []string
	for i := 0; i < n; i++ {
		nn = append(nn, strconv.Itoa(i+1))
	}
	pList := perm([]string{}, nn)
	for i, c := range pList {
		if c == p {
			a = i
		}
		if c == q {
			b = i
		}
	}
	if a > b {
		fmt.Println(a - b)
	} else {
		fmt.Println(b - a)
	}
}


Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main(){
  int n,x,t;
  cin>>n>>x>>t;
  if(n%x==0){
    int p=n/x;
    cout<<p*t;}
  else{
    int k=n/x;
    k++;
    cout<<k*t;}
  return 0;
}

Measured memory_bytes: 3592
n=io.read("*n")
s,sum,cnt={[0]=1},0,0
for i=1,n do
	a=io.read("*n")
	sum=sum+a
	if s[sum]==nil then s[sum]=0 end
	cnt=cnt+s[sum]
	s[sum]=s[sum]+1
end
print(cnt)

Measured memory_bytes: 9648
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	char ar[n+1];
	cin>>ar;
	k=0;
	for(i=1;i<n-1;i++){
		if(ar[i]=='B'){
			if(ar[i-1]=='A'&&ar[i+1]=='C'){
				k++;
			}
		}
	}
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        x: [u64; n],
    }
    let mut sorted_x = x.clone();
    sorted_x.sort();

    for i in 0..x.len() {
        println!(
            "{}",
            if x[i] > sorted_x[x.len() / 2 - 1] {
                sorted_x[x.len() / 2 - 1]
            } else {
                sorted_x[x.len() / 2]
            }
        );
    }
}


Measured memory_bytes: 7728
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;
  cin>>N;
  ll ans=0;
  if(N%2==1){
    ans=0;
  }
  else{
    ll i=10;
    while(N>=i){
      ans+=(N/i);
      i=i*5;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

void solve() {
  int n;
  int h = 0;
  cin >> n;
  int ret = 0;
  for(int i = 0; i < n; i++) {
    int curr;
    cin >> curr;
    if(curr >= h) {
      ret++;
      h = curr;
    }
  }
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


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

using namespace std;
typedef long long ll;


int N;
vector<vector<int>> to;
map<pair<int,int>,int> ans;
int Co = 1;

vector<int> AA, BB;


void dfs(int u, int v, int c){
    
    vector<bool> A(Co+1,true);
    A[c] = false;
    
    int cc = 1;
    int a,b;
    for(auto k : to[u]){
        if(k == v) continue;
        while (!A[cc]) cc++;
    
        a = u,b = k;
        if(a > b) swap(a,b);
        ans[{a,b}] = cc;
        A[cc] = false;
        dfs(k,u,cc);
        
    }
    
}


int main()
{
    cin >> N;
    to.resize(N);
    
    AA.resize(N);
    BB.resize(N);
    
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        to[a].push_back(b);
        to[b].push_back(a);
        AA[i] = a;
        BB[i] = b;
        ans[{a,b}] = 0;
    }
    rep(i,N){
        Co = max(Co,int(to[i].size()));
    }
    
    dfs(0,-1,0);
    
    cout << Co << endl;
    rep(i,N-1){
        cout << ans[{AA[i],BB[i]}] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 19456
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  cin >> n;
  int memo = 0;
  memo = sqrt(n * 2);
  int maxscore = 0;
  maxscore = n + 1;
  for(int i = memo - 1;i <= memo + 1;i++){
    if((1 + i) * i / 2 >= n){
      maxscore = min(i,maxscore);
    }
  }
  ll goukei = 0;
  goukei = (1 + maxscore) * maxscore / 2;
  //cout << goukei << endl;
  for(int i = 1;i <= maxscore;i++){
    if(i != goukei - n)cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
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, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
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 matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    A = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    left=[]
    cur=0
    for a in A:
        left.append(cur)
        cur=max(cur,a)
        
    cur=0
    right=[]
    for a in reversed(A):
        right.append(cur)
        cur=max(cur,a)
    for i in range(N):
        print(max(left[i],right[-i-1]))
    
    


if __name__ == "__main__":
    main()

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

#define maxn 2010
#define ll long long
#define mod 924844033

using namespace std;

int wsk;
ll dp[maxn][maxn][3], silnia[maxn];

void calculate_dp (int n, int k)
{
	dp[0][0][0]=1;
	for(int i = 1; i <= 2*k; ++i)
	{
		for (int j = i; j<=n; j+=2*k)
		{
			++wsk;
			silnia[wsk]=(silnia[wsk-1]*((ll)wsk))%mod;
			for (int x = 1; x<=wsk; ++x)
			{
				dp[wsk][0][0] = 1;
				if(wsk == 1)
				{
					if (j + k <=n)
						dp[wsk][1][1] = 1;
				}
				else if (i==j)
				{
					if(j - k <= 0)
					dp[wsk][x][0] = (dp[wsk-1][x][0] + dp[wsk-1][x][1])%mod;
					else
					dp[wsk][x][0] = (dp[wsk-1][x][0] + dp[wsk-1][x][1] + dp[wsk-1][x-1][0] + dp[wsk-1][x-1][1])%mod;
					if(j + k <= n)
					dp[wsk][x][1] = (dp[wsk-1][x-1][0] + dp[wsk-1][x-1][1])%mod;
				}
				else
				{
					dp[wsk][x][0] = (dp[wsk-1][x][0] + dp[wsk-1][x][1] + dp[wsk-1][x-1][0])%mod;
					if(j + k <= n)
					dp[wsk][x][1] = (dp[wsk-1][x-1][0] + dp[wsk-1][x-1][1])%mod;
				}
				//cout << dp[wsk][x][0] << " " << dp[wsk][x][1] << endl;
			}
		}
	}
}


ll ans (int n)
{
	ll odp = 0;
	for(int i = 0; i<=n; ++i)
	{
		if (i%2 == 0)
			odp = (odp + (((dp[n][i][0] + dp[n][i][1])%mod)*silnia[n-i])%mod)%mod;
		else
			odp = (mod + odp - (((dp[n][i][0] + dp[n][i][1])%mod)*silnia[n-i])%mod)%mod;
	}
	return odp;
}

int main()
{
	int n, k;
	cin >> n >> k;
	silnia[0]=1;
	calculate_dp (n, k);
	cout << ans(n);
	return 0;
}



Measured memory_bytes: 92672
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long cc;

cc a, b, c, Ans, i, j;
cc judge1=0, judge2=0, judge3;
string S;


int main() {
	cin >> S;
	for (i = 0; i < 3; i++) {
		for (j = i + 1; j < 4; j++) {
			if (S[i] == S[j])
				judge1 += 1;
		}
		if (judge1 == 1)
			judge2 += 1;
		judge1 = 0;
	}
	if(judge2==2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

		return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;
const ll INF = 100000000000000;

ll nibun_tansaku(ll x){
  ll left = 0;
  ll right = 45000;
  ll key = x;
  while(right - left > 1){
    ll mid = (left + right) / 2;
    ll mid_num = mid * (mid + 1) / 2;
    ll right_num = right * (right + 1) / 2;
    ll left_num = left * (left + 1) / 2;
    if(mid_num <= key ){
      left = mid;
    }else{
      right = mid;
    }
  }
  return left+1;
}

int main() {
  ll x;
  cin >> x;
  ll time = nibun_tansaku(x);
  ll ans = min(x, time);
  if(time * (time-1) / 2 == x){
    cout << time - 1 << endl;
    return 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)


n=int(input())

c={}
tree=[set([]) for _ in range(n)]

for _ in range(n-1):
    i,j,k=map(int,input().split())
    i-=1
    j-=1
    tree[i].add(j)
    tree[j].add(i)
    c[(min(i,j),max(i,j))]=k

result=[]
q,k=map(int,input().split())

memo=[-1]*n

def DEF(z,cnt):
    global memo,tree,c
    memo[z]=cnt
    for item in tree[z]:
        if memo[item]==-1:
            DEF(item,cnt+c[(min(item,z),max(item,z))])

DEF(k-1,0)
result=[]
for item in range(q):
    a,b=map(int,input().split())
    result.append(memo[a-1]+memo[b-1])

for item in result:
    print(item)







Measured memory_bytes: 191432
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

long long int gcd(long long int a, long long int b){
	if(b == 0)return a;
	return gcd(b,a % b);
}

long long int lcm(long long int a, long long int b){
	return a * b / gcd(a,b);
}

int main(){
	int a[3], m[3], p[3] = {1,1,1}, c[3] = {0};
	while(1){
		memset(c,0,sizeof(c));
		scanf("%d%d%d%d%d%d",a,m,a+1,m+1,a+2,m+2);
		if(!a[0])break;
		for(int i=0;i<3;i++){
			do{
			p[i] = a[i] * p[i] % m[i];
			c[i]++;
			}while(p[i] != 1);
		}
		cout << lcm(lcm(c[0],c[1]),c[2]) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
int main()
{
    int n;
    cin>>n;
    vector<int>a(n+1);
    for(int i=1;i<=n;i++)
        cin>>a[i];
    auto it=a.begin();
    it++;
    sort(it,a.end());
    cout<<a[n/2+1]-a[n/2]<<endl;
}

Measured memory_bytes: 888
#include<stdio.h>
int field[8][8]={0};
char sf[8][8]={0};
int x,y;
int dx[12]={0,0,0,0,0,0,-3,-2,-1,1,2,3};
int dy[12]={-3,-2,-1,1,2,3,0,0,0,0,0,0};

int chain(int x,int y){
    field[x][y]=0;
    for(int i=0;i<12;i++){
        if(field[x-dx[i]][y-dy[i]]==1&&0<=x-dx[i]&&x-dx[i]<=7&&0<=y-dy[i]&&y-dy[i]<=7){
            chain(x-dx[i],y-dy[i]);
        }
    }
    return 0;
}

int in(){
    for(int j=0;j<8;j++){
        scanf("%s",sf[j]);
    }
    return 0;
}

int che(){
    for(int j=0;j<8;j++){
        for(int k=0;k<8;k++){
            field[j][k]=sf[j][k]-'0';
        }
    }
    return 0;
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        in();
        che();
        scanf("%d%d",&y,&x);
        chain(x-1,y-1);
        printf("Data %d:\n",i+1);
        for(int j=0;j<8;j++){
            for(int k=0;k<8;k++){
                printf("%d",field[j][k]);
            }
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A[N];
  int n = 1;
  for(int i=0;i<N;i++){
  	cin >> A[i];
  }
  for(int i=0;i<n;i++){
   for(int k=0;k<N;k++){
     if(A[k]%2==0){
       A[k] /=2;
       if(k == N-1)
         n++;
     }else
       break;
   }
  }
  cout << n-1;
}

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

using namespace std;
using ll = long long;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum >= h) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define ALL(v) v.begin(), v.end()
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

using tpl = tuple<string, int, int>;

int main() {
	int N;
	cin >> N;
	vector<tpl> vec;
	string a;
	int b;
		REP(i, N) {
		cin >> a >> b;
		vec.push_back(make_tuple(a, -1*b, i+1));
	}
	sort(ALL(vec));
	for(auto x: vec) cout << get<2>(x) << endl;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> a(N+1);
    for (int i = 1; i <= N; i++) scanf("%lld", &a[i]);
    
    vector<ll> lsum(N+2, 0), rsum(N+2, 0);
    for (int i = 1; i <= N; i++) {
        lsum[i] = lsum[i-1] + max((ll)0, a[i]);
    }
    for (int i = N; i >= 1; i--) {
        rsum[i] = rsum[i+1] + max((ll)0, a[i]);
    }
    vector<ll> sum(N+2, 0);
    for (int i = 1; i <= K; i++) sum[K] += a[i];
    for (int i = K+1; i <= N; i++) sum[i] = sum[i-1] + a[i] - a[i-K];
    
    ll ans = 0;
    for (int i = K; i <= N; i++) {
        ans = max(ans, lsum[i-K]+rsum[i+1]);
        ans = max(ans, lsum[i-K]+rsum[i+1]+sum[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        char[] a = {'M', 'A', 'R', 'C', 'H'};
        int[] count = new int[5];
        int n = sc.nextInt();
        for(int i=0; i<n; i++) {
            String name = sc.next();
            for(int j=0; j<5; j++) {
                if(name.charAt(0) == a[j]) {
                    count[j]++;
                }
            }
        }
        BigDecimal res = new BigDecimal("0");
        for(int i=0; i<5; i++) {
            for(int j=i+1; j<5; j++) {
                for(int k=j+1; k<5; k++){
                    res = res.add(new BigDecimal((long)count[i] * count[j] * count[k]));
                }
            }
        }

        System.out.println(res.toPlainString());
    }

}


Measured memory_bytes: 46324
#include <bits/stdc++.h>
using namespace std;
int main()
{
 int64_t M,B,N,n,m,i;
  cin >> N >> M;
  m=M/2;
  for(i=1;i<=m;i++)
  {
    cout << i << " " << 2*m+2-i << endl;
  }
  m=(M+1)/2;
  for(i=1;i<=m;i++)
  {
    cout << 2*M+2-i << " " << 2*M-2*m+1+i << endl;
  }
  

  
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define FOR(i,x,y) for(int i=(x),i##END=(y);i<=i##END;++i)
#define DOR(i,x,y) for(int i=(x),i##END=(y);i>=i##END;--i)
template<typename T,typename _T>inline bool chk_min(T &x,const _T y){return y<x?x=y,1:0;}
template<typename T,typename _T>inline bool chk_max(T &x,const _T y){return x<y?x=y,1:0;}
typedef long long ll;
const int P=1e9+7;
const int N=100005;
template<const int maxn,const int maxm,typename T>struct LinkedList
{
	int head[maxn],nxt[maxm],tot;T to[maxm];
	LinkedList(){clear();}
	T &operator [](const int x){return to[x];}
	void clear(){memset(head,-1,sizeof(head)),tot=0;}
	void add(int u,T v){to[++tot]=v,nxt[tot]=head[u],head[u]=tot;}
	#define EOR(i,G,u) for(int i=G.head[u];~i;i=G.nxt[i])
};
struct edge{int to,p,q;};
struct Qry{int id,k,x,y;};
LinkedList<N,N<<1,edge>G;
LinkedList<N,N<<2,Qry>Q;
int dep[N],fa[N],sz[N],son[N],top[N];
int A[N],B[N];
ll Res[N];
int n,K;

void dfs(int u,int f,int d)
{
	dep[u]=d,fa[u]=f,sz[u]=1,son[u]=0;
	EOR(i,G,u)
	{
		int v=G[i].to;
		if(v==f)continue;
		dfs(v,u,d+1);
		sz[u]+=sz[v];
		if(sz[v]>sz[son[u]])son[u]=v;
	}
}

void hld(int u,int f,int tp)
{
	top[u]=tp;
	if(son[u])hld(son[u],u,tp);
	EOR(i,G,u)
	{
		int v=G[i].to;
		if(v==f||v==son[u])continue;
		hld(v,u,v);
	}
}

int get_lca(int x,int y)
{
	while(top[x]!=top[y])
	{
		if(dep[top[x]]<dep[top[y]])
			std::swap(x,y);
		x=fa[top[x]];
	}
	return dep[x]<dep[y]?x:y;
}

void DFS(int u,int f,int D)
{
	EOR(i,Q,u)
	{
		Qry q=Q[i];
		Res[q.id]+=q.k*(D-B[q.x]+A[q.x]*q.y);
	}
	EOR(i,G,u)
	{
		int v=G[i].to;
		if(v==f)continue;
		A[G[i].p]++;
		B[G[i].p]+=G[i].q;
		DFS(v,u,D+G[i].q);
		A[G[i].p]--;
		B[G[i].p]-=G[i].q;
	}
}

int main()
{
	scanf("%d%d",&n,&K);
	FOR(i,1,n-1)
	{
		int u,v,p,q;
		scanf("%d%d%d%d",&u,&v,&p,&q);
		G.add(u,(edge){v,p,q}),G.add(v,(edge){u,p,q});
	}
	dfs(1,0,1);
	hld(1,0,1);
	FOR(i,1,K)
	{
		int x,y,u,v;
		scanf("%d%d%d%d",&x,&y,&u,&v);
		Q.add(u,(Qry){i,1,x,y});
		Q.add(v,(Qry){i,1,x,y});
		Q.add(get_lca(u,v),(Qry){i,-2,x,y});
	}
	DFS(1,0,0);
	FOR(i,1,K)printf("%lld\n",Res[i]);
	return 0;
}


Measured memory_bytes: 20736
#include<iostream>
#include<cstring>
using namespace std;
char a[105];
int i,l;
bool f;
int main(){
	cin>>a;
	l=strlen(a);
	for(i=0;i<l;i++){
		if(a[i]=='C'){
			f=1;
		}    
		if(f==1&&a[i]=='F'){
			cout<<"Yes";
			return 0;
		}    
	}     
	cout<<"No";
	return 0;
}

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

using namespace std;

#define int long long

const int MOD = 1e9 + 7;

int k;

void solve(int n)
{
    cout << n << "\n";
    int a;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            a = (i + j) % n;
            if (i % 2) a += n;
            if (a >= k) a -= n;
            a++;
            cout << a << " ";
        }
        cout << "\n";
    }
}

signed main()
{
    cin >> k;
    if (k == 1) cout << "1\n1", exit(0);
    for (int n = 2; n <= 500; n += 2)
    {
        if (2 * n >= k)
        {
            solve(n);
            return 0;
        }
    }
}


Measured memory_bytes: 1152
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
*/

main:-
    get_number(A),
    get_number(B),
    (A =< 9, B =< 9) -> 
        (X is A * B, writeln(X)) ; 
        writeln("-1").


Measured memory_bytes: 8128
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N, M = map(int, input().split())
    S = input()[:-1][::-1]
    # print(S)

    res = []
    n = 0
    while n < N:
        miss = True
        for m in reversed(range(1,M+1)):
            if n+m < N+1 and S[n+m] == "0":
                n += m
                res.append(str(m))
                miss = False
                break
        if miss:
            print(-1)
            return
        
    print(" ".join(reversed(res)))

    


if __name__ == '__main__':
    main()

Measured memory_bytes: 75116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
const int N = 1e5+10;

int a[2001], n;

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

	cin >> n;
	for(int i=0;i<n;++i) cin >> a[i];
	sort(a, a+n);
	int ans = 0;
	for(int i=n-1;i>1;--i){
		for(int j=i-1;j;--j){
			int k = a[i] - a[j];
			int m = lower_bound(a, a+j, k+1) - a;
			ans += j-m;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<20)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n, d, num[15][15];
    cin >> n >> d;
    rep(i,n){
        rep(j,d){
            cin >> num[i][j];
        }
    }
    int count = 0;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++){
            int t = 0;
            rep(k,d){
                t += (num[i][k] - num[j][k]) * (num[i][k] - num[j][k]);
            }
            if(ceil(sqrt(t))==floor(sqrt(t)))
                count++;
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main()
{
	int N;
	cin >> N;
	long long lucas[N];
	lucas[0] = 2;
	lucas[1] = 1;

	FOR(i,2,N+1){
		lucas[i] = lucas[i-2] + lucas[i-1];
	}

	cout << lucas[N];

	return 0;
}


Measured memory_bytes: 256
def main():
    import copy
    from heapq import heappop, heapify, heappush
    import math
    N, K = map(int, input().split())
    A = [int(i) for i in input().split()]
    F = [int(i) for i in input().split()]
    ans = 0
    A.sort(reverse=True)
    F.sort()
    s = []
    for i in range(N):
        s.append([A[i]*F[i], A[i], F[i]])
    s.sort(reverse=True, key=lambda x: x[0])

    def f(S, T):
        cur = 0
        num = 0
        while cur <= K:
            if num == N:
                break
            a, b, c = S[num]
            if a <= T:
                break
            cur += math.ceil((a - T)/c)
            num += 1
        if cur <= K:
            return True
        else:
            return False

    ok, ng = s[0][0], -1
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2
        if f(s, mid) == True:
            ok = mid
        else:
            ng = mid
    print(ok)

if __name__ == '__main__':
    main()

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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


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

    vector<int> s(4);
    string d;
    for(int i=0;i<n;i++){
        cin>>d;
        if(d=="AC")s.at(0)++;
        else if(d=="RE")s.at(1)++;
        else if(d=="WA")s.at(2)++;
        else if(d=="TLE")s.at(3)++;
    }

    cout<<"AC x "<<s.at(0)<<endl;
    cout<<"WA x "<<s.at(2)<<endl;
    cout<<"TLE x "<<s.at(3)<<endl;
    cout<<"RE x "<<s.at(1)<<endl;
}



Measured memory_bytes: 3624
N=int(input())
c=list(map(str,input()))
#print(c)
W=0;R=0;w=0;r=0;p=0
for i in range(N):
  if c[i]=="W":
    W=W+1
R=len(c)-W
#print(R,W)
for i in range(R):
  if c[i]=="W":
    p=p+1
if W==0 or R==0:
  print(0)
else:
  print(p)

Measured memory_bytes: 10708
let quick_sort (a : (int * char * int) array) cmp =
  let rec partition p r =
    let swap i j = let t = Array.get a i in Array.set a i (Array.get a j); Array.set a j t
    in
    let rec exchange i j =
      if j >= r then (swap (i + 1) r; i + 1)
      else if cmp a.(j) a.(r) <= 0 then (swap (i + 1) j; exchange (i + 1) (j + 1))
      else exchange i (j + 1)
    in exchange (p - 1) p
  and doit p r =
    if p < r then begin
      let q = partition p r in
      doit p (q - 1);
      doit q r
    end in
  doit 0 (Array.length a - 1)

let stable_p (a : (int * char * int) array) n =
  let rec doit i =
    if i = n - 1 then true
    else if (fun (xi, _, xd) (yi, _, yd) -> xd = yd && xi > yi) a.(i) a.(i+1) then false
    else doit (i + 1)
  in doit 0

let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        doit s1 (String.sub s (i + 1) (String.length s - String.length s1 - 1) :: acc)
  in doit str []

let () =
  let n = read_int () in
  let a = Array.init n (fun i ->
    match split (read_line ()) ' ' with
    | [c; d] -> (i, c.[0], int_of_string d)
    | _ -> exit 1
  ) in
  quick_sort a (fun (_, _, x) (_, _, y) -> compare x y);
  print_endline (if stable_p a n then "Stable" else "Not stable");
  Array.iter (fun (_, c, d) -> Printf.printf "%c %d\n" c d) a

Measured memory_bytes: 8780
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdint>

using namespace std;

template<typename T>
class BIT {
private:
    uint32_t n;
    vector<T> vec;

public:
    BIT(uint32_t n) : n(n) {
        vec.resize(n+1);
        fill(vec.begin(), vec.end(), 0);
    }

    void add(uint32_t a, T x) {
        for (uint32_t i = a; i <= n; i += i & -i) vec[i] += x;
    }

    T sum(uint32_t a) {
        T sum = 0;
        for (uint32_t i = a; i > 0; i -= i & -i) sum += vec[i];
        return sum;
    }
};

int main() {
    int32_t n, q;
    scanf("%d %d", &n, &q);

    BIT<int32_t> bit(n);

    for (int32_t i = 0; i < q; i++) {
        int32_t com, x, y;
        scanf("%d %d %d", &com, &x, &y);

        if (com) printf("%d\n", bit.sum(y) - bit.sum(x-1));
        else bit.add(x, y);
    }

    return 0;
}

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

class Program
{
    static void Main()
    {
        var rd = new Reader();
        rd.Read().ToList().ForEach(delegate (string content)
        {
            List<string> result = new List<string>();
            int count = 0;
            Convert.ToString(int.Parse(content), 2).ToCharArray().Reverse().ToList().ForEach(delegate (char n)
            {
                if (n == '1')
                    result.Add(Math.Pow(2, count++).ToString());
                else
                    count++;
            });
            Console.WriteLine(string.Join(" ", result));
        });
    }
}
class Reader
{
    internal IEnumerable<string> Read()
    {
        string n;
        while (!string.IsNullOrEmpty(n = Console.ReadLine()))
        {
            yield return n;
        }
    }
}




Measured memory_bytes: 14324
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		Scanner cin=new Scanner(System.in);
		String t="CODEFESTIVAL2016";
		while(cin.hasNext()){
			String s=cin.nextLine();
			int n=s.length();
			int res=0;
			for(int i=0;i<n;i++){
				if(t.charAt(i)!=s.charAt(i))res++;
			}
			System.out.println(res);
			
		}
	}
}

Measured memory_bytes: 9680
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define endl "\n"

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

const int N = 1e6 + 7;
bool is_ans[N];// all false

void solve(vi& arr, int n) {
	map<int, int> mp;
	sort(arr.begin(), arr.end());
	for (auto x : arr)
		mp[x]++;
	int mx = arr[n - 1];

	for (int i = 0; i < n; i++) {
		int val = arr[i];
		for (int j = 2 * val; j <= mx; j += val)
			is_ans[j] = true;
	}


	int cnt = 0;
	for (auto x : arr)
		cnt += (mp[x] == 1 and !is_ans[x] ? 1 : 0);
	cout << cnt << endl;
}

signed main() {
	crap;

	int n;
	cin >> n;
	vi arr(n);
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
	}
	// cout << "hi";
	solve(arr, n);

	return 0;
}

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

namespace ABC177
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split(' ');
            var h = Console.ReadLine().Split(' ');
            List<int> H = h.Select(s => int.Parse(s)).ToList();
            List<int> peaks = Enumerable.Repeat(1, int.Parse(NM[0])).ToList();

            for (int i = 0; i < int.Parse(NM[1]); i++)
            {
                var AB = Console.ReadLine().Split(' ');
                if (H[int.Parse(AB[0]) - 1] < H[int.Parse(AB[1]) - 1])
                {
                    if (peaks[int.Parse(AB[0]) - 1] > 0)
                        peaks[int.Parse(AB[0]) - 1] = 0;

                    if (peaks[int.Parse(AB[1]) - 1] == 1)
                        peaks[int.Parse(AB[1]) - 1] = 2;
                }
                else if (H[int.Parse(AB[0]) - 1] > H[int.Parse(AB[1]) - 1])
                {
                    if (peaks[int.Parse(AB[0]) - 1] == 1)
                        peaks[int.Parse(AB[0]) - 1] = 2;

                    if (peaks[int.Parse(AB[1]) - 1] > 0)
                        peaks[int.Parse(AB[1]) - 1] = 0;
                }
                else if (H[int.Parse(AB[0]) - 1] == H[int.Parse(AB[1]) - 1])
                {
                    peaks[int.Parse(AB[0]) - 1] = 0;
                    peaks[int.Parse(AB[1]) - 1] = 0;
                }
            }

            System.Console.WriteLine(peaks.Count(p => p > 0));
        }
    }
}


Measured memory_bytes: 49536