akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <cassert>
using namespace std;

struct UnionFind {
        int n;
        vector<int> parent;
        vector<int> rank;
        vector<int> num;
        int find(int x) {
                if (parent[x] == x) return  x;
                return parent[x] = find(parent[x]);
        }
        UnionFind(int n_) {
                n = n_;
                parent.resize(n);
                for (int i = 0; i < n; i ++) parent[i] = i;
                rank.assign(n, 0);
                num.assign(n, 1);
        }
        void unite(int x, int y) {
                if ((x = find(x)) != (y = find(y))) {
                        if (rank[x] < rank[y]) {
                                parent[x] = y;
                                num[y] += num[x];
                        } else {
                                parent[y] = x;
                                if (rank[x] == rank[y]) rank[x] ++;
                                num[x] += num[y];
                        }
                        n --;
                }
        }
        bool same(int x, int y) { return find(x) == find(y); }
        int get() { return n; }
        int get(int x) { return num[find(x)]; }
};

int main() {
        int n, m;
        scanf("%d %d", &n, &m);
        vector<vector<int>> g(n), rg(n);
        UnionFind uf(n + 1);
        for (int i = 0; i < m; i ++) {
                int a, b;
                scanf("%d %d", &a, &b);
                a --, b --;
                g[a].push_back(b);
                rg[b].push_back(a);
                uf.unite(a, b);
        }
        vector<int> color(n, -1);
        long long x, y, z, edge;
        function<bool (int, int)> dfs = [&](int u, int c) {
                if (color[u] == -1) {
                        color[u] = c;
                        if (c == 0) x ++;
                        else if (c == 1) y ++;
                        else if (c == 2) z ++;
                        else assert(false);
                } else if (color[u] != c) {
                        return true;
                } else {
                        return false;
                }
                for (auto v : g[u]) {
                        edge ++;
                        if (dfs(v, (c + 1) % 3)) return true;
                } 
                for (auto v : rg[u]) {
                        edge ++;
                        if (dfs(v, (c + 2) % 3)) return true;
                }
                return false;
        };
        long long ans = 0;
        for (int i = 0; i < n; i ++) if (!uf.same(i, n)) {
                long long sz = uf.get(i);
                uf.unite(i, n);
                x = 0, y = 0, z = 0, edge = 0;
                bool all = dfs(i, 0);
                if (all) {
                        ans += sz * sz;
                } else if (y == 0 || z == 0) {
                        ans += edge / 2;
                } else {
                        ans += x * y + y * z + z * x;
                }
        }
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 20608
import std.stdio,std.range,std.conv,std.string,std.algorithm;

void main(){
    int[][] mat=new int[][](11,11);
    while(true){
        int data=readln.chomp.to!int;
        if(!data)break;
        foreach(y;0..data){
            mat[y][0..data]=readln.split.map!(to!int).array[0..data];
            mat[y][data]=mat[y][0..data].reduce!"a+b";
        }
        foreach(x;0..data+1){
            mat[data][x]=mat.transversal(x).take(data).reduce!"a+b";
        }
        foreach(y;0..data+1){
            foreach(x;0..data+1){
                writef("%5d", mat[y][x]);
            }
            writeln;
        }
    }
}

Measured memory_bytes: 1080
#include<stdio.h>

int int_sort( const void * a , const void * b ) {
  /* 引数はvoid*型と規定されているのでint型にcastする */
  if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return 1;
}

int main(void) {
  int n, m, i, sum=0;
  int* a;
  scanf("%d %d", &n, &m);
  a = (int*)malloc(sizeof(int)*n);
  for(i=0; i<n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  qsort((void*)a, n, sizeof(int), int_sort);
  if(a[n-m] < (double)sum/(4*m)) {
    printf("No\n");
  }
  else {
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int dp[21][200000];
int N,K,Q,x[200000],a,b;
int solve(int pos,int t){
	for(int i=19;i>=0;i--){
		if((t/(1<<i))%2==1)pos=dp[i][pos];
	}
	return pos;
}
int main(){
	cin>>N;for(int i=0;i<N;i++)cin>>x[i];cin>>K>>Q;
	for(int i=0;i<N;i++){
		int pos1=upper_bound(x,x+N,x[i]+K)-x;pos1--;
		dp[0][i]=pos1;
	}
	dp[0][N]=N;
	for(int i=0;i<20;i++){
		for(int j=0;j<N;j++)dp[i+1][j]=dp[i][dp[i][j]];
		dp[i+1][N]=N;
	}
	for(int i=0;i<Q;i++){
		cin>>a>>b;if(a>b)swap(a,b);a--;b--;
		int L=0,R=200000,M;
		while(true){
			M=(L+R)/2;
			int p1=solve(a,M-1),p2=solve(a,M);
			if(p1<b && p2>=b)break;
			if(p1>=b)R=M;
			if(p2<b)L=M;
		}
		cout<<M<<endl;
	}
	return 0;
}


Measured memory_bytes: 9600
n,m,c=map(int, input().split())
b=list(map(int, input().split()))
cnt=0
for i in range(n):
  s=0
  a=list(map(int, input().split()))
  for j in range(m):
    s=s+a[j]*b[j]
  if s+c>0:
    cnt=cnt+1
print(cnt)

Measured memory_bytes: 9172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		if(n%2==0) {
			System.out.println(n/2);
		}else {
			System.out.println(n/2+1);
		}
	}

}


Measured memory_bytes: 22356
#include<deque>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define pb push_back
#define pf push_front
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T1,class T2,class T3>inline void          in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
long N,K,len=1,i,M,ans=1,j,k;
string S;
deque<long>v,s;
inline void solve(void){
  in(N,K,S);
  up(i,1,N-1){
    if(S[i]==S[i-1])len++;
    else{
      v.pb(len);
      len=1;
    }
  }
  v.pb(len);
  if(S[0]=='0')v.pf(0);
  if(S[N-1]=='0')v.pb(0);
  M=v.size();
  s.resize(M+1);
  for(i=0;i<M;i++)s[i+1]=s[i]+v[i];
  for(i=0;i<M;i+=2){
    j=2*K+1+i;
    if(j>M)j=M;
    chmax(ans,s[j]-s[i]);
  }
  out(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 2000
#include<stdio.h>
int main(void)
{
  int train1,train2,bus1,bus2,price = 0;
  char str[32];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&train1);
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&train2);
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&bus1);
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&bus2);
  
  if(train1<train2)
  {
    price += train1;
  }else
  {
    price += train2;
  }
  
  if(bus1<bus2)
  {
    price += bus1;
  }else
  {
    price += bus2;
  }
 
  printf("%d",price);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cassert>
#include <iostream>
#include <queue>
#include <cstring>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

#define N 202020
#define B 80
#define M 1000020
#define LOGN 35
#define mod 998244353
#define inf 0x3f3f3f3f
#define LL long long

char s[N];
// D is 0, P is 1

int main()
{
  scanf("%s", s + 1);
  for (int i = 1; s[i]; ++i)
  {
    if (s[i] == '?')
      s[i] = 'D';
  }
  printf("%s\n", s + 1);
  return 0;
}


Measured memory_bytes: 3876
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        int up = 0;
        int count = 0;

        for(int i=1; i<n; i++) {
            int pre = ary[i-1];
            int now = ary[i];

            if(pre == now) {
                continue;
            }
            int up2 = (now > pre) ? 1 : -1;
            if(up == 0) up = up2;

            if(up2 != up) {
                count++;
                up = 0;
            } else {
                up = up2;
            }
        }

        return count+1;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }

}


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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define MOD 1000000007
#define PI 3.14159265359
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;

void test()
{
	char a;
	cin>>a;

	if(a>='A' && a<='Z')
		cout<<'A'<<endl;
	else
		cout<<'a'<<endl;
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

//cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

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

using namespace std;

int main(){
    int W, a, b;
    cin >> W >> a >> b;
    int ans = 0;
    if(b-a-W >0) ans = b-a-W;
    if(a-b-W >0) ans = a-b-W;
    cout << ans << endl;
}   

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s,t;
int q;

int cnt[2][2][100001];

int main(){
	cin >> s >> t;
	rep(i,s.size()){
		cnt[0][0][i+1] = (s[i] == 'A');
		cnt[0][1][i+1] = (s[i] == 'B');
		cnt[0][0][i+1] += cnt[0][0][i];
		cnt[0][1][i+1] += cnt[0][1][i];
	}
	rep(i,t.size()){
		cnt[1][0][i+1] = (t[i] == 'A');
		cnt[1][1][i+1] = (t[i] == 'B');
		cnt[1][0][i+1] += cnt[1][0][i];
		cnt[1][1][i+1] += cnt[1][1][i];
	}
	cin >> q;
	rep(i,q){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		int sa = (cnt[0][0][b] - cnt[0][0][a-1])%3;
		int sb = (cnt[0][1][b] - cnt[0][1][a-1])%3;
		int ta = (cnt[1][0][d] - cnt[1][0][c-1])%3;
		int tb = (cnt[1][1][d] - cnt[1][1][c-1])%3;
		if((tb+3-ta)%3 == (sb+3-sa)%3)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    bool a, b;
    a = false, b = false;
    REP(i,3){
        char c;
        cin >> c;
        if(c == 'A')
            a = true;
        else if(c == 'B')
            b = true;
    }

    if(a && b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

char a[14];

int main() {
    
    cin >> a;
    
    for (int i = 12; i >=5; i--) {
        a[i] = a[i-1];
    }
    a[4] = ' ';
    
    cout << a << endl;
    
    
    return 0;
    
    
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

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

    int N;
    cin >> N;
    string *s = new string[N];
    for (int i = 0; i < N; i++) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }

    sort(s, s + N);

    long long j = 0, num = 0;
    for (int i = 0; i < N - 1; i++) {
        if (s[i] == s[i + 1])
            j++;
        else {
            num += (1 + j) * j / 2;
            j = 0;
        }
    }
    cout << num + (1 + j) * j / 2 << '\n';

    return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;


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

    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3100
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            String b = sc.next();

            String ans;
            if(b.equals("A")) ans = "T";
            else if(b.equals("T")) ans = "A";
            else if(b.equals("C")) ans = "G";
            else ans = "C";


            System.out.println(ans);
 
        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int XMAX = 2501;
int main() {
  int n, a;
  cin >> n >> a;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  vector<vector<ll>> dp(n + 1, vector<ll>(XMAX, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = n; j >= 0; j--) {
      for (int k = XMAX - 1; k >= 0; k--) {
        if (j != n && x[i] + k < XMAX) dp[j + 1][k + x[i]] += dp[j][k];
      }
    }
  }
  ll res = 0;
  for (int i = 1; i <= n; i++) res += dp[i][i * a];
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i)
void fastscan(int &x)
 {
        bool neg=false;
        register int c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    } 
string alpha = "abcdefghijklmnopqrstuvwxyz";
const int mod = 1e9+7;
const int inf = 2e18+5;
const int nax = 100010;
const int mod1 = 998244353;
   

signed main()
 {
int n,k;
  cin>>n>>k;
  vector<int> v;
  loop(i,0,n)
   {
    int x;
    cin>>x;
    v.pb(x);
   }
   int dp[n] ;
   loop(i,0,n)
    dp[i] = inf;
   dp[0] = 0;
   loop(i,0,n)
    {
      loop(j,i+1,min(i+k+1,n))
       {
        dp[j] = min(dp[i] + abs(v[j]-v[i]),dp[j]);
       }
    }
    cout<<dp[n-1];
return 0;
}


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

using namespace std;

int main()
{
    char array[26];
    array[0] = 'a';
    for(int n=0; n<25; n++)
    {
        array[n+1]=array[n]+1;
    }
    
    char x;
    int kosu[26]={};
    
    while(cin >> x)
    {
        kosu[(x-'a')]++;
    }
    
    int ans=0;
    
    for(int i=0; i<26; i++)
    {
        if(kosu[i]==0)
        {
            break;
        }
        ans++;
    }
    
    if(ans==26) cout << "None" << endl;
    else
    {
        cout << char ('a'+ans) << endl;
    }
    
    return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int n = read();
  vi d;
  REP(i, n) { d.PB(read()); }
  sort(ALL(d));
  print(d[n / 2] - d[n / 2 - 1]);
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	if (n < 1200) {
		cout << "ABC";
	}
	else if (n < 2800) {
		cout << "ARC";
	}
	else {
		cout<<"AGC";
	}
	cout << 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;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;
long long s[44];

void prepare(){
    s[0]=1;
    rep(i,42){
        s[i+1]=s[i]*(-2);
    }
}

int main(){

long long N;
cin>>N;

string ans;
prepare();


if(N==0){
    cout<<'0'<<endl;
    return 0;
}

char src[2]={'0','1'};
long long div=2;
int p=0;
while(abs(N)>0){
    if((N%div)!=0){
        ans.insert(0,1,src[1]);
        N-=s[p];
    }
    else{
        ans.insert(0,1,src[0]);
    }
    p++;
    div*=2;
}
//cout<<ans.size();
rep(i,ans.size()){
    cout<<ans[i];
}
 return 0;
}
/*
-9

1011


123456789

11000101011001101110100010101

0

0
*/

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int N, T, A,n,nyan, H[100010];
    double ans = 100001.0;
    scanf("%d", &N);
    scanf("%d %d", &T, &A);

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

    for (n = 1; n < N + 1;n++){
        if((A-(T-H[n]*0.006))*(A-(T-H[n]*0.006))<ans*ans){
    ans=A-(T-H[n]*0.006);
        nyan = n;
        }
    }

    printf("%d", nyan);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int table[200][200] = {{0}};
    int c,r; //column,row
    cin >> r >> c;
    
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> table[i][j];
        }
    }
    //横計算する
    for(int i = 0; i < r + 1; i++){
        int sum = 0;
        for(int j = 0; j < c; j++){
            sum += table[i][j];
        }
        table[i][c] = sum;
    }
    //縦計算する
    for(int j = 0; j < c + 1; j++){
        int sum = 0;
        for(int i = 0; i < r; i++){
            sum += table[i][j];
        }
        table[r][j] = sum;
    }
    //先に出力を作る
    for(int i = 0; i < r + 1; i++){
        for(int j = 0; j < c; j++){
            cout << table[i][j] << " ";
        }
        cout << table[i][c] << endl;
    }
}


Measured memory_bytes: 3256
from collections import deque
s = str(input())
b = deque()

for i in range(len(s)):
    if s[i] == "0":
        b.append("0")
    elif s[i] == "1":
        b.append("1")
    elif s[i] == "B":
        if len(b) == 0:
            pass
        else:
            b.pop()


print("".join(map(str, b)))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;

int main() {
	int n, q;
	scanf("%d %d", &n, &q);
	dsu d(n);
	for (int i = 0; i < q; i++) {
		int t, u, v;
		scanf("%d %d %d", &t, &u, &v);
		if (t) {
			puts(d.same(u, v) ? "1" : "0");
		} else {
			d.merge(u, v);
		}
	}
	return 0;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
string s,t[4]={"dream","erase","dreamer","eraser"};

bool solve(int k,int n){
  for(int i=0;i<t[n].size();i++)
    if(i+k>=0&&s[i+k]!=t[n][i])return false;
  return true;
}

int main(){
  cin>>s;
  int f=0;
  for(int i=s.size()-1;i>=0;i--){
    int k=0;
    if(i<3){
      f=1;
      break;
    }
    if(s[i]=='m')k=0;
    else if(s[i]=='e')k=1;
    else {
      if(s[i-2]=='m')k=2;
      else if(s[i-2]=='s')k=3;
      else f=1;
    }
    i-=t[k].size()-1;
    if(!solve(i,k)){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  if(f)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++){
    cin >> S[i];
  }
  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < N; i++){
    if (S[i] == "A"){
      cnt++;
    }
    if (S[i] == "Un"){
      if (cnt > 0){
        ans++;
        cnt--;
      }
    }
  }
  if (ans * 2 == N){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <cmath>

using vec = std::vector< int >;

double norm( vec a, vec b ) {
    int d = a.size();
    double ans = 0;
    for (int i=0; i<d; ++i) {
        int tmp = a[i] - b[i];
        ans += tmp * tmp;
    }
    return std::sqrt( ans );
}

int main() {
    int n, d;
    int ans = 0;
    vec v[10];
    std::cin >> n >> d;
    for (int i=0; i<n; ++i) {
        int tmp;
        for (int j=0; j<d; ++j) {
            std::cin >> tmp;
            v[i].push_back( tmp );
        }
    }
    for (int i=0; i<n-1; ++i) {
        for (int j=i+1; j<n; ++j) {
            double dist = norm( v[i], v[j] );
            if (dist == (int) dist) ++ans;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def f(l, r, kousa=1):
    n = (r - l) // kousa
    return (r + l) * (n + 1) // 2

def solve():
    N = II()
    ans = 0
    for j in range(1, N+1):
        ans += f(j, N - (N%j), j)
    print(ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9180
#include <vector>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;
const int N = 200000;

int n;
int ans[N];
vector <int> a[N];
priority_queue< pair<int,int> > q;

int main(void)
{
	scanf("%d", &n);
	for (int i=1;i<n;++i)
	{
		int x, y; scanf("%d %d", &x, &y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	memset(ans,-1,sizeof ans);
	int m; scanf("%d", &m);
	for (int i=1;i<=m;++i)
	{
		int x, v; scanf("%d %d", &x, &v);
		ans[x] = v; q.push(make_pair(-v,x));
	}
	while (q.size())
	{
		int x = q.top().second;
		int v = -q.top().first;
		q.pop();
		for (int i=0;i<a[x].size();++i)
		{
			int y = a[x][i];
			if (ans[y] >= 0 and abs(ans[x]-ans[y]) ^ 1) {
				puts("No");
				return 0;
			}
			else if (ans[y] < 0) {
				ans[y] = v + 1;
				q.push(make_pair(-ans[y],y));
			}
		}
	}
	puts("Yes"); 
	for (int i=1;i<=n;++i)
		printf("%d\n", ans[i], i==n?'\n':' ');
	return 0;
} 

Measured memory_bytes: 10612
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

ll inf=(ll)2e18;
const int mod=1000000007;
//const int mod=998244353;

int n,m;
const int N=2e5+10;




int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int q,t,k,u,v;
    ll x,a,b,c,d,y,p,z;
    cin >> n >> k;
    vi vv(n);
    for(int i=0; i<n; i++){
        cin >> vv[i];
    }
    for(int i=k; i<n; i++){
        if(vv[i-k]<vv[i]){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }
    }
    
    
    
    
    
    return 0;
}






Measured memory_bytes: 3972
#include<stdio.h>
int main()
{
  int m,n,i,j,k=0,box1[100][100],box2[100];

  for(i=0;i<100;i++)
    {
      box2[i]=0;
    }
  scanf("%d %d",&m,&n);
  for(i=0;i<m;i++)
    {
      for(j=0;j<n;j++)
	{
	  scanf("%d",&box1[i][j]);
	}
    }
  for(i=0;i<m;i++)
    {
      for(j=0;j<n;j++)
	{
	  printf("%d ",box1[i][j]);
	  k=k+box1[i][j];
	}
      printf("%d\n",k);
      k=0;
    }
  for(i=0;i<n;i++)
    {
      for(j=0;j<m;j++)
	{
	  box2[i]=box1[j][i]+box2[i];
	}
    }
  for(i=0;i<n;i++)
    {
      printf("%d ",box2[i]);
    }
  for(i=0;i<m;i++)
    {
      for(j=0;j<n;j++)
	{
	  k=k+box1[i][j];
	}
    }
  printf("%d\n",k);
  return 0;
}



Measured memory_bytes: 2032
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String SArray[] = S.split("/");

		SArray[0] = "2018";

		System.out.print(SArray[0] + "/" + SArray[1] + "/" + SArray[2]);
	}

}

Measured memory_bytes: 21844
from sys import stdin
rs = lambda : stdin.readline().strip()
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    A, V = ril()
    B, W = ril()
    T = ri()
    print('YES' if abs(A - B) <= T * (V - W) else 'NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
ARGF.each_line do |line|
  h, w = line.split.map(&:to_i)
  break if h == 0 && w == 0
  (1..h).each do |i|
    case i
    when 1, h
      puts '#' * w
    else
      print "#", ("." * (w - 2)), "#\n"
    end
  end
  puts
end

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

int main() {
  int k, x;
  cin >> k >> x;

  if (500 * k >= x) {
      cout << "Yes" << endl;
  } else {
      cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e8;
ll mod=1e9+7;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
//#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define pi acos(-1)
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define SIZE 5000 + 1

ll expo(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}

void solve()
{
  ll n;
  cin>>n;
  ll ans=0;
  set<ll> st;
  for(ll  i=2;i*i<=n;i++)
  {
      if(n%i==0)
      {
          ll a=n/i;
          //st.insert(a);
          while(a%i==0 && a!=0)
          {
              a=a/i;
          }
          if(a%i==1)
            ans++;
          if((i*i)!=n)
          {
              ll b=n/i;
              ll d=n/b;
              //debug2(d,d1);
              while(d%b==0 && d!=0)
              d=d/b;
              if(d%b==1)
                ans++;
          }
      }
      //debug2(ans,i);
  }
  ans++;
  ll didi=n-1;
  if(didi>0)
  {
      //debug(didi);
      ll i;ll v=0;
  for(i=2;i*i<=didi;i++)
  {
      if(didi%i==0)
      {
            ans++;
          if((i*i)!=didi)
          {
                ans++;
          }
      }
      //debug2(i,ans);
  }
  if(didi!=1)
    ans++;
  }
cout<<ans<<endl;




}

int main()
{
  boost;
  ll t=1;
  //cin>>t;
  //sieve();
  //int ca=0;
  while(t--)
  {
     // ca++;
     // cout<<"Case #"<<ca<<":"<<" ";
      solve();
  }
}


Measured memory_bytes: 256
#dp[i][k] : i番目まで見て、0でない数がk個出現しているときの組合せ
#dp0[][] : N以下であるか未確定、dp1[][] = N以下が確定

#例:1以上N以下の整数であって、0でない数字がちょうどK個あるような個数

def main(N,K):
    dp0 = [[0] * (K + 1) for _ in range(len(N) + 1)]
    dp1 = [[0] * (K + 1) for _ in range(len(N) + 1)]
    dp0[0][0] = 1

    #桁ごと(最上位桁から)
    for i, n in enumerate(N):
        for k in range(K + 1):
            #確認中の桁が0の場合
            if n == '0':
                dp0[i+1][k] += dp0[i][k]
                dp1[i+1][k] += dp1[i][k]
                #k < Kの場合
                if k < K:
                    dp1[i + 1][k + 1] += 9 * dp1[i][k]
            #確認中の桁が0以外の場合
            else:
                if k < K:
                    dp0[i+1][k+1] += dp0[i][k]
                    dp1[i+1][k+1] += (int(n) - 1) * dp0[i][k]
                    dp1[i+1][k+1] += 9 * dp1[i][k]

                dp1[i+1][k] += dp0[i][k]
                dp1[i+1][k] += dp1[i][k]
    print(dp0[-1][K] + dp1[-1][K])

N = input()
K = int(input())
main(N,K)


Measured memory_bytes: 3064
import java.util.Scanner;

class BubbleSort {

  public int n = 0;

  public BubbleSort(int[] argv ) {
    sort(argv);
    for(int i = 0; i < (argv.length - 1); i++){
      System.out.printf("%d ", argv[i]);
    }
    System.out.println(argv[argv.length - 1]);
    System.out.printf("%d\n", n);
  }


  public void sort( int[] array ) {
    int tmp=0; //作業領域
    for( int i=0; i<array.length-1; i++ ) {
       for( int j=0; j<array.length-i-1; j++ ) {
          if( array[j] > array[j+1] ) {
              tmp = array[j];
              array[j] = array[j+1];
              array[j+1] = tmp;
              n += 1;
          }
       }
    }
  }
}

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = Integer.parseInt(sc.next());
    int[] a = new int[x];
    for(int i = 0; i < x; i++){
      a[i] = Integer.parseInt(sc.next());
    }
    BubbleSort bs = new BubbleSort(a);
  }
}


Measured memory_bytes: 26344
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;


// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// -------------------------------------------------------------------------------------

int f(ll x, ll y) {
  int res1 = 0;
  while(x > 0) {
    x /= 10;
    res1++;
  }

  int res2 = 0;
  while(y > 0) {
    y /= 10;
    res2++;
  }

  return max(res1, res2);
}

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

  int ans = INF<int>;
  for(ll a = 1; a*a <= n; a++) {
    if(n % a != 0) continue;
    ans = min(ans, f(a, n / a));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

signed main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<int> a(m);

  int b=0,f=0;
  rep(i,m){
    cin>>a[i];
    if(a[i]==0||a[i]==n)continue;
    if(a[i]<x){
      b++;
    }else if(x<a[i]){
      f++;
    }
  }
  cout<<min(b,f)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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


Measured memory_bytes: 3100
N, M = map(int, input().split())
L = 0
R = N
for _ in range(M):
    inp = input().split()
    l = int(inp[0])
    r = int(inp[1])
    L = max(L,l)
    R = min(R,r)
print(max(0,R + 1 - L))

Measured memory_bytes: 3064
#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;}

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  int k;
  cin>>k;
  int c=0;
  for(int i=0;i<k;i++){
    int x;
    cin>>x;
    c|=1<<x;
  }
  for(int b=c;;b=(b-1)&c){
    int nb=c^b;
    cout<<nb<<":";
    for(int i=0;i<n;i++)
      if((nb>>i)&1) cout<<" "<<i;
    cout<<"\n";
    if(b==0) break;
  }
  cout<<flush;
  return 0;
}



Measured memory_bytes: 3172
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

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

typedef pair<int, int> pii;
typedef long long ll;

// x coordinate mod 2 = 0
int dx1[] = {0, 1, 1, 0, -1, -1};
int dy1[] = {1, 0, -1, -1, -1, 0};

// mod 2 = 1
int dx2[] = {0, 1, 1, 0, -1, -1};
int dy2[] = {1, 1, 0, -1, 0, 1};

constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

// テ・ツコツァテヲツィツ?(x, y), テヲツ卍づゥツ鳴?z (mod 6) テ」ツ?ォテ」ツ?甘」ツ?妥」ツつ凝ヲツ慊?・ツーツ湘・ツ?、
int rec[210][210][6];
int sx, sy, gx, gy;
int N, X[1010], Y[1010];
bool exist[210][210];
int lx, ly;

struct Elem {
    int x, y, t;
};

signed main() {
    rep(i,0,210) rep(j,0,210) rep(k,0,6) rec[i][j][k] = INF;
    cin >> sx >> sy >> gx >> gy;
    cin >> N;
    rep(i,0,N) cin >> X[i] >> Y[i];
    cin >> lx >> ly;

    sx += lx, sy += ly, gx += lx, gy += ly;
    rep(i,0,N) {
        exist[ X[i]+lx ][ Y[i]+ly ] = true;
    }

    rec[sx][sy][0] = 0;
    queue<Elem> q;
    q.push(Elem{sx, sy, 0});
    while(!q.empty()) {
        Elem cur = q.front(); q.pop();

        // move
        int ax = abs(cur.x - lx), ay = abs(cur.y - ly);
        int dir = (ax * ay * (cur.t)) % 6;
        rep(i,0,6) {
            int nx, ny;
            if(ax % 2) nx = cur.x + dx2[i], ny = cur.y + dy2[i];
            else       nx = cur.x + dx1[i], ny = cur.y + dy1[i];
            if(nx < 0 || nx > 2*lx || ny < 0 || ny > 2*ly) continue;
            if(exist[nx][ny]) continue;
            if(rec[nx][ny][(cur.t+1)%6] > rec[cur.x][cur.y][cur.t] + (dir != i)) {
                rec[nx][ny][(cur.t+1)%6] = rec[cur.x][cur.y][cur.t] + (dir != i);
                /*
                if(nx-lx >= 0 && ny-ly >= 0)
                    printf("(%lld, %lld) -> (%lld, %lld), time = %lld, cost = %lld\n",
                    cur.x-lx, cur.y-ly, nx-lx, ny-ly, cur.t+1, rec[nx][ny][(cur.t+1)%6]);
                */
                q.push(Elem{nx, ny, (cur.t+1)%6});
            }
        }

        // stay
        if(rec[cur.x][cur.y][(cur.t+1)%6] > rec[cur.x][cur.y][cur.t] + 1) {
            rec[cur.x][cur.y][(cur.t+1)%6] = rec[cur.x][cur.y][cur.t] + 1;
            q.push(Elem{cur.x, cur.y, (cur.t+1)%6});
        }
    }

    int ans = INF;
    rep(i,0,6) chmin(ans, rec[gx][gy][i]);
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5440
use std::cmp::Reverse;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("No Line");
    buffer
}
fn read_lines<R, T: Fn(&str)->R> (count: usize, transformer: T) -> Vec<R> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(transformer(buffer.trim()));
        buffer.clear();
    }
    vec
}
fn read_value<T: std::str::FromStr>() -> T {
    read_line().trim().parse().ok().unwrap()
}
fn read_values<T: std::str::FromStr>() -> Vec<T> {
    read_line().trim().split(' ').map(|x| x.parse().ok().expect("Can't Parse")).collect::<Vec<T>>()
}
fn read_tabulate<T: std::str::FromStr>(count: usize) -> Vec<T> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(buffer.trim().parse().ok().expect("Can't Parse"));
        buffer.clear();
    }
    vec
}
macro_rules! assign {
    () => {};
    ($($token:tt)*) => {
        let mut iter = read_values::<String>().into_iter();
        assign_iter!(iter, $($token)*);
    };
}
macro_rules! assign_iter {
    ($iter:expr) =>{};
    ($iter:expr,) =>{};
    ($iter:expr, $id:ident:$t:tt $($tail:tt)*) => {
        let $id: $t = $iter.next().unwrap().parse().ok().expect("Can't Parse");
        assign_iter!($iter, $($tail)*);
    };
    ($iter:expr, mut $id:ident:$t:tt $($tail:tt)*) => {
        let mut $id: $t = $iter.next().unwrap().parse().ok().expect("Can't Parse");
        assign_iter!($iter, $($tail)*)
    };
}
macro_rules! freeze {
    ($($id:ident), *) => {
        $(let $id = $id;)*
    };
}
fn main() {
    assign! {
        n: usize
    }
    let mut players = read_values::<usize>();
    players.sort_by_key(|&v| Reverse(v));
    let players = players;
    let mut heap = BinaryHeap::new();
    heap.push(players[0]);
    let mut max_confort = 0i64;
    for p in 1 .. n {
        let player = players[p];
        let max = heap.pop().unwrap();
        max_confort += max as i64;
        heap.push(player);
        heap.push(player);
    }
    println!("{}", max_confort);
}

Measured memory_bytes: 6916
cup_cost = list(map(int, input().split()))
cost = [cup_cost[0]*8, cup_cost[1]*4, cup_cost[2]*2, cup_cost[3]]
l = [250, 500, 1000, 2000]
A = int(input())*1000

price = 0
while True:
  if A == 0:
    break;

  if A >= 2000:
      ind = cost.index(min(cost[:]))
  elif A >= 1000:
      ind = cost.index(min(cost[:-1]))
  elif A >= 500:
      ind = cost.index(min(cost[:-2]))
  else:
      ind = cost.index(min(cost[:-3]))
      
  cup_cnt = int(A/l[ind])
  price += cup_cnt * cup_cost[ind]
  A -= l[ind] * cup_cnt
    

print(price)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    long b = sc.nextLong();
    long n = sc.nextLong();
    long x = Math.min(b - 1, n);
    long res = (a*x)/b - a*(x/b);
    System.out.println(res);
    sc.close();
  }
}

Measured memory_bytes: 35680
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
    int N;
    cin>>N;
    bool exist=false;
    int p=N/4;
    if(N/4!=0){
        p++;
    }
    
    rep(x,p+1){
        rep(i,p+1){
            if(N==4*i+7*(x-i)){
                exist=true;
            }
        }
        
    }
    if(exist==true){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
  
   
}

Measured memory_bytes: 3612
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int H = scanner.nextInt();
    int W = scanner.nextInt();
    int h = scanner.nextInt();
    int w = scanner.nextInt();
    System.out.println((H - h) * (W - w));
  }

}


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

int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  int AC = 0, TLE = 0, WA = 0, RE = 0;
  for(int i = 0; i < N; i++){
    if(vec.at(i) == "AC"){
      AC++;
    }
    else if(vec.at(i) == "TLE"){
      TLE++;
    }
    else if(vec.at(i) == "WA"){
      WA++;
    }
    else{
      RE++;
    }
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}

Measured memory_bytes: 6428
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int N;
	cin >> N;
	VI t(N), x(N), y(N);
	REP(i, N) cin >> t[i] >> x[i] >> y[i];
	int tp = 0, xp = 0, yp = 0;

	string S = "Yes";
	REP(i, N) {
		if (t[i] - tp < abs(x[i] - xp) + abs(y[i] - yp)) {
			S = "No";
			break;
		}
		//if (t[i] - tp == abs(x[i] - xp) + abs(y[i] - yp));
		if (t[i] - tp > abs(x[i] - xp) + abs(y[i] - yp)) {
			if (((t[i] - tp) - (abs(x[i] - xp) + abs(y[i] - yp))) % 2 == 1) {
				S = "No";
				break;
			}
		}
		tp = t[i];
		xp = x[i];
		yp = y[i];
	}
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_bacm
#define mp mame_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int k;
    cin >> k;
    ll s = 0;
    for (int i = 1; i <= k; i++){
        for (int j = 1; j <= k; j++){
            for (int d = 1; d <= k; d++){
                s += gcd(i, gcd(j, d));
            }
        }
    }
    cout << s << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3580
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((a==5 || a==7)&&(b==5 || b==7)&&(c==5|| c==7)&&(a+b+c==17))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

Measured memory_bytes: 1664