akhauriyash/Code-Regression huggingface dataset:
/*****************************************************

@author: vichitr

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 2e5+7;
const ll inf = 1e17;

int pwr(int x, int y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r % MOD;
}

int inv(int x)
{
    return pow(x, MOD-2);
}
vector<int> adj[N];
bool vis[N];
int c[N], d[N], score, idx;

int solve(string s)
{
	if(s.size()==0)
		return 0;
	int c= 0, n = s.size();

	int ans = 0;
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='D')
		{
			c++;
		}
		else
			ans += c;

	}
	return ans;
}

void solve()
{
    int n;
    string s; cin>>s;
    n = s.size();
    string t;
    for(int i=0;i<n;)
    {
    	if(i+1<n and s[i]=='B' and s[i+1]=='C'){
    		i+=2;
    		t+='D';
    	}
    	else{
    		t+=s[i];
    		i++;
    	}

    }
    // cout<<t<<endl;
    int ans = 0;
    n = t.size();
    s = "";
    for(int i=0;i<n;i++)
    {
    	if(t[i]=='A' or t[i]=='D')
    		s+=t[i];
    	else{
    		ans += solve(s);
    		s = "";
    	}
    }
    ans += solve(s);
    cout<<ans;
}

signed main()
{
    fast;
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t=1;
    // cin >>t;
    while(t--){
        solve();
    }
    return 0;
}

/*****************************


****************************/

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

using namespace std;

int main(void){
  int middle,final,retest,grade,num=0;
  vector<vector<int>> vec(3);
  while(true){
    cin>>middle>>final>>retest;
    if(middle+final+retest==-3) break;
    num++;
    vec.at(0).push_back(middle);
    vec.at(1).push_back(final);
    vec.at(2).push_back(retest);
  }

  for(int i=0;i<num;i++){
    if((vec.at(0).at(i)==-1)||(vec.at(1).at(i)==-1)){
      cout<<"F"<<endl;
      continue;
    }
    grade=vec.at(0).at(i)+vec.at(1).at(i);
    if(grade>=80) cout<<"A"<<endl;
    else if(grade>=65) cout<<"B"<<endl;
    else if(grade>=50) cout<<"C"<<endl;
    else if(grade>=30){
      if(vec.at(2).at(i)>=50) cout<<"C"<<endl;
      else cout<<"D"<<endl;
    }
    else cout<<"F"<<endl;
  }
  return 0;

}



Measured memory_bytes: 3140
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a = 0;
  rep(i, 0, 2){
    char c;
    cin >> c;
    if(c == '9'){
      a++;
    }
  }
  if(a == 0){
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
}

Measured memory_bytes: 3552
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Mon Dec 17 17:56:12 2018
//
package main

import (
	"fmt"
	"sort"
)

type city struct {
	pref, year, no int
}

type cities []city

func (c cities) Len() int {
	return len(c)
}

func (c cities) Swap(i, j int) {
	c[i], c[j] = c[j], c[i]
}

func (c cities) Less(i, j int) bool {
	if c[i].pref == c[j].pref {
		return c[i].year < c[j].year
	}
	return c[i].pref < c[j].pref
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	cs := make(cities, M)
	for i := range cs {
		fmt.Scan(&cs[i].pref, &cs[i].year)
	}

	cs2 := make(cities, len(cs))
	copy(cs2, cs)
	sort.Sort(cs)

	count := 1
	for i := range cs {
		if i > 0 && cs[i-1].pref != cs[i].pref {
			count = 1
		}
		cs[i].no = count
		count++
	}

	for _, c := range cs2 {
		lower := sort.Search(len(cs), func(i int) bool {
			return cs[i].pref >= c.pref
		})
		upper := sort.Search(len(cs), func(i int) bool {
			return cs[i].pref >= c.pref+1
		})
		prefs := cs[lower:upper]

		index := sort.Search(len(prefs), func(i int) bool {
			return prefs[i].year >= c.year
		})
		fmt.Printf("%06d%06d\n", prefs[index].pref, prefs[index].no)
	}
}


Measured memory_bytes: 9860
#include <stdio.h>
#include <stdlib.h>
struct tree{
  int key;
  struct tree *parent;
  struct tree *left;
  struct tree *right;
};
struct tree *T,*NIL;
void insert(struct tree *);
struct tree *find(int);
struct tree *getMin(struct tree *);
struct tree *getSuccessor(struct tree *);
void delete(int);
void inorder(struct tree *);
void preorder(struct tree *);
int main(){
  int n,k,i;
  char command[10],a;
  struct tree *A;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%c",command,&a);
    if(!strcmp(command,"insert")){
      scanf("%d",&k);
      A=malloc(sizeof(struct tree));
      A->key=k;
      A->left=NIL;
      A->right=NIL;
      insert(A);
    }
    else if(!strcmp(command,"print")){
      inorder(T);
      printf("\n");
      preorder(T);
      printf("\n");
    }
    else if(!strcmp(command,"delete")){
      scanf("%d",&k);
      delete(k);
    }
       else if(!strcmp(command,"find")){
      scanf("%d",&k);
      A=find(k);
      if(A->key==k)printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

void insert(struct tree *z){
  struct tree *x,*y;
  x=T;
  y=NIL;
  while(x!=NIL){
    y=x;
    if(x->key>z->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL){
    T=z;
  }
  else {
    if(y->key<z->key)y->right=z;
    else y->left=z;
  }
}
void inorder(struct tree *A){
  if(A==NIL)return;
  inorder(A->left);
  printf(" %d",A->key);
  inorder(A->right);
}
void preorder(struct tree *A){
  if(A==NIL)return;
  printf(" %d",A->key);
  preorder(A->left);
  preorder(A->right);
}
struct tree *find(int k){
  struct tree *x=T;
  while(x!=NIL){
    if(x->key==k)return x;
    else if(k<x->key)x=x->left;
    else x=x->right;
  }
  return T;
}
void delete(int k){
  struct tree *x,*y,*z;
  z=find(k);
  if(z->left==NIL||z->right==NIL)y=z;
  else y=getSuccessor(z);
  if(y->left!=NIL)x=y->left;
  else x=y->right;
  if(x!=NIL)x->parent=y->parent;
  if(y->parent==NIL)T=x;
  else if(y==y->parent->left)y->parent->left=x;
  else y->parent->right=x;
  if(y!=z)z->key=y->key;
}
struct tree *getSuccessor(struct tree *z){
  struct tree *x,*y;
  if(z->right!=NIL)return getMin(z->right);
  y=x->parent;
  while(y!=NIL&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}
struct tree *getMin(struct tree *z){
   while(z->left!=NIL){
    z=z->left;
  }
  return z;
}




Measured memory_bytes: 20432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll n,k,x,y,sum,ans,mod=1e9+7,a[2005];
int main(){
	n=read(),k=read();
	for(int i=0;i<n;i++)
		a[i]=read();
	x=(k*(k-1)/2)%mod;
	y=(k*(k+1)/2)%mod;
	for(int i=0;i<n;i++){
		for(int j=0;j<i;j++)
			if(a[j]<a[i])sum++;
		(ans+=sum*x)%=mod,sum=0;
		for(int j=i+1;j<n;j++)
			if(a[j]<a[i])sum++;
		(ans+=sum*y)%=mod,sum=0;
	}
	cout << ans;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > vp(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    vp.at(i) = make_pair(a, b);
  }
  sort(vp.begin(), vp.end());
  for (int i = 0; i < n; i++) {
    cout << vp.at(i).first << " " << vp.at(i).second << endl;
  }
}


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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int a[100];
    int m = 0;
    int n;cin>>n;
    int sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }
    //cout << (double)(sum/n) << endl;
    m = round((double)sum/n);
	int out = 0;
    //cout << m << endl;
    rep(i, n){
        out += (a[i]-m)*(a[i]-m);
    }
    cout << out << endl;
	return 0;
}


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

int main(void){
  int a, b, c, x, y, ans;
  scanf("%d %d %d %d %d",&a, &b, &c, &x, &y);
  if(a+b<=2*c) ans = a*x+b*y;
  else{
    if(x < y){
      if(2*c < b) ans = 2*c*y;
      else ans = 2*c*x+b*(y-x);
    }else{
      if(2*c < a) ans = 2*c*x;
      else ans = 2*c*y+a*(x-y);
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<cstdlib>
#include<ctime>
#include<set>
#include<bitset>
#include<map>
#include<iostream>
#define ll long long
#define rep(i,a,b) for(register ll i=a;i<=b;++i)
#define fd(i,a,b) for(register int i=a;i>=b;--i)
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define Abs(a) ((a<0)?-(a):(a))
namespace io{
    char buf[1<<17],*p1=buf,*p2=buf;
    inline int getc(){
         return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<17,stdin),p1==p2)?EOF:*p1++;
    }
    template<class T>
    inline void Read(T &x){
        x=0;T f=1;char c;
        for(c=getc();c<'0'||c>'9';f=((c=='-')?-1:f),c=getc());
        for(;c>='0'&&c<='9';x=x*10+(c^48),c=getc());
        x*=f;
    }
    template<class T>
    inline void write(T a){
        if(a==0){putchar('0');return;}
        if(a<0)putchar('-'),a=-a;
        char c1[120];
        int h=0;
        while(a)c1[++h]=a%10+'0',a/=10;
        for(int i=h;i>=1;i--)putchar(c1[i]);
        return;
    }
    template<class T>
    inline void write_(T a){write(a);putchar(' ');}
    template<class T>
    inline void writeln(T a){write(a);putchar('\n');}
}
using namespace io;
template<class T>
inline T gcd(T a,T b){return a==0?b:gcd(b%a,a);}
template<class T>
inline T lcm(T a,T b){return 1ll*a/gcd(a,b)*b;}
/*----------------------------------------------------------------------*/
int n, a, b;


int main(){
	Read(n);Read(a);Read(b);
	writeln(std::min(n * a, b));
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,n,x,a[100000],candy[100000];
  long result=0;
  
  scanf("%d %d",&n,&x);
  for(i=0;i<n;i++){
    scanf("%d",&candy[i]);
    a[i]=candy[i];
  }
  
  for(i=0;i<n-1;i++){
    if(a[i]>x){
      a[i]=x;
    }
    
    if(a[i]+a[i+1]>x){
      a[i+1]=(x-a[i]);
    }
  }
  
  for(i=0;i<n;i++){
    result+=(candy[i]-a[i]);
  }
  
  printf("%ld",result);
}

Measured memory_bytes: 896
// AtCoder Regular Contest 066
// C - Lining Up

#include <cstdio>
#include <algorithm>
#define MAX_N 100000
#define MOD ((ll)1e9 + 7)
using namespace std;
typedef long long int ll;


int N;
int a[MAX_N];
ll ans;

int main() {

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

  sort(a, a + N);

  ans = 1;
  for (int i = 0; i < N; i++) {
    if (a[i] != (i + N % 2) / 2 * 2 + (N + 1) % 2) {
      ans = 0;
      break;
    }
    ans *= (i % 2 == 1) ? 2 : 1;
    ans %= MOD;
  }

  printf("%lld\n", ans);

  return 0;

}




Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int H = sc.nextInt();
    int W = sc.nextInt();
    char[][] f = new char[H][W];
    for (int i = 0; i < H; i++) {
      f[i] = sc.next().toCharArray();
    }
    int cr = 0;
    int cc = 0;
    while (cr < H - 1 || cc < W - 1) {
      boolean right = cc < W - 1 && f[cr][cc + 1] == '#';
      boolean bottom = cr < H - 1 && f[cr + 1][cc] == '#';
      boolean left = cc > 0 && f[cr][cc - 1] == '#';
      boolean up = cr > 0 && f[cr - 1][cc] == '#';
      if (right == bottom || left || up) {
        System.out.println("Impossible");
        return;
      }
      f[cr][cc] = '.';
      if (right) {
        ++cc;
      } else {
        ++cr;
      }
    }
    if (f[cr][cc - 1] == '#' || f[cr - 1][cc] == '#') {
      System.out.println("Impossible");
    } else {
      System.out.println("Possible");
    }
  }

}


Measured memory_bytes: 10188
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;

const int height = 51, width = 51;

void count_bomb(int i, int j, int h, int w, char s[height][width])
{
    int cnt = 0;
    for (int x = i-1; x <= i+1; x++) {
        for (int y = j-1; y <= j+1; y++) {
            if ((x >= 0 && x < h) && (y >= 0 && y < w)) {
                if (s[x][y] == '#') cnt++;
            }
        }
    }
    cout << cnt;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;

    char s[height][width];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                cout << '#';
            } else {
                count_bomb(i, j, h, w, s);
            }
        }
        cout << endl;
    }
    return 0;
}


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

int main()
{
    string S,T;
    int A,B;
    string U;

    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if(S == U)
    {
        cout << A-1 << ' ' << B;
    }
    else if(T == U)
    {
        cout << A << ' ' << B - 1;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
const int maxval = 1e5;
ll mod = 1e9+7;
ll fact[maxval+1];
ll factinv[maxval+1];

ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;

        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;

        // Update y and x
        y = x - q * y;
        x = t;
    }

    // Make x positive
    if (x < 0)
       x += m0;

    return x;
}

ll findncr(int n,int r)
{
    return (fact[n]%mod * factinv[n-r]%mod * factinv[r]%mod)%mod ;
}

int main()
{
    fast
    int t=1;
    // cin >> t;
    fact[0] = 1;
    fact[1] = 1;
    for(int i=2; i<=maxval; i++){
        fact[i] = (fact[i-1]%mod * i%mod )%mod;
    }

    for(int i=0; i<=maxval; i++){
        factinv[i] = modInverse(fact[i],mod);
    }

    while(t--){
        int n,k;
        cin >> n >> k;
        ll a[n];
        for(int i=0; i<n; i++) cin >> a[i];
        ll res = 0;
        sort(a,a+n);
        k--;
        for(int i=n-1; i>=0; i--){

            if(i >= k){
                res = (res%mod + (a[i]%mod * findncr(i,k)%mod)%mod)%mod;
            }

            if(n-1-i >= k){
                res = (res%mod - (a[i]%mod * findncr(n-1-i,k)%mod)%mod)%mod;
            }
        }

        cout << res;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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 pw(ll a, ll m, ll P) {
    if (m == 0) return 1ll;
    long long res = pw((a * a) % P, (m / 2), P) % P;
    return m % 2 ? res * a % P : res;
}

void solve(long long N, long long P, string S) {
    if (P == 5 || P == 2) {
        long long ans = 0;
        for (int i = 0; i < S.size(); i++) {
            if ((S[i] - '0') % P == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return;
    }
    long long geta = 1;
    map<long long, int> c;

    long long cnt = 0;
    long long tot = 0;
    c[0] = 1;
    for (int i = 0; i < S.size(); i++) {
        geta *= 10;
        geta %= P;

        tot = tot * 10 + S[i] - '0';
        tot %= P;
        long long key = tot * pw(geta, P - 2, P) % P;
        cnt += c[key];
        c[key]++;
    }
    cout << cnt << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long P;
    scanf("%lld", &P);
    string S;
    cin >> S;
    solve(N, P, S);
    return 0;
}


Measured memory_bytes: 1284
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

bool solve() {
    int N;
    cin >> N;
    int max_n = N / 100;
    for(int i = 1; i <= max_n; i++) {
        int rest = N - 100 * i;
        if(0 <= rest && rest <= 5 * i) return true;
    }
    return false;
}

int main() {
    cout << (solve() ? 1 : 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int mn,n;
int x[34],arr[34];
void recur(int pos,int cost,int cur,int used[])
{
    if(pos==3)
    {
        mn=min(mn,cost);
        return;
    }
    if(cur==0)
    {
        for(int i=0; i<n; i++)
        {
            if(!used[i])
            {
                used[i]=1;
                recur(pos,cost,arr[i],used);
                used[i]=0;
            }
        }
    }
    else
    {
        int need=x[pos]-cur;
        if(need>10)
        {
            for(int i=0; i<n; i++)
            {
                if(used[i]==0)
                {
                    used[i]=1;
                    recur(pos,cost+10,cur+arr[i],used);
                    used[i]=0;
                }
            }
        }
        recur(pos+1,cost+abs(need),0,used);
    }
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);

    cin>>n;
    for(int i=0; i<3; i++)
        cin>>x[i];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    int used[50]= {0};
    mn=INT_MAX;
    recur(0,0,0,used);
    cout<<mn<<endl;


    return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    static Scanner sc;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        int R = A - 2*B;
        if(R < 0) {
            System.out.println("0");
        } else {
            System.out.println(R);
        }
    }


}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
typedef unsigned long long uint64;
using namespace std;
int main(){
 long int a;
 long double b;
 cin >> a>> b;
 long long y = round(b*100);
 cout << a*y/100 << endl;
return 0;
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
int a,b,t;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>a>>b>>t;
	int i=a;
	int res=0;
	while(i<=t){
		res+=b;
		i+=a;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
object Main {
  def setTrain(t1: String, t2: String): List[String] = {
    (for(x <- List(t1, t1.reverse); y <- List(t2, t2.reverse)) yield {
      List(List(x, y), List(y, x)).map(_.mkString)
    }).flatten
  }

  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    for(_ <- 1 to n) {
      val s = sc.next
      val set = scala.collection.mutable.ArrayBuffer.empty[String] 
      for(len <- 1 to s.length - 1) {
        val t1 = s.take(len)
        val t2 = s.drop(len)
        setTrain(t1, t2).foreach(t =>
          if (!set.contains(t)) set += t)
      }
      println(set.size)
    }
  }
}

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

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

int main()
{
	int T=1;
	// cin >> T ;

	while(T--)
	{
		int n,r ;
		cin>>n>>r ;
		int h[n+1] ;
		for(int i=1 ; i<=n ; i++)
			cin>>h[i] ;

		int dp[n+1] ;
		dp[0]=0 ;
		dp[1]=0 ;

		for(int i=2 ; i<=n ; i++)
		{
			dp[i]=1e9 ;

			for(int k=i-1 ; k>max((i-r-1),0) ; k-- )
			{
				dp[i]=min(dp[i] , abs(h[i]-h[k])+dp[k]) ;
			}
		}
		cout<<dp[n]<<endl ;
	}
	return 0;
}

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

typedef long long int int64;
int64 dp[5003][5003],dp2[5003];
int64 a,b;
int n;
int p[5003],ip[5003];
int main()
{
	scanf("%d%lld%lld",&n,&a,&b);
	for(int i = 1;i <= n;++i) {
		scanf("%d",&p[i]);
		ip[p[i]] = i;
	}
	memset(dp,-1,sizeof(dp));
	dp[0][0] = 0;
	dp2[0] = 0;
	for(int i = 1;i <= n;++i) {
		// (j,j+1)
		int64 min = dp[i-1][0];
		for(int j = 0;j <= n;++j) {
			if(dp[i-1][j]!=-1 && dp[i-1][j]<min) min=dp[i-1][j];
			if(ip[i-1]==j && dp2[i-1]<min) min=dp2[i-1];
			dp[i][j] = min + (ip[i] <= j ? a : b);
			if(ip[i] == j+1) dp2[i] = min;
		}
	}
	int64 ans = dp2[n];
	for(int i = 0;i <= n;++i) if(dp[n][i] < ans) ans = dp[n][i];
	printf("%lld\n", ans);
}


Measured memory_bytes: 195968
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M), mask(M, 0);
    REP (i, M) {
        cin >> a[i] >> b[i];
        REP (j, b[i]) {
            int c;
            cin >> c;
            mask[i] += 1LL << (c - 1);
        }
    }
    const int INF = 1LL << 60;
    vector<vector<int>> dp(M + 1, vector<int>(1LL << N, INF));
    dp[0][0] = 0;
    REP (i, M) REP (bit, 1LL << N) if (dp[i][bit] != INF) {
        dp[i + 1][bit] = min(dp[i + 1][bit], dp[i][bit]);
        dp[i + 1][bit | mask[i]] = min(dp[i + 1][bit | mask[i]], dp[i][bit] + a[i]);
    }
    cout << (dp[M][(1LL << N) - 1] == INF ? -1 : dp[M][(1LL << N) - 1]) << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 32384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];

  Int ans=0;
  vector<Int> v;
  for(Int i=0;i<n;i++){
    if(a[i]&1) v.emplace_back(a[i]);
    else ans+=a[i]/2;
  }
  sort(v.rbegin(),v.rend());
  for(Int i=0;i+1<(Int)v.size();i+=2){
    ans+=(v[i]+v[i+1])/2;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <string.h>
#include <string>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%s\n",(b*10+c)%4 ? "NO" : "YES");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int count(int a){
int count = 0;
while(a % 100 == 0){
  count += 1;
  a /= 100;
}
return count;
}

int main(){
  int D,N;
  cin >> D >> N;
  int c = 0;
  int ans = 0;
  while(c !=N){
    ans += 1;
    int a = count(ans);
    if(a == D){
      c+=1;
    }
  }
  cout << ans;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> frame(H+2, vector<char>(W+2,'#'));
  vector<vector<char>> photo(H, vector<char>(W));
  int n,m,i;
  string str;
  for(n=0;n<H;n++){
    cin >> str;
    for(m=0;m<W;m++){
        photo.at(n).at(m) = str.at(m);
    }
  }
  for(n=0;n<H;n++){
    for(m=0;m<W;m++){
        frame.at(n+1).at(m+1) = photo.at(n).at(m);
    }
  }
  for(n=0;n<H+2;n++){
    for(m=0;m<W+2;m++){
        cout << frame.at(n).at(m);
      }
    cout << endl;
  }
}

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


int main(){
    //ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("../input.txt","r",stdin);
    
    
    int x;
    cin >> x;
    cout << !x << "\n";
}

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

int main(){
  int count=0;
  int N,M,C;
  cin>>N>>M>>C;
  vector<int>A(N*M);
  vector<int>B(M);
  rep(i,M){
    cin>>B[i];
  }
  rep(i,N){
    rep(j,M){
      cin>>A[i*M+j];
    }
  }
  rep(i,N){
    int h=0;
    rep(j,M){
      h+=A[i*M+j]*B[j];
    }
    if(h+C>0){
      count++;
    }
  }
  cout<<count;
}


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

int main() 
{ 
    long long n;
    cin>>n;
    long long i=sqrt(n);
    while(i)
    {
        if(n%i==0)
        break;
        i--;
    }
    cout<<i+n/i-2;
} 


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);

	int m = max(max(A, B), C);

	printf("%d", m * 10 + A + B + C - m);




}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		String x = in.nextLine();
		String[] c ={"a","b","c","d","e","f","g","h","i","j",
"k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
for(String d : c){
 if(!x.contains(d)){
	System.out.println(d);
	System.exit(0);
 }
}
System.out.println("None");
	}
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UF{
    vector<int>par,sz;
    vector<int>f;
    void init(int n){
        par.resize(n);
        sz.resize(n);
        f.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
            f[i]=0;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        sz[x]+=sz[y];
        f[x]|=f[y];
        par[y]=x;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N,H,W;
int x[44444],y[44444];
int px[111111],py[111111];

int solve(int T){
    UF uf;uf.init(N);
    memset(px,-1,sizeof(px));
    memset(py,-1,sizeof(py));
    rep(i,N){
        if(px[x[i]]>=0)uf.unite(px[x[i]],i);
        if(py[y[i]]>=0)uf.unite(py[y[i]],i);
        if(y[i]==T)uf.f[uf.find(i)]=1;
        px[x[i]]=i;py[y[i]]=i;
    }

    int cnt1=0,cnt2=0;
    rep(i,N)if(uf.find(i)==i){
        cnt1++;
        if(uf.f[i])cnt2++;
    }

    if(cnt1==1)return N-1;
    return N-cnt1+cnt1-cnt2+cnt1-1;
}

signed main(){
    scanf("%lld%lld%lld",&N,&W,&H);
    rep(i,N)scanf("%lld%lld",&x[i],&y[i]);

    int ans=1001001001;
    rep(i,2){
        chmin(ans,solve(1));
        chmin(ans,solve(H));
        swap(H,W);
        rep(j,N)swap(x[j],y[j]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4436
#include <cstdio>

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	if(n==1) puts("Hello World");
	else{
		int a,b; scanf("%d%d",&a,&b);
		printf("%d\n",a+b);
	}
	return 0;
}


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

int main() {
  long long x;
  cin >> x;
  
  bool fin = false;
  for (long long i = 0; i < 100000; i++) {
    long long y_p = x + pow(i, 5);
    long long y_m = x + pow(-i, 5);
    for (long long j = 0; j < 100000; j++) {
      if (pow(j, 5) == y_p) {
        cout << j << " " << i << endl;
        fin = true;
        break;
      }
      if (pow(j, 5) == y_m) {
        cout << j << " " << -i << endl;
        fin = true;
        break;
      }
    }
    
    if (fin)
      break;
  }      
      
  return 0;
}

Measured memory_bytes: 4228
import java.io.*;
import java.util.*;
import java.math.*;
class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    int n;
	    Map<Integer, Integer> map;
	    while(true){
		n = Integer.valueOf(sc.readLine());
		if(n==0)
		    break;
		String[] st = sc.readLine().split(" ");
		int[] lho, kok;
		lho = new int[n];
		for(int i=0; i<n; i++)
		    lho[i] = Integer.valueOf(st[i]);
		map = new HashMap<Integer, Integer>();
		for(int i=0; i<n; i++){
		    if(!map.containsKey(lho[i]))
			map.put(lho[i],1);
		    else{
			int b = map.get(lho[i]);
			map.remove(lho[i]);
			map.put(lho[i],b+1);
		    }
		}
		int count = 0;
		kok = new int[n];
		while(true){
		    kok = lho.clone();
		    for(int i=0; i<n; i++)
			lho[i] = map.get(lho[i]);
		    map.clear();
		    for(int i=0; i<n; i++){
			if(!map.containsKey(lho[i]))
			    map.put(lho[i],1);
			else{
			    int b = map.get(lho[i]);
			    map.remove(lho[i]);
			    map.put(lho[i],b+1);
			}
		    }
		    if(Arrays.equals(lho,kok))
			break;
		    count++;
		}
		System.out.println(count);
		for(int i=0; i<n-1; i++)
		    System.out.print(lho[i]+" ");
		System.out.println(lho[n-1]);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 10000
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
typedef long long int ll;

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

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

struct edge { int to, cost; };
vector<edge> G[100010];
int N;
int color[100010] = {};

void dfs(int v, int c) {
	color[v] = c;
	for (int i = 0; i < G[v].size(); i++) {
		//隣接している頂点が距離偶数で同じ色ならfalse
		if (G[v][i].cost % 2 == 0 && color[G[v][i].to] == 0) {
//			cout << "G[" << v << "][" << i << "].to:" << G[v][i].to << endl;
//			cout << "color[G[" << v << "][" << i << "].to]:" << c << endl;
			dfs(G[v][i].to, c);
		}
		else if (G[v][i].cost % 2 == 1 && color[G[v][i].to] == 0) {
//			cout << "G[" << v << "][" << i << "].to:" << G[v][i].to << endl;
//			cout << "color[G[" << v << "][" << i << "].to]:" << -c << endl;
			dfs(G[v][i].to, -c);
		}
	}
}

void solve() {
	for (int i = 1; i <= N; i++) {
		if (color[i] == 0) {
			//まだ頂点iが塗られていなければ1で塗る
			dfs(i, 1);
		}
	}

	for (int i = 1; i <= N; i++) {
		if (color[i] == -1) cout << 0 << endl;
		else cout << color[i] << endl;
	}
}

int main()
{
	cin >> N;
	REP(i, N - 1) {
		int s, t, u;
		cin >> s >> t >> u;
		G[s].push_back({ t, u });
		G[t].push_back({ s, u });
	}
	solve();
}

Measured memory_bytes: 8320
// CODING BEAST
/*******************************************************************************************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define Precision(a) cout << fixed << setprecision(a)

using ll = long long;
ll inf = 1e18;
using vb = vector<bool>; using vc = vector<char>; using vd = vector<double>; using vi = vector<int>; using vvi = vector<vi>;
using vll = vector<ll>; using vvll = vector<vll>; using pi = pair<int, int>; using pll = pair<ll, ll>;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i = 0; i < n; i++)
#define repc(i,a,n) for(ll i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define pow2(x) (1ll<<(x))
#define Blazing_fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trav(a,v) for(auto &a:v)
int a[8] = { -1, -1, -1, 0, 0, 1, 1, 1};
int b[8] = { -1, 0, 1, -1, 1, -1, 0, 1};
inline ll power(ll x, ll y)
{
    ll temp;
    if ( y == 0)
        return 1;
    temp = power(x, y / 2) ;
    if (y % 2 == 0)
        return (temp * temp) ;
    else
        return (x * temp * temp) ;
}
bool sortbysec(pll & a, pll & b) {
    return (a.second < b.second);
}
/*
ll fact(ll n)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
        res = (res * i) ;
    return res;
}

ll ncr(ll n, ll r)
{
    return fact(n) / (fact(r) * fact(n - r));
}
bool isprime(ll n) {
    if (n <= 1) return false;
    if (n <= 3) return true;
    if ((n % 2 == 0) || (n % 3 == 0)) return false;
    for (ll i = 5; i * i <= n; i = i + 6)
        if ((n % i == 0) || (n % (i + 2) == 0)) return false;

    return true;
}*/
/*********************************************************************************************************************************************************/

signed main() {
    string s; cin >> s;
    ll ans = 0;
    ll ma = 0;
    rep(i, s.size()) {
        if (s[i] == 'R') {
            ans++;
        }
        else {

            ans = 0;
        }
        ma = max(ans, ma);
    }
    cout << ma << endl;
}




Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
bool K=false;

int main(){
    long long A,B,T,V,W;cin>>A>>V>>B>>W>>T;
    if((A<B)&&(T*V+A>=T*W+B))K=true;
    else if((A>B)&&A-T*V<=B-T*W)K=true;
    if(K)cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <map>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::map<std::string, int> m;
  for (int i = 0; i < n; ++i) {
    std::string t;
    std::cin >> t;
    std::sort(t.begin(), t.end());
    ++m[t];
  }
  long sum = 0;
  for (auto i : m) {
    long c = i.second;
    sum += c * (c - 1) / 2;
  }

  std::cout << sum << std::endl;
}
	


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 1;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;
vi v;

void solve(int testCase){

    scanf("%d %d" , &n , &m);
    string s;
    cin >> s;

    reverse(s.begin() , s.end());

    for(int i = 0 ; s[i] ; i ++){
            if(s[i] == '0'){
                    v.push_back(i);
            }
    }


    vi ans;
    int curr = 0;

    while( true ){
            int nxt = upper_bound(v.begin() , v.end() , curr + m) - v.begin() - 1;
            if(v[nxt] == curr){
                    printf("-1\n");
                    return;
            }
            ans.push_back(v[nxt] - curr);
            curr = v[nxt];

            if(curr == n)break;
    }

    reverse(ans.begin() , ans.end());

    for(int A : ans)printf("%d " , A);
    printf("\n");

}

main(){

    int t = 1;
    //scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

using namespace std;
int d[51];
int main() {
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }
    int sum = 0;
    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
def max_heapify(arr, i):
    size = len(arr)
    left = i * 2
    right = i * 2 + 1
    if left <= size and arr[left - 1] > arr[i - 1]:
        largest = left
    else:
        largest = i
    if right <= size and arr[right - 1] > arr[largest - 1]:
        largest = right
    
    if largest != i:
        arr[i - 1], arr[largest - 1] = arr[largest - 1], arr[i - 1]
        max_heapify(arr, largest)

def build_max_heap(arr):
    size = len(arr)
    for i in range(size // 2, 0, -1):
        max_heapify(arr, i)


n = int(input())
arr = list(map(int, input().split()))
build_max_heap(arr)
print(" ", end="")
print(*arr)


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

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	int temp,temp2;
	long long a[n];
	for(temp=0;temp<n;temp++)
	{
		cin>>a[temp];
	}
	long long sum=0;
	for(temp=0;temp<n;temp++)
	{
		sum+=a[temp]/2;
		a[temp]=a[temp]%2;
		if((a[temp]>0)&&(a[temp+1]>0)&&(temp+1<n))
		{
			sum++;
			a[temp+1]--;
		}
	}
	cout<<sum<<"\n";
}

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

int main() {

  int H, W;
  cin >> H >> W;

  vector<string> C(H);
  for (int i = 0; i < H; i++) {
    cin >> C[i];
  }

  for (int i = 0; i < H; i++) {
    cout << C[i] << endl;
    cout << C[i] << endl;
  }

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define max(a,b) a>b?a:b
int comp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int main() {
	int n, a[1000], ab, cd,i;
	double ans=0.0;
	fscanf(stdin, "%d", &n);
	for (i = 0; i < n; i++) fscanf(stdin, "%d", &a[i]);
	qsort(a, n, sizeof(int), comp);
	for (i = 1; i < n; i++) {
		cd = a[i] - a[i - 1];
		if (i == n - 1) ab = a[n - 3] + a[n - 4];
		else if (i == n - 2) ab = a[n - 1] + a[n - 4];
		else ab = a[n - 1] + a[n - 2];
		ans = max(ans, (double)ab / cd);
	}
	P(lf, ans);
	return 0;
}

Measured memory_bytes: 688
ns = gets.chomp.split("")
ns.map!{|item|
    if item != "?" then
    item.to_i
  else
    item.to_s
  end
}
dp = Array.new(13, 0)
dp[0]=1
 
ns.each do |n|
  dpnext = Array.new(13, 0)
  dp.each_with_index {|b, num|
    if n == "?"
      10.times {|t|
        dpnext[ (num * 10 + t) % 13 ] += b
      }
    else
      dpnext[ (num * 10 + n) % 13 ] += b
    end
  }
  13.times{|t|
    dpnext[t] %= 1000000007
  }
  dp = dpnext
end
p dp[5]%1000000007

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

int main(){
  int N;
  cin >> N;
  int64_t ans=0;
  map<pair<char,char>,int> m;
  string s,temp;
  pair<char,char> p;
  for(int i=1;i<=N;i++){
    if(i%10==0){
      continue;
    }
    s=to_string(i);
    p=make_pair(s.front(),s.back());
    if(m.count(p)){
      continue;
    }else{
      m[p]=1;
    }
    queue<string> que;
    que.push(s);
    while(!que.empty()){
      s=que.front();
      que.pop();
      if(s.size()==1){
        temp=s+s.back();
        if(stoi(temp)>N){
          break;
        }
        que.push(temp);
        m.at(p)++;
      }else{
        bool flag=true;
        for(char c='0';c<='9';c++){
          temp=s.substr(0,s.size()-1)+c+s.back();
          if(stoi(temp)>N){
            flag=false;
            break;
          }
          que.push(temp);
          m.at(p)++;
        }
        if(!flag){
          break;
        }
      }
    }
  }
  char f,b;
  for(auto & x:m){
    tie(f,b)=x.first;
    p=make_pair(b,f);
    if(m.count(p)){
      ans+=x.second*m.at(p);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3848
#include <stdio.h>
void gcd(int x, int y){
  if(x % y){
    gcd(y, x % y);
  }else{
    printf("%d ", y);
  }
}
void lcm(int x, int y, int a){
  int g = y * a;
  if(g % x){
    lcm(x, y, a + 1);
  }else{
    printf("%d\n", g);
  }
}
int main(void){
  int x, y;

  while(scanf("%d%d", &x, &y) != EOF){
    int a, b;
    if(x > y){
      a = x;
      b = y;
    }else{
      a = y;
      b = x;
    }
    gcd(a, b);
    lcm(a, b, 1);
  }
}

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

int main(){
    int s;
    cin>>s;
    int a,b,c;
    a=s/3600;
    s-=a*3600;
    b=s/60;
    s-=b*60;
    c=s;
    cout<<a<<":"<<b<<":"<<c<<endl;
    return 0;
}
    


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
 

int main(){
  int n,k,r,s,p;
  string t;
  cin >>n>>k>>r>>s>>p>>t;

  string tka ="";
  int ans=0;
  rep(i,n){
    if(i<k){
      if(t.at(i) == 'r'){
        tka += 'p';
      }else if(t.at(i) == 's'){
        tka += 'r';
      }else if(t.at(i) == 'p'){
        tka += 's';
      }
    }else if(i >= k){
       if(t.at(i) == 'r'){
         if(tka.at(i-k) == 'p'){
           tka += 'n';
         }else{
          tka += 'p';
         }
      }else if(t.at(i) == 's'){
         if(tka.at(i-k) == 'r'){
           tka += 'n';
         }else{
          tka += 'r';
         }
      }else if(t.at(i) == 'p'){
         if(tka.at(i-k) == 's'){
           tka += 'n';
         }else{
          tka += 's';
         }
      }
    }
  }

  rep(i,n){
    if(tka.at(i) == 'r'){
      ans += r;
    }else if(tka.at(i) == 's'){
      ans += s;
    }else if(tka.at(i) == 'p'){
      ans += p;
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 640
import Data.Array
import Data.Array.IO
import Control.Monad

type Grid = IOUArray (Int,Int) Char
type DP = IOUArray (Int,Int) Int

main = do
  [h,w] <- map read . words <$> getLine :: IO [Int]
  xss <- replicateM h getLine 
  grid <- thaw $ listArray ((1,1),(h,w)) $ concat xss :: IO Grid
  dp <- newArray ((1,1),(h,w)) (10^9) :: IO DP

  readArray grid (1,1) >>= \r -> do
    if r == '#'
       then writeArray dp (1,1) 1
       else writeArray dp (1,1) 0

  ((minh,minw), (maxh,maxw)) <- getBounds dp

  forM_ [1..h] $ \i -> do
    forM_ [1..w] $ \j -> do
      d <- readArray dp (i,j) 
      g <- readArray grid (i,j) 
      forM_ [(i+1,j),(i,j+1)] $ \p@(i',j') -> do
        when (i' <= maxh && j' <= maxw) $ do
          readArray grid p >>= \r ->
            if (r == '#') && (g == '.')
               then readArray dp p >>= \s -> writeArray dp p $ min (d+1) s
               else readArray dp p >>= \s -> writeArray dp p $ min d s

  readArray dp (h,w) >>= print


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

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
 
    long long N, M; cin >>N>>M;

    if (N == 1 && M == 1)
        cout << 1 << endl;
    else if (N == 1 || M == 1)
        cout << max(N, M) - 2 << endl;
    else
        cout << (N-2) * (M-2) << endl;
}


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

struct data {
  int s, to;
};
bool operator<(const data &l, const data &r) {
  if(l.s != r.s) return l.s < r.s;
  return l.to < r.to;
}

int n;
vector<int> memo, nodeid;
string s;
vector<string> v;
vector<data> dv;
set<data> st;

bool solve();

int main() {
  while(1) {
    cin >> n;
    if(n == 0) break;
    cin >> s;
    if(solve())
      cout << "SAFE" << endl;
    else
      cout << "UNSAFE" << endl;
    v.erase(v.begin(), v.end());
    dv.erase(dv.begin(), dv.end());
    st.clear();
  }
  return 0;
}

bool solve() {
  // parse
  for(int i = 0; i < n; ++i) {
    data now = {0, 0};
    while(i < n && s[i] != 'u') {
      if((now.s >> (s[i] - '0')) & 1) return 0;
      now.to = s[i] - '0';
      if(st.find(now) == st.end()) {
        st.insert(now);
        dv.push_back(now);
      }
      now.s |= 1 << (s[i++] - '0');
    }
  }
  for(int t = 0; t < 10; ++t) {
    int nowsize = st.size();
    for(int i = 0; i < nowsize; ++i)
      for(int j = i + 1; j < nowsize; ++j) {
        data nextd = {0, 0};
        if((dv[i].s & dv[j].s) != 0) continue;
        if((dv[i].s >> dv[j].to) & (dv[j].s >> dv[i].to) &
           1)
          return 0;
        nextd.s = dv[i].s | dv[j].s;
        if((dv[i].s >> dv[j].to) & 1) {
          nextd.to = dv[i].to;
          if(st.find(nextd) == st.end()) {
            st.insert(nextd);
            dv.push_back(nextd);
          }
        }
        if((dv[j].s >> dv[i].to) & 1) {
          nextd.to = dv[j].to;
          if(st.find(nextd) == st.end()) {
            st.insert(nextd);
            dv.push_back(nextd);
          }
        }
      }
  }
  return 1;
}



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

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int calc(int i, int j, int m){
    int t = gcd(i, j);
    return gcd(t, m);
}

int main() {
    int k; cin >> k;
    ll sum = 0;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int m = 1; m <= k; m++){
                sum += calc(i, j, m);
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if((a == 5 && b == 7 && c == 5) || (a == 5 && b == 5 && c == 7)
			|| (a == 7 && b == 5 && c == 5))
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}

Measured memory_bytes: 24916
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int k;
    cin>>k;
    long long int sum=0;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            for(int p=1;p<=k;p++)
            {
                sum=sum+__gcd(i,__gcd(j,p));
            }
        }
    }
    cout<<sum;
}

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

int main() {
  string s;
  cin >>s;
  int start=0,end=0;
  for (int i=0;i<s.size();i++) {
    if (s.at(i)=='A') {
      start=i;
      break;
    }
  }
  for (int i=s.size()-1;i>=0;i--) {
    if (s.at(i)=='Z') {
      end=i;
      break;
    }
  }
  cout << end - start +1 <<endl;
}

Measured memory_bytes: 640