akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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 const INF = 1001001001;


int N,M,Q,ans;
int a[55],b[55],c[55],d[55];

void dfs (vector<int> A,int v) {
    A.push_back(v);
    if(SZ(A) == N) {
        int cnt = 0;
        rep(i,Q) {
            if(A[b[i]] - A[a[i]] == c[i]) cnt += d[i];
        }
        chmax(ans, cnt);
    }
    else {
        for(int i = v; i <= M; ++i) {
            dfs(A, i);
        }
    }
}


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

cin >> N >> M >> Q;
rep(i,Q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
}

ans = 0;
rrep(i,M) dfs({}, i);
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
	long long a,b;
	int p=0;
	cin>>a>>b;
	while(a<=b)
	{
		a=a*2;
		p++;
	}
	cout<<p;
	return 0;
}

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

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mem(x, y) memset(x, y, sizeof x);
#define y1 asdgh
#define int long long
#define double long double
#define endl '\n'
//mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
//#pragma warning(disable:4996)
//#pragma comment(linker, "/STACK:336777216")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*------------------------------<Debugging Stuff>---------------------------------*/

template<class L, class R> ostream& operator<<(ostream &os, pair<L , R> P) {
      return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R , class M> ostream& operator<<(ostream &os, tuple<L , R , M> P) {
      return os << "(" << get<0>(P) << "," << get<1>(P) << "," << get<2>(P) << ")";
}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
      os << "{ "; for(auto v : V) os << v << " "; return os << "}";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

/*------------------------------</Debugging Stuff>--------------------------------*/
const int maxn = (int) 1e6 + 6;
const double EPS = 1e-9;
const int INF = (int) 1e18 + 18;
const int mod = (int) 1e9 + 7;

signed main() {
      
      fio;
      int n; cin >> n;
      vector<int> a(n);
      for(int &x : a) cin >> x;
      
      int cnt = 0;
      for(int i = 1; i < n - 1; i++){
            vector<int> tmp;
            for(int j = i - 1; j <= i + 1; j++){
                  tmp.push_back(a[j]);
            }
            sort(tmp.begin() , tmp.end());
            if(tmp[1] == a[i])
                  cnt++;
      }
      
      cout << cnt << endl;
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      return 0;
}

// IMPORTANT -:
// check base cases n = 0 , n = 1
// max / min questions - check for binary search
// difference array might be interesting


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
inline lint _max(lint a, lint b){ return a>b ? a : b; }
inline lint _min(lint a, lint b){ return a<b ? a : b; }

const int MOD = 1e9+7;
const int MAX = 200010;
const int INF = 2e9+10;


int n, cnt[64][32];

lint get_num(){
    lint res = 0;
    static char S[32];
    cin.getline(S, 32);
    int m = strlen(S);
    int p = m-1;
    for(int i=0; i<m; i++){
        if(S[i] == '.'){ p = i; continue; }
        res = res*10 + (S[i]-'0');
    }
    for(int i=0; i<9-(m-1-p); i++) res *= 10;
    return res;
}

int getm(lint x, lint m){
    int res = 0;
    while(x%m==0) x/=m, res++;
    return res;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    
    static char dum[4];
    cin>>n; cin.getline(dum, 4);

    lint ans = 0;
    for(int i=1; i<=n; i++){
        lint x = get_num();
        int c2 = getm(x, 2), c5 = getm(x, 5);

        for(int a=0; a<64; a++) for(int b=0; b<32; b++){
            if(a+c2>=18 && b+c5>=18)
                ans += cnt[a][b];
        }
        cnt[c2][c5]++;
    }
    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int tresult = 0;
		int hresult = 0;

		for(int i = 0; i < n; i++){
			String taro = scan.next();
			String hanako = scan.next();

			if(taro.compareTo(hanako) == 0){
				tresult++;
				hresult++;
			}else if(taro.compareTo(hanako) < 0){
				hresult += 3;
			}else if(taro.compareTo(hanako) > 0){
				tresult += 3;
			}
		}
		System.out.println(tresult + " " + hresult);
	}

}

Measured memory_bytes: 20812
#include<stdio.h>
int main(void)
{
	char s[3];
	int sum,i;
	sum=700;
	for(i=0;i<3;i++){
		scanf("%c",&s[i]);
		if(s[i]=='o'){
			sum+=100;
		}
	}
	printf("%d\n",sum);
	return 0;
}


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

int main(){
	string str;
	cin>>str;
	sort(str.begin(), str.end()); 
	if(str[0]==str[1] && str[2]==str[3] && str[1]!=str[2]){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <numeric>
using namespace::std;
int main(){

  string S;
  cin>>S;
  if(S[0]==S[1]&&S[1]==S[2]){
    cout<<"No";
  }else if(S[0]==S[1]){
    if(S[2]==S[3]){
      cout<<"Yes";
    }else{
      cout<<"No";
    }
  }else if(S[0]==S[2]){
    if(S[1]==S[3]){
      cout<<"Yes";
    }else{
      cout<<"No";
    }
  }else if(S[0]==S[3]){
    if(S[1]==S[2]){
      cout<<"Yes";
    }else{
      cout<<"No";
    }
  }else{
    cout<<"No";
  }
  
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type path struct {
	xy     rune
	num    int
	weight int
}

type paths []path

func (p paths) Len() int {
	return len(p)
}

func (p paths) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p paths) Less(i, j int) bool {
	return p[i].weight < p[j].weight
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	w, h := nextInt(), nextInt()
	var paths paths = make([]path, w+h)
	for wi := 0; wi < w; wi++ {
		p := nextInt()
		paths[wi] = path{'y', wi, p}
	}
	for hi := 0; hi < h; hi++ {
		p := nextInt()
		paths[w+hi] = path{'x', hi, p}
	}
	sort.Sort(paths)

	ans := 0
	xRemain, yRemain := w+1, h+1
	for _, p := range paths {
		switch {
		case p.xy == 'x':
			ans += p.weight * xRemain
			yRemain--
		case p.xy == 'y':
			ans += p.weight * yRemain
			xRemain--
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8704
N,M = map(int,input().split())
ab = []
for i in range(N):
    a,b = list(map(int,input().split()))
    a -= 1
    b -= 1
    ab.append([a,b])
cd = []
for i in range(M):
    c,d = list(map(int,input().split()))
    c -= 1
    d -= 1
    cd.append([c,d])
ans = []
for a,b in ab:
    dis = float('inf')
    for i in range(M):
        if dis > abs(cd[i][0]-a)+abs(cd[i][1]-b):
            dis = abs(cd[i][0]-a)+abs(cd[i][1]-b)
            ind = i
    ans.append(ind)
for i in ans:
    print(i+1)
            

Measured memory_bytes: 3064
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
int ar[100005];
bool check(){
  int c=*max_element(ar,ar+n);
  int c2=*min_element(ar,ar+n);
  if(c2==n-1) return true;
  c2=c-1;
  int cnt=0;
  REP(i,n) if(ar[i]==c2) ++cnt;
  if(cnt>=c) return false;
  int cnt2=n-cnt;
  int rest=c-cnt;
  if(cnt2<rest*2) return false;
  return true;
}
int main(){
  cin>>n;
  REP(i,n) scanf("%d",&ar[i]);
  puts(check()?"Yes":"No");
  return 0;
}





Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;
typedef long long ll;


int main(){
        ll N;
        cin >>N;
        map<ll, ll> A;
        ll a;
        for(ll i=0; i<N; i++){
                cin >> a;
                A[a]++;
                A[a-1]++;
                A[a+1]++;
        }
        ll Count = 0;
        for(auto v : A){
                if(Count < v.second) Count = v.second;
        }
        cout << Count;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 1e6 + 44;
const int X[] = {1,0,-1,0,1,-1,1,-1};
const int Y[] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9;

int a[N], dp[N];

int main () {
	boost;
	int n;
	cin >> n;
	for (int i = 0 ; i < n ; ++ i) {
		cin >> a[i];
	}
	for (int i = 1 ; i < n ; ++ i) {
		dp[i] = dp[i - 1] + abs (a[i] - a[i - 1]);
		if (i > 1)
			dp[i] = min (dp[i], dp[i - 2] + abs (a[i] - a[i - 2]));
	}
	cout << dp[n - 1];
}

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

#ifndef DEBUG
#define DEBUG false
#endif

#define REP(t,i,a,b) for(t i = a; i < b; ++i)
#define EREP(t,i,a,b) for(t i = a; i <= b; ++i)
#define REPR(t,i,a,b) for(t i = a; i > b; --i)
#define EREPR(t,i,a,b) for(t i = a; i >= b; --i)

typedef long long ll;

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;

int main (void) {
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    std::priority_queue<int> que;
    REP(int, i, 0, n) {
        int a;
        cin >> a;
        que.push(a);
    }

    while (m > 0) {
        int a = que.top();
        if (a == 0) break;

        que.pop();
        que.push(a/2);
        m --;
    }

    ll ans = 0;
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 892
def fix(c):
  return int(c) - 1

def bfs(x, order, visited):
  if visited[x]:
    return
  visited[x] = True
  for to in edges[x]:
    bfs(to, order, visited)
  order.append(x)

def bfs_rev(x, visited):
  if visited[x]:
    return []
  visited[x] = True
  ret = [x]
  for to in rev_edges[x]:
    ret = ret + bfs_rev(to, visited)
  return ret

def bfs2(x, visited):
  if visited[x]:
    return
  visited[x] = True
  for to in edges[x]:
    bfs2(to, visited)

while True:
  n = int(input())
  if n == 0:
    break
  edges = []
  score = []
  for _ in range(n):
    lst = input().split()
    score.append(float(lst[0]))
    edges.append(list(map(fix, lst[2:])))
  rev_edges = [[] for _ in range(n)]
  for i in range(n):
    for e in edges[i]:
      rev_edges[e].append(i)
  
  #帰りがけ順取得
  visited = [False] * n
  order = []
  for x in range(n):
    bfs(x, order, visited)
  order.reverse()
  
  #強連結成分分解
  visited = [False] * n
  cycles = []
  for x in order:
    if not visited[x]:
      cycle = bfs_rev(x, visited)
      cycles.append(cycle)

  visited = [False] * n
  ans = 1
  for x in order:
    if not visited[x]:
      for cycle in cycles:
        if x in cycle:
          acc = 1
          for node in cycle:
            bfs2(node, visited)
            acc *= score[node]
          ans *= (1 - acc)
  print("{0:.7f}".format(ans))


Measured memory_bytes: 5940
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;

ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }

int main() {
  ll n, k; cin >> n >> k; 
  Vll a(n); cin >> a;

  ll g = a[0];
  rep(i, n) g = gcd(a[i], g);

  bool ans = false;
  rep(i, n) if (a[i] >= k && k % g == 0) ans = true;

  cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
long long abs(long long n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  long long n;
  cin >> n;
  vector <long long> v(n);
  long long sum = 0;
  rep(i, n) {
    cin >> v.at(i);
    sum += v.at(i);
  }
  long long min = 2*(long long)pow(10, 9);
  long long tmp = 0;
  for (int i = 0; i < n-1; i++) {
    tmp += v.at(i);
    long long c = tmp-(sum-tmp);
    if (c < 0) {
      c = -c;
    }
    if (min > c) {
      min = c;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    string s;
    cin >> s;

    int left_c = -1;
    int right_f = -1;

    rep(i, s.size()){
        if(s[i] == 'C' && left_c==-1) left_c = i;
        if(s[i] == 'F') right_f = i;
    }

    if(left_c<right_f && left_c>=0 && right_f>=0) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$s = trim(fgets(STDIN));
$t = trim(fgets(STDIN));
$ans = "";
if($s===$t){
    $ans=$t;
}else{
    for($i=$n-1;$i>=0;--$i){
        $offsets=substr($s,$i);
        $offsett=substr($t,0,$n-$i);
        if($offsett===$offsets){
            $ans=$s.substr($t,$n-$i);
            break;
        }
    }
    
}
if($ans===""){
    $ans=$s.$t;
}
echo strlen($ans);
?>

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

int main(){
    int K, S;
    int counter = 0;
    cin >> K >> S;
    for (int i = 0; i <= K; i++){
        for (int j = 0; j <= K; j++){
            if((0 <= S - (i + j)) && (S - (i + j) <= K)){
                //cout << 1 << endl;
                //cout << i << j << endl;
                counter++;
            }
        }
    }
    cout << counter << endl;
}
// 00 01 10 11 20 02 

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N;
  string s;

  cin >> N >> s;

  int ans = 0;

  for (int i=0; i+2<s.size(); i++) {
    ans += s.substr(i, 3) == "ABC";
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main(){
	char a[110], b[110];
	cin >> a >> b;

	int c;
	if(strlen(a)>strlen(b)){ cout << "GREATER" << endl; return 0;	}
	if(strlen(a)<strlen(b)){ cout << "LESS" << endl; return 0; }

	for(int i=0; i<strlen(a); i++){
		if(a[i]<b[i]){ cout << "LESS" << endl; return 0; }
		if(a[i]>b[i]){ cout << "GREATER" << endl; return 0; }
	}

	cout << "EQUAL" << endl; 

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
 
using namespace std;
 
typedef long long ll;
 
#define MP make_pair
#define F first
#define S second
 
int main(){
	ll a[100001],b[100001],n;
  	fill(a,a+100001,0);
  	fill(b,b+100001,0);
  	cin >>n;
  	for(int i=0;2*i<n;i++){
    	ll tmp,tmp2;
      	cin >> tmp >> tmp2;
      	a[tmp]++; b[tmp2]++;
    }
  	ll afir=0,asec=0,bfir=0,bsec=0,argmaxa,argmaxb;
  	for(int i=0;i<100001;i++){
    	if(a[i]>afir){
          	asec=afir;
        	afir=a[i]; argmaxa=i;
        }else if(a[i]>asec){
         	asec=a[i];
        }
    }
  	for(int i=0;i<100001;i++){
    	if(b[i]>bfir){
          	bsec=bfir;
        	bfir=b[i]; argmaxb=i;
        }else if(b[i]>bsec){
         	bsec=b[i];
        }
    }
  	if(argmaxa==argmaxb){
      	ll ans=min(n-afir-bsec,n-bfir-asec);
    	cout << ans <<endl; 
    }else{
    	cout << n-afir-bfir << endl;
    }
}

Measured memory_bytes: 1792
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			int h = sc.nextInt();
			int w = sc.nextInt();
			
			System.out.println((n-h+1)*(n-w+1));

		}
	}
}

Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {

	public static int[][][] dp;
	public static char[] sCharArray;
	public static char[] tCharArray;
	public static StringBuilder builder;

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String sString = scan.nextLine();
		String tString = scan.nextLine();

		int sLength = sString.length();
		int tLength = tString.length();

		// 元となった座標も記録する 1:s-1,t-1 から 2:s-1,t から 3:s,t-1 から
		dp = new int[sLength + 1][tLength + 1][2];

		sCharArray = sString.toCharArray();
		tCharArray = tString.toCharArray();

		for (int s = 1; s < sLength + 1; s++) {

			for (int t = 1; t < tLength + 1; t++) {

				if (sCharArray[s - 1] == tCharArray[t - 1]) {

					dp[s][t][0] = dp[s - 1][t - 1][0] + 1;
					dp[s][t][1] = 1;

				} else {

					if (dp[s - 1][t][0] > dp[s][t - 1][0]) {

						dp[s][t][0] = dp[s - 1][t][0];
						dp[s][t][1] = 2;

					} else {

						dp[s][t][0] = dp[s][t - 1][0];
						dp[s][t][1] = 3;
					}
				}
			}
		}

		builder = new StringBuilder();
		restoration(sLength, tLength);
		System.out.println(builder.reverse().toString());
	}

	public static void restoration(int s, int t) {

		int record = dp[s][t][1];

		if (record == 1) {

			builder.append(sCharArray[s - 1]);
			restoration(s - 1, t - 1);

		} else if (record == 2) {

			restoration(s - 1, t);

		} else if (record == 3) {

			restoration(s, t - 1);
		}
	}
}


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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50

int main()
{
    int n, m;
    cin >> n >> m;
    set<int> s1;
    vi v;
    bool solve = 0;
    for(int i = 0 ; i<m; ++i)
    {
        int a, b;
        cin >> a >> b;
        if(a == 1)
        {
            s1.insert(b);
        }
        if(b == n)
        {
            v.pb(a);
        }

    }

    for(int i = 0; i < v.size(); ++i)
    {
        if(s1.count(v[i]))
        {
            solve = 1;
            break;
        }
    }

    if(solve)
    {
        cout << "POSSIBLE" << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 5368
a,b,c,d = gets.split(" ").map(&:to_i)

ac = a * c
bd = b * d
bc = b * c
ad = a * d

if (a < 0 && c < 0) && (b >= 0 && d >= 0)
  if ac.abs() >= bd.abs()
    puts ac
  else
    puts bd
  end
elsif a < 0 && c < 0
  puts ac
elsif b >= 0 && d >= 0
  puts bd
else
  if a < 0
    puts bc
  else
    puts ad
  end
end


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

int T, n, m;
ll d;
vector<string> v;


int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    C *= 2;
    ll ans = A * X + B * Y;
    ans = min(ans, C * max(X, Y));
    ans = min(ans, C * min(X, Y) + A * (X - min(X, Y)) + B * (Y - min(X, Y)));
    cout <<  ans << 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 ll = long long;
using P = pair<int,int>;
const int INF = 1000000001;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  queue<int> A, B, C;
  rep(i, s1.size()){
    A.push((int)(s1[i] - 'a'));
  }
  rep(i, s2.size()){
    B.push((int)(s2[i] - 'a'));
  }
  rep(i, s3.size()){
    C.push((int)(s3[i] - 'a'));
  }

  int next = A.front();
  A.pop();
  while(1){
    switch (next)
    {
    case 0:
      if(A.empty()){
        cout << "A" << endl;
        return 0;
      }
      else{
        next = A.front();
        A.pop();
      }
      break;
    case 1:
      if(B.empty()){
        cout << "B" << endl;
        return 0;
      }
      else{
        next = B.front();
        B.pop();
      }
      break;
    case 2:
      if(C.empty()){
        cout << "C" << endl;
        return 0;
      }
      else{
        next = C.front();
        C.pop();
      }
      break;    
    default:
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    public static void Main( )
    {
        string S = Console.ReadLine( );
        bool isRL, isR, isL;
        int[] chileds = new int[ S.Length ];

        // はじめにRにいる子供の動きを記録
        int countOfR = 1;   // その地点(i)の前までに連続しているRの個数
        for ( int i = 1; i < S.Length; i++ )
        {
            isR = S[ i ] == 'R';
            isRL = ( S[ i - 1 ] == 'R' ) & ( S[ i ] == 'L' );
            if ( isRL )
            {
                chileds[ i - 1 ] = countOfR % 2 == 0 ? countOfR / 2 : countOfR / 2 + 1;
                chileds[ i ] = countOfR / 2;
                countOfR = 0;
            }
            if ( isR ) countOfR++;
        }

        // Lにいる子供の動きを記録
        int countOfL = 1;
        for ( int i = S.Length - 2; i >= 0; i-- )
        {
            isL = S[ i ] == 'L';
            isRL = ( S[ i ] == 'R' ) & ( S[ i + 1 ] == 'L' );
            if ( isRL )
            {
                chileds[ i + 1 ] += countOfL % 2 == 0 ? countOfL / 2 : countOfL / 2 + 1;
                chileds[ i ] += countOfL / 2;
                countOfL = 0;
            }
            if ( isL ) countOfL++;
        }

        Console.WriteLine( string.Join( " ", chileds ) );


    }


}

Measured memory_bytes: 27608
#include <stdio.h>

int main(void) {
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if(b+c==a || c+a==b || a+b==c)
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}

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


int main(){
    int K, A, B;
    cin>>K>>A>>B;
    
    for(int i=A; i<=B; i++){
        if(i%K==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
int64_t M[21][21],Mat[21][21],I[21][21];
void mul(int64_t A[][21],int64_t B[][21]){
  int64_t C[21][21];
  memset(C,0,sizeof C);
  for(int i=0;i<21;++i){
    for(int j=0;j<21;++j){
      for(int k=0;k<21;++k){
        (C[i][j]+=A[i][k]*B[k][j]%MOD)%=MOD;
      }
    }
  }
  for(int i=0;i<21;++i)for(int j=0;j<21;++j)A[i][j]=C[i][j];
}
int64_t cal(int p){
  for(int i=0;i<21;++i)for(int j=0;j<21;++j)Mat[i][j]=M[i][j];
  memset(I,0,sizeof I);
  for(int i=0;i<21;++i)I[i][i]=1;
  while(p){
    if(p&1)mul(I,Mat);
    mul(Mat,Mat);
    p>>=1;
  }
  return I[20][0];
}
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  for(int i=0;i<10;++i){
    if(i%2==0)M[i][i+1]=1;
    else{
      for(int j=i-1;j>=0;j-=2)M[i][j]=1;
    }
  }
  for(int i=10;i<21;++i){
    for(int j=0;j<10;j+=2)M[i][j]=1;
    for(int j=10;j<=i;++j)M[i][j]=1;
  }
  int t;cin>>t;
  while(t--){
    int n;cin>>n;
    if(n<=4){
      cout<<0<<"\n";
    }else{
      cout<<cal(n-4)<<'\n';
    }
  }
  return 0;
}
//2020.07.23 21:38:20


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/range/algorithm.hpp>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 1;
  rep(i, n - 1) {
    if ((s[i] != s[i + 1])) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main () {
    int N, H[100001];
    cin >> N;
    for (int i=0;i<N;i++) cin >> H[i];
    long long S = 0;
    long long maxS = -1;
    if (N==1) {
         cout << "0\n";
         return 0;
    }

    for (int i=N-2;i>=0;i--) {
        if (H[i+1] <= H[i]) S++;
        else {
            S = 0;
        }
        maxS = max(maxS,S);
    }
    cout << maxS << '\n';
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn Agrawal coderbond007  PLEASE!! PLEASE!! HACK MY SOLUTION!!
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int aa = in.nextInt();
            int ab = in.nextInt();
            int ba = in.nextInt();
            int bb = in.nextInt();
            out.println(Math.max(0, Math.min(ab, bb) - Math.max(aa, ba)));
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            int res = 0;
            do {
                if (c == ',') {
                    c = pread();
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        private static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21588
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int N;
    cin >> N;
    for(int i = N; i <= 999; i++){
        if(i / 100 == i / 10 % 10 and i / 10 % 10 == i % 10){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  int a,b;cin >> a >> b;
  if(b<a) cout << a-1 << endl;
  else cout << a << endl;
  return 0;
}


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

int main(){
    map<char,int> dict;
    string w;
    cin>>w;
    size_t l=w.length();
    rep(i,l){
        dict[w[i]]++;
    }
    bool flag=true;
    for(auto iter=dict.begin();iter!=dict.end();iter++){
        if(iter->second%2==1) flag=false;
    }
    if(flag) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010
ll f(ll n){
	ll ans=0,k=n;
	while(n)ans+=(n/5),n/=5;
	return ans;
}
ll ff(ll n){
	if(n<=9)return 0;
	else if(n&1){
		return 0;
	}
	else{
		ll k=n/2;
		ll ans=f(k);
		return ans;
	}
}
ll g(ll n){
	ll cnt=0;
	while(n%10==0)cnt++,n/=10;
	return cnt;
}
int main(){
	IOS;
	
	ll n;cin>>n;
	cout<<ff(n);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <climits>
using namespace std;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    
    if ( a - b >= 0 ) {
        cout << "delicious" << endl;
    } else if ( b - a <= x ) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
    
    return 0;
}

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

using namespace std;

int main()
{
	const int values[4]={10,50,100,500};
	
	bool first=true;
	for(int pay,coins[4];cin>>pay,pay;first=false){
		if(!first) cout<<endl;
		for(int i=0;i<4;i++) cin>>coins[i];
		
		int money=inner_product(coins,coins+4,values,0);
		int rest=money-pay;
		
		int counts[4]={};
		for(int i=3;i>=0;i--){
			counts[i]=rest/values[i];
			rest%=values[i];
		}
		for(int i=0;i<4;i++) if(coins[i]-counts[i]>0)
			cout<<values[i]<<' '<<coins[i]-counts[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1156
n = int(input())
wl = list(map(int,input().split()))

ans = 10000000

for t in range(n-1):
    #print('ループ{}回目',t+1)
    s1 = sum(wl[:t+1])
    #print('s1 = {}',s1)
    s2 = sum(wl[t+1:])
    #print('s2 = {}',s2)
    if abs(s2-s1) < ans:
        ans = abs(s2-s1)

print(str(ans))

Measured memory_bytes: 3060
#include <stdio.h>

void main(){
	char a[100];
	int alphabet[26]={0*26};
	int i=0;
	scanf("%s",a);
	while (a[i]!='\0'){
		alphabet[a[i]-'a']++;
		//printf("%d\n",a[i]-'a');
		//printf("%d\n",alphabet[a[i]-'a']);
		i++;
	}
	for (i=0;i<26;i++){
		if (alphabet[i]%2){
			printf("No\n");
			return;
		}
	}
	printf("Yes\n");
}

Measured memory_bytes: 128
#include <iostream>

int main(){
  int n, q, t, cnt, u, l;
  int str[100000];
  std::cin >> n;
  for(int i = 0; i < n; i++){
    std::cin >> str[i];
  }
  std::cin >> q;
  cnt = 0;

  for(int i = 0; i < q; i++){
    std::cin >> t;
    u = -1;
    l = n;
    while(l - u != 1){
      if(str[(u + l) / 2] > t) l = (u + l) / 2 + (u + l) % 2;
      else u = (u + l) / 2;
    }
    if(str[u] == t || str[l] == t) cnt++;
  }
  std::cout << cnt << std::endl;
}


Measured memory_bytes: 3496
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000009

int main(){
  int n;
  int ans=0;
  cin>>n;
  int a[200009];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int mi=INF;
  for(int i=0;i<n;i++){
    mi=min(mi,a[i]);
    if(mi>=a[i])ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n;   cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    sort(ALL(v));
    ll res=0;
    rep(i, n){
        FOR(j, i+1, n){
            FOR(k, j+1, n){
                ll a=v[i], b=v[j], c=v[k];
                if(a!=b && b!=c){
                    if(a+b>c && b+c>a && c+a>b) res += 1;
                }
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3600
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double t = sc.nextDouble();
    double a = sc.nextDouble();
    int ans = 0;
    double sa = 1000000;
    for(int i = 0; i < n; i++) {
      double h = sc.nextDouble();
      double s = Math.abs(a - (t - h * 0.006));
      if(s < sa) {
        sa = s;
        ans = (i + 1);
      }
    }
    System.out.println(ans);
  }
}

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

#define ll long long
#define pb push_back
#define fi first
#define se second
using namespace std;
const ll N = 5e5 +9;

ll a, b[N], c, n, mn=9999999, mx=-999999;

int main(){
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> b[i];
    }
    sort(b+1,b+n+1);
    cout<<b[n]-b[1];



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[200001];
int len,ans,sum;
int main() {
	gets(s);
	len=strlen(s);
	for(int i=0;i<len;i++){
		if(s[i]=='S')sum++;
		if(sum&&s[i]=='T'){
			sum--;
			ans+=2;
		}
	}
	printf("%d\n",len-ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

int main() {
    string s; cin >> s;
    int n = (int)s.size();
    if(n==2){
      if(s[0]==s[1]) cout << 1 << " " << 2 << '\n';
      else cout << -1 << " " << -1 << '\n';
      return 0;
    }
    REP(i,n-2) {
        if(s[i]==s[i+1] || s[i]==s[i+2] || s[i+1]==s[i+2]) {
            cout << i+1 << ' ' << i+3 << '\n';
            return 0;
        }
    }
    cout << -1  << ' ' << -1 << '\n';

    return 0;
}

Measured memory_bytes: 512
#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

#[allow(unused_macros)]
macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } }
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }
    let (h, w) = readl!(usize, usize);
    let mut c: Vec<_> = (0..10).map(|_| readlvec!(i32)).collect();
    for k in 0..10 {
        for i in 0..10 {
            for j in 0..10 {
                c[i][j] = min(c[i][k]+c[k][j], c[i][j]);
            }
        }
    }
    let a: Vec<_> = (0..h).map(|_| readlvec!(i32)).collect();
    let ans: i32 = a.into_iter().map(|row| {
        row.into_iter().filter(|&x| x != -1).map(|x| c[x as usize][1]).sum::<i32>()
    }).sum();
    printfln!("{}", ans);
}



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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

struct data{int h, w; };

namespace std
{
  inline bool operator < (const data& a, const data& b)
  {
    return a.h*a.h+a.w*a.w!=b.h*b.h+b.w*b.w ? a.h*a.h+a.w*a.w<b.h*b.h+b.w*b.w : a.h < b.h;
  }
}

vector<data> g;
int h, w;

int main()
{
  erep(i, 1, 200) erep(j, i+1, 200) g.pb((data){i, j});
  sort(ALL(g));

  while(cin >> h >> w, h){
    data res = *upper_bound(ALL(g), (data){h, w});
    cout << res.h << ' ' << res.w << endl;
  }

  return 0;
}

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

int main() {
  vector<int> abc(3);
  for (int i = 0; i < 3; i ++) {
    cin >> abc.at(i);
  }

  sort(abc.begin(), abc.end());
  int ans = abc.at(2) - abc.at(1);
  abc.at(0) += ans;
  if ((abc.at(2) - abc.at(0)) % 2 == 0) {
    ans += (abc.at(2) - abc.at(0)) / 2;
  } else {
    ans += (abc.at(2) - abc.at(0)) / 2 + 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long N;
    cin >> N;
    string out = "";
    char smla = 'a';
 
    while((N - 1) / 26) {
        long long n = N - 1 / 26;
        n = N % 26;
        if(n == 0) {
            out += 'z';
        } else {
            out += (smla + n - 1);
        }
        //cout << n << endl;
        N = (N - 1) / 26;
        //cout << N << endl;
    }
    long long n  = N;
    n = (n);
    if(n == 0) {
    } else {
        out += (smla + n - 1);
    }
    reverse(out.begin(), out.end());
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3628
(stdin => {
  // Define Function
  const area = a => b => a * b
  const perimeter = a => b => (a + b) * 2  

  // Declare Variable
  const inputs = stdin.toString().trim().split(' ')

  const x = Number(inputs[0])
  const y = Number(inputs[1])

  console.log([area(x)(y), perimeter(x)(y)].join(' '))

})(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 15096
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
inline i64 Calc(i64 x, i64 p) {
    return x / p;
}
int n;
i64 a, b, c, d, res, p;
int main() {
    cin >> a >> b;
    n = 2;
    vector<i64> v(n);
    for (i64& x : v) {
        cin >> x;
        res += (Calc(b, x) - Calc(a - 1, x));
    }
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j) {
            p = v[i] * v[j] / __gcd(v[i], v[j]);
            res -= (Calc(b, p) - Calc(a - 1, p));
        }
    res = (b - a + 1) - res;
    cout << res;
    return 0;
}


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

const int maxn=1e5+10;
int n,m;
vector<int> vec[maxn];

int main(){
	cin>>n;
	while(m*(m-1)/2<n)
		++m;
	if(m*(m-1)/2>n){
		puts("No");
		return 0;
	}
	puts("Yes");
	for(int i=1,k=0;i<=m;++i)
		for(int j=i+1;j<=m;++j)
			vec[i].push_back(++k),vec[j].push_back(k);
	printf("%d\n",m);
	for(int i=1;i<=m;++i){
		printf("%d ",m-1);
		for(int j=0;j<vec[i].size();++j)
			printf("%d ",vec[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
int d[100];
int n, m;
int main() {
	int u, v;
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;++ i) {
		scanf("%d%d",&u,&v);
		d[u] ++; d[v] ++; 
	}
	for(int i = 1;i <= n;++ i) {
		printf("%d\n",d[i]);
	}
	return 0;
} 

Measured memory_bytes: 384