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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

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

    vector<pi> s;
    //c?????????d?????????????????¨??????
    rep(i,m)
    {
        int c,d;
        scanf(" %d %d",&c,&d);
        if(c<d) s.pb(pi(c,d));
    }

    sort(all(s));

    int ans=n+1;
    int back=s[0].fi;
    int now=s[0].se;

    if(m>0)
    {
        rep(i,m-1)
        {
            if(now<s[i+1].fi)
            {
                ans+=2*(now-back);

                back=s[i+1].fi;
                now=s[i+1].se;
            }
            else
            {
                now=max(now,s[i+1].se);
            }
        }
        ans+=2*(now-back);
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
        long long int A,B, C, D,E,F;
        long long int Aa[10000000] = {};
        string S,Sa,Sb,Sc;
        cin >> A >> B >> C >> D;
        if(A > B){
          cout << B * C + (A - B) * D << endl; 
        }
        else cout << A * C << endl;
    
        return 0;
}


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

using namespace std;
typedef long long ll;
const int MAXN = 1000100;

int N, M;
int arr[MAXN];
ll pbest[MAXN], sbest[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);
    
    cin >> M;
    N = 3 * M;
    for (int i = 0; i < N; i++)
        cin >> arr[i];

    ll ctot = 0;
    multiset <int> s;
    for (int i = 0; i < N; i++)
    {
        ctot += arr[i];
        s.insert(arr[i]);
        if (i >= M)
        {
            auto it = s.begin();
            ctot -= *it;
            s.erase(it);
        }
        pbest[i] = ctot;
    }

    ctot = 0;
    s.clear();
    for (int i = N - 1; i >= 0; i--)
    {
        ctot += -arr[i];
        s.insert(-arr[i]);
        if (i < 2 * M)
        {
            auto it = s.begin();
            ctot -= *it;
            s.erase(it);
        }
        sbest[i] = ctot;
    }

    ll ans = -1e15;
    for (int i = M - 1; i < 2 * M; i++)
        ans = max (ans, pbest[i] + sbest[i+1]);
    cout << ans << "\n";
}

Measured memory_bytes: 17280
INF = 10 ** 5 + 5
is_prime = [1] * INF

def eratorasu():
    is_prime[0] = 0
    is_prime[1] = 0
    for i in range(2, INF):
        if is_prime[i] == 0:
            continue
        for j in range(i * 2, INF, i):
            is_prime[j] = 0
    return
eratorasu()
X = int(input())
for i in range(X, INF):
    if is_prime[i] == 1:
        print(i)
        exit()

Measured memory_bytes: 3828
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var N = cin.ReadInt();
            var min = 114514;
            for (int i = 0; i < N; ++i)
            {
                var A = cin.ReadInt();
                var c = 0;
                while (A % 2 == 0 && A != 0) { A >>= 1; ++c; }
                min = Min(min, c); 
                //Error.WriteLine(A);
            }  
            WriteLine(min);
        }  
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  char a = s[0], b = s[s.length() - 1];
  cout << a << s.length()-2 << b << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
grid = [list(map(int, input().split())) for i in range(2)]
tempSum = sum(grid[0]) + grid[1][n-1]
maxCandy = tempSum
for i in range(n-1):
    tempSum = tempSum - grid[0][n-1-i] + grid[1][n-2-i]
    if tempSum > maxCandy:
        maxCandy = tempSum
print(maxCandy)



Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

L, R, d = inm()


def solve():
    r = R // d
    l = (L - 1) // d
    return r - l


print(solve())


Measured memory_bytes: 9180
n,k = map(int,input().split())
mod = 10**9+7
num_gcd = [0]*(k+1)
for i in range(1,k+1)[::-1]:
    num = pow(k//i,n,mod)
    for j in range(2,k//i+1):
        num -= num_gcd[i*j]
    if num < 0:
        num += mod
    num_gcd[i] = num
ans = 0
for i in range(1,k+1):
    ans += i*num_gcd[i]
    ans %= mod
print(ans)

Measured memory_bytes: 74492
#include <algorithm>
#include <vector>
#include<stdio.h>
#include <iostream>
#include<map>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
const int MAX_NODES = 5005;
const int INF = 2147483647;
ll mapa[MAX_NODES][MAX_NODES];
int nodes = MAX_NODES, src, dest;
int dist[MAX_NODES], cola[MAX_NODES], usa[MAX_NODES];
struct E{
  int to, rev;
  ll flow, cap;
};
vector<E> gR[MAX_NODES];
void addEdge(int a, int b, ll c_to,ll c_rev){
  E e1 = {b, gR[b].size(), 0, c_to};
  E e2 = {a, gR[a].size(), 0, c_rev};
  gR[a].push_back(e1);
  gR[b].push_back(e2);
}
bool dinicBfs() {
  fill (dist,dist+nodes,-1);
  dist[src]=0;
  int fin=-1;
  cola[++fin]=src;
  int ini=0;
  while (ini<=fin){
    int u=cola[ini++];
    for (int i=0; i<(int)gR[u].size(); i++){
        E &e=gR[u][i];
        int v=e.to;
        if (dist[v]<0 && e.flow<e.cap){
            dist[v]=dist[u]+1;
            cola[++fin]=v;
        }
    }
  }
  return (dist[dest] >= 0);
}
ll dinicDfs(int u, ll f){
  if (u == dest) return f;
  for (int &i = usa[u]; i < (int) gR[u].size(); i++) {
    E &e = gR[u][i];
    if (e.cap <= e.flow) continue;
    int v = e.to;
    if (dist[v] == dist[u] + 1) {
      ll df = dinicDfs(v, min(f, e.cap - e.flow));
      if (df > 0) {
        e.flow += df;
        gR[v][e.rev].flow -= df;
        return df;
      }
    }
  }
  return 0;
}
ll maxFlow(int _src, int _dest) {
  src = _src;
  dest = _dest;
  ll res = 0;
  while (dinicBfs()) {
    fill(usa, usa + nodes, 0);
    ll delta = dinicDfs(src, INF);
    res += delta;
  }
  return res;
}

int main() {

    int n,m,x,y;
    ll c;
    scanf("%d%d",&n,&m);
    nodes=n;
    for (int i=0; i<m; i++){
        scanf("%d%d%lld",&x,&y,&c);
        if (x!=y){
            mapa[x][y]+=c;
        }
    }
    for (int i=0; i<n; i++){
        for (int j=0; j<n; j++){
            if (mapa[i][j]>0) {
                addEdge(i,j,mapa[i][j],mapa[j][i]);
                mapa[i][j]=0; mapa[j][i]=0;
            }
        }

    }
    printf("%lld\n",maxFlow(0,n-1));
}

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

int main(){

  int D; cin >> D;

  if(D == 22) cout << "Christmas Eve Eve Eve" << endl;
  if(D == 23) cout << "Christmas Eve Eve" << endl;
  if(D == 24) cout << "Christmas Eve" << endl;
  if(D == 25) cout << "Christmas" << endl;

  return 0;

}

Measured memory_bytes: 256
H, W = map(int, input().split())
ans = min(H, W)

if H % 3 == 0 or W % 3 == 0:
    ans = 0
    print(ans)
    exit()

for h in range(H // 3, H //2+1):
    w = W // 2
    s1 = h * W
    s2 = (H - h) * w
    s3 = (H - h) * (W - w)
    ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))

for w in range(W // 3, W //2+1):
    h = H // 2
    s1 = w * H
    s2 = (W - w) * h
    s3 = (W - w) * (H - h)
    ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))

print(ans)

Measured memory_bytes: 3064
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int bf;

		String str = br.readLine();
		String[] array = str.split(" ");

		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);
		int c = Integer.parseInt(array[2]);

		if(a > b){
			bf = a;
			a = b;
			b = bf;
		}
		if(b > c){
			bf = b;
			b = c;
			c = bf;
		}
		if(a > b){
			bf = a;
			a = b;
			b = bf;
		}

		System.out.println(a + " " + b + " " + c);
	}
}

Measured memory_bytes: 24232
n,k=map(int,input().split())
a=list(map(int,input().split()))
def gcd(a,b):
  while b:a,b=b,a%b
  return a
g=a[0]
for i in a:g=gcd(g,i)
if max(a)>=k and k%g==0:print("POSSIBLE")
else:print("IMPOSSIBLE")

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

#pragma GCC diagnostic warning "-Wconversion"

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) begin(a), end(a)
#define has(a, b) (a.find(b) != a.end())
#define fora(i, n) for(int i = 0; i < n; i++)
#define forb(i, n) for(int i = 1; i <= n; i++)
#define forc(a, b) for(const auto &a : b)
#define ford(i, n) for(int i = n; i >= 0; i--)
#define maxval(t) numeric_limits<t>::max()
#define minval(t) numeric_limits<t>::min()
#define imin(a, b) a = min(a, b)
#define imax(a, b) a = max(a, b)

#define dbgs(x) #x << " = " << x
#define dbgs2(x, y) dbgs(x) << ", " << dbgs(y)
#define dbgs3(x, y, z) dbgs2(x, y) << ", " << dbgs(z)
#define dbgs4(w, x, y, z) dbgs3(w, x, y) << ", " << dbgs(z)

using ll = long long;

int data[10];

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

        int N;
        cin >> N;

        fora(i, N)
        {
                int r;
                cin >> r;
                data[min(r / 400, 8)]++;
        }

        ll res = 0;
        fora(i, 8)
        {
                if (data[i] != 0)
                        ++res;
        }

        cout << max(1LL, res) << " " << res + data[8] << endl;
}


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

int main(void) {
	long long H, W;
	cin >> H >> W;
	if (H > W)  swap(H, W);
	if (H==1) {
		cout << 1 << endl;
	} else {
		cout << (H*W+1) / 2 << endl;
	}
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        HashMap<String, Long> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String s = scan.next();
            char[] d = s.toCharArray();
            Arrays.sort(d);
            String sorted = new String(d);
            if (!map.containsKey(sorted)) {
                map.put(sorted, 0L);
            }
            long count = map.get(sorted);
            map.put(sorted, count + 1);
        }
        long answer = 0;
        for (String x : map.keySet()) {
            long count = map.get(x);
            if (count == 1) {
                continue;
            }
            answer += count * (count - 1) / 2;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 52752
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int train , taxi;
		if((train = sc.nextInt() * sc.nextInt()) < (taxi = sc.nextInt())) {
			System.out.println(train);
		} else {
			System.out.println(taxi);
		}
		sc.close();
	}

}


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

#define ll long long
const int MOD = 1e9 + 7;
int main() {
	ll n, ans = 1;
	cin >> n;
	for (int i=1; i<=n; i++) {
		ans*=i;
		if (ans >= MOD)
			ans %= MOD;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3544
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1e9+7;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    // 上位ふたつを求める
    vector<ll> B = A;
    sort(B);
    ll mx0 = B[B.size() - 1];
    ll mx1 = B[B.size() - 2];
    //
    rep(i, N)
    {
        ll a = A[i];
        if (a != mx0)
        {
            cout << mx0 << endl;
        }
        else
        {
            cout << mx1 << endl;
        }
    }

    //
    return 0;
}

Measured memory_bytes: 5936
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  
  switch(n % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      puts("hon");
      break;
      
    case 0:
    case 1:
    case 6:
    case 8:
      puts("pon");
      break;
      
    default:
      puts("bon");
      break;
  }
  
  return 0;
}

Measured memory_bytes: 1640
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

// ABC095 at 2018/04/24

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solveB();
    }

    private void solveA() {
        Scanner sc = new Scanner(System.in);
        char[] N = sc.nextLine().toCharArray();
        int result = 700;
        for (char c : N) {
            if ("o".equals(String.valueOf(c))) {
                result += 100;
            }
        }
        System.out.println(result);
    }

    private void solveB() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int cnt = 0;
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            list.add(sc.nextInt());
        }
        for (Integer integer : list) {
            X -= integer;
            cnt++;
        }

        Collections.sort(list);
        int min = list.get(0);
        while(min <= X) {
            X -= min;
            cnt++;
        }
        System.out.println(cnt);

    }

    private void solveC() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveD() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveE() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveF() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

}

Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <limits>
using namespace std;
 
int main(){
    int n, l;
    cin >> n >> l;
    string s[n];
    string ans;
    for(size_t i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    sort(s, s+n);
    
    for(size_t i = 0; i < n; i++)
    {
        ans += s[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long q, h, s, d;
  long long N;
  cin>>q>>h>>s>>d>>N;
  long long ONE=min(4*q,min(2*h,min(2*q+h,s)));
  long long TWO=min(d,ONE*2);
  cout<<N/2*TWO+N%2*ONE<<endl;
}

Measured memory_bytes: 3632
#include <cstdio>

int main ()
{
    char c;
    int i=0;
    while (scanf("%c",&c)!=EOF)
  {
    i++;
    if (c=='\n')
    {
        printf("\n");
        i=0;
        continue;
    }
    if (i%2!=0)
      printf("%c",c);
  }
  return 0;
}

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

using namespace std;
int main(){
    int n;cin>>n;
    string S;cin>>S;
    ll r=0,g=0,b=0;
    for(auto c:S){
        if(c=='R')++r;
        else if(c=='G')++g;
        else ++b;
    }
    ll all=r*g*b;
    ll sub=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(S[i]==S[j])continue;
            int k=j*2-i;
            if(k>=n|| S[j]==S[k]||S[k]==S[i])continue;
            sub++;
        }
    }
    cout<<all-sub<<endl;
}


Measured memory_bytes: 3592
import sys
import itertools

readline = sys.stdin.readline

def main():
    N = int(input())
    P = tuple(map(int, readline().split()))
    Q = tuple(map(int, readline().split()))
    
    dictN = list(itertools.permutations(range(1, N+1)))
    p = dictN.index(P)
    q = dictN.index(Q)
    ans = abs(p-q)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 8052
data = []
i = 0
readlines.each do |l|
	d = 1
	temp = []
	l.chars do |c|
		if !(c =~ /[0-9]/)
			next if temp.empty?	
			data[i] = temp.map.with_index{|n,i| n*(10**i)}.inject{|x,y| x+y} 
			temp.clear
			i += 1
			data[i] = 0
		else
			temp.unshift(c.to_i)
		end
	end
end
puts data.inject{|x,y| x+y} 

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main() {
  int N;
  cin>>N;
  int dp[100001][3] = {0};
  int A[100001][3];
  for(int i(0);i<N;i++){
    cin>>A[i+1][0]>>A[i+1][1]>>A[i+1][2];
  }
  for(int i(1);i<=N;i++){
    for(int j(0);j<3;j++){
      for(int k(0);k<3;k++){
        if(j != k){
          dp[i][j] = max(dp[i][j],dp[i-1][k] + A[i][k]);
        }
      }
    }
  }
  cout << max({dp[N][0],dp[N][1],dp[N][2]}) << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while(cin>>n && n){
        n/=4;
        int ans=0;
        rep(i,n){
            int x;cin>>x;
            ans+=x;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1156
#include<iostream>

using namespace std;

int N;

int main() {
    cin >> N;
    long ans = 0;
    if(N > 1) {
        for (int i = 1; i < N+1; i++) {
            if (i == 1) {
                ans += 1;
            } else if (i == N) {
                ans += 0;
            } else {
                ans += (long)(i);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int n;
    cin >> n;
    int arr[n];
    int i;
    for(i=0;i<n;i++)
        cin >> arr[i];
    int ans = 0;
    int j, k;
    for(i=0;i<n;i++)
        for(j=i+1;j<n;j++)
            for(k=j+1;k<n;k++)
            {
                if(arr[i] + arr[j] > arr[k] && arr[i] + arr[k] > arr[j] && arr[j] + arr[k] > arr[i] && arr[i] != arr[j] && arr[i] != arr[k] && arr[j] != arr[k])
                    ans++;
            }
    cout << ans;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(void) {

	string N;
	cin >> N;

	bool good = true;
	for (int i = 1; i < 3; i++) {
		if (N[0] != N[i]) {
			good = false;
			break;
		}
	}

	if (!good) {
		good = true;
		for (int i = 2; i < 4; i++) {
			if (N[1] != N[i]) {
				good = false;
				break;
			}
		}
	}

	cout << (good ? "Yes": "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <complex>
#include <set>
#include <iomanip>
#include <cstring>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;


double dp[310][310][310];
int n;

double rec(int n1, int n2, int n3) {
    if (dp[n1][n2][n3] >= 0) return dp[n1][n2][n3];
    if (n1 == 0 and n2 == 0 and n3 == 0) return 0.0;

    double res = 0.0;
    if (n1 > 0) res += rec(n1-1, n2, n3) * n1;
    if (n2 > 0) res += rec(n1+1, n2-1, n3) * n2;
    if (n3 > 0) res += rec(n1, n2+1, n3-1) * n3;
    res += n;
    res *= 1.0 / (n1 + n2 + n3);

    return dp[n1][n2][n3] = res;

}

int main() {
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int one = 0, two = 0, three = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == 1) ++one;
        else if (a[i] == 2) ++two;
        else ++three;
    }

    memset(dp, -1, sizeof(dp));

    cout << fixed << setprecision(10) << rec(one, two, three) << endl;

    return 0;
}

Measured memory_bytes: 233088
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

int main(){ _

	int N;
	cin >> N;

	ll ans = N*800 - (N/15)*200;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3588
import collections


N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

d = collections.Counter(D)
t = collections.Counter(T)

F  = True
dk = d.keys()

for tk in t.keys():
    if tk in dk == False:
        F = False
        break
    elif d[tk] < t[tk]:
        F = False
        break

if F:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 57056
import math
a,b,x = list(map(int,input().split()))
bottle = a**2*b
##水の入っていない量について(水が半分以上入っている)
if x>bottle/2:
    p_bottle = bottle-x
    tanx = p_bottle/(a**3)*2
    ans = math.degrees(math.atan(tanx))
else:
    #a*(b**2*tan(90-x))=x
    tan90x=x/(a*b**2)*2
    ans = 90-math.degrees(math.atan(tan90x))
print("{:.10f}".format(ans))

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-9
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
double dist(ll x,ll y){
	return sqrt(x*x+y*y);
}
ll naiseki(ll x1,ll y1,ll x2,ll y2){
	return x1*x2+y1*y2;
}
int main(){
	int N;
	ll x[101],y[101];
	vector<pair<double,pll> > arg;
	scan(N);
	rep(i,N){
		scan(x[i]>>y[i]);
		arg.push_back({atan2(y[i],x[i]),{x[i],y[i]}});
	}
	double ans=0;
	sort(ALL(arg));
	rep(i,N){
		ll oldx=0,oldy=0;
		rep(j,N){
			ll newx=arg[(i+j)%N].second.first,newy=arg[(i+j)%N].second.second;
			ll nowx=oldx+newx,nowy=oldy+newy;
			oldx=nowx,oldy=nowy;
			ans=max(ans,dist(nowx,nowy));
		}
	}
	prin(setprecision(12)<<ans);
	return 0;
}


Measured memory_bytes: 384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    p=LIST()

    p_=p.copy()
    p_.sort()

    t=0
    for i in range(n):
        if p[i]!=p_[i]:
            t+=1

    if t<=2:
        print('YES')
    else:
        print('NO')

if  __name__=='__main__':
    main()

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.length();

    bool flag = true;
    for(int i = 0 ; i < (n + 1) / 2 ; i++)
    {
        if(s[i] != s[n - i - 1])
        {
            flag = false;
            break;
        }
    }
    if(!flag)
    {
        printf("No\n");
        return 0;
    }

    for(int i = 0 ; i < (n + 1) / 2 / 2 - 1 ; i++)
    {
        if(s[i] != s[(n + 1) / 2 - i - 2])
        {
            flag = false;
            break;
        }
    }
    if(!flag)
    {
        printf("No\n");
        return 0;
    }

    for(int i = (n + 3) / 2 - 1 ; i < (2 * n + n + 3) / 2 / 2 ; i++)
    {
        if(s[i] != s[(3 * n + 3) / 2 - 2 - i])
        {
            flag = false;
            break;
        }
    }
    if(!flag)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>

#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
    for (T x : s)
        cout << x << " ";
    cout << endl;
}

int main(){
    srand(17);
    ios_base::sync_with_stdio(0);
    int a, b, n;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>

using namespace std;

int main(){
        int x,h;
        cin >> x >> h;
        while(x||h){
                printf("%.6f\n",2*x*pow((double)x*x/4+(double)h*h,0.5)+x*x);
                cin >> x >> h;
        }   
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int A, B;
    cin >> A >> B;
    cout << 6 - A - B << endl;
    return 0;
};

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define v vector
#define mp make_pair
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e9+7;
int ll_max=1e6;
int main() {
	// your code goes here
	IOS;
	int64_t n,x;
	
	ll i,j,m,k,sum=0;
      cin>>n;
      v<char> a;
      while(n>0){
            x=n%(int64_t)26;
            
            if(x>0){
                  x--;
            a.pb('a'+x);
            n/=(int64_t)26;
            }
            else{
            a.pb('z');
            n/=(int64_t)26;
            n--;
            }
            
            
      }
      for(i=a.size()-1;i>=0;i--){
            cout<<a[i];
      }
	return 0;
}

Measured memory_bytes: 3620
//
//  number_even_pairs.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
using namespace std;

int main(int argc, const char* argv[]) {
  int n, m;
  std::cin >> n >> m;

  std::cout << n*(n-1)/2 + m*(m-1)/2 << std::endl; // combination of 2 n, and combination of 2 m
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.swing.*;


import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 998244353;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        String s = in.next();
        out.println(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5) ? "Yes" : "No");
    }


}



class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


Measured memory_bytes: 22868
from collections import deque
H, W = map(int, input().split())
G = [list(input()) for i in range(H)]


def calc(sh, sw):
    dist = [[float('inf')] * W for i in range(H)]
    directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
    dist[sh][sw] = 0
    que = deque([[sh, sw]])

    while que:
        sh, sw = que.pop()
        for dh, dw in directions:
            if not ((0 <= sh + dh < H) and (0 <= sw + dw < W)):
                continue

            if G[sh + dh][sw + dw] == '#':
                continue

            if dist[sh + dh][sw + dw] != float('inf'):
                continue

            dist[sh + dh][sw + dw] = dist[sh][sw] + 1
            que.appendleft([sh + dh, sw + dw])

    ret = 0
    for d in dist:
        for w in range(W):
            if d[w] == float('inf'):
                continue
            ret = max(ret, d[w])

    return ret


ans = 0
for sh in range(H):
    for sw in range(W):
        if G[sh][sw] == '#':
            continue
        ans = max(ans, calc(sh, sw))

print(ans)


Measured memory_bytes: 3316
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int x;
  int cnt = 1;
  while (cin >> x) {
    if (x == 0) {
      return 0;
    }
    cout << "Case " << cnt << ": " << x << '\n';
    ++cnt;
  }

  return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;

int power(ll n, ll p) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        ll t = power(n, p / 2);
        return t * t % MOD;
    }
    return n * power(n, p - 1) % MOD;
}

int nCr(int n, int r) {
    ll x = 1, y = 1;
    rep(i, r) {
        x = x * (n - i) % MOD;
        y = y * (i + 1) % MOD;
    }
    return x * power(y, MOD - 2) % MOD;
}

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

    ll ans = power(2, n) - 1 - nCr(n, a) - nCr(n, b);

    cout << (ans % MOD + MOD) % MOD << endl;
    return 0;
}


Measured memory_bytes: 3584
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve()
}

func resolve() {
	o, e := scanString(sc), scanString(sc)
	build := &strings.Builder{}
	for i := range loop1(len(o) + len(e)) {
		if i%2 == 1 {
			build.WriteByte(o[i/2])
		} else {
			build.WriteByte(e[(i-1)/2])
		}
	}
	fmt.Println(build.String())
}

func loop0(n int) chan int {
	return loop(0, n-1, 1)
}

func loop1(n int) chan int {
	return loop(1, n, 1)
}

func loop(s, e, d int) chan int {
	ch := make(chan int)
	go func() {
		for i := s; i <= e; i += d {
			ch <- i
		}
		close(ch)
	}()
	return ch
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1800
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;
typedef pair<long long, long long> pll;
// scanf("%d %d %d %d", &w, &b, &d, &s); %lld
// printf("%d\n", points);
// const double PI = acos(-1);

int main()
{
    #ifdef LOCAL
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    #else
        fastIO;
    #endif
    ll n, b, r, ans;
    cin >> n >> b >> r;
    if(n%(b+r) > b)
        ans = n/(b+r)*b+b;
    else
        ans = (n/(b+r)*b) + n%(b+r);

    cout << ans << endl;
  
    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
int main(){
  int n,m,b,i,j;
  int N[10][7]={
    {0,1,1,1,1,1,1},
    {0,0,0,0,1,1,0},
    {1,0,1,1,0,1,1},
    {1,0,0,1,1,1,1},
    {1,1,0,0,1,1,0},
    {1,1,0,1,1,0,1},
    {1,1,1,1,1,0,1},
    {0,1,0,0,1,1,1},
    {1,1,1,1,1,1,1},
    {1,1,0,1,1,1,1}
  };
  while(1){
    scanf("%d",&n);
    if(n==-1)break;
    for(i=0;i<n;i++){
      scanf("%d",&m);
      for(j=0;j<7;j++){
	if(i==0)printf("%d",N[m][j]);
	else{
	  if(N[m][j]==N[b][j])printf("0");
	  else                printf("1");
	}
      }
      b=m;
      printf("\n");
    }
  }
  return 0;
}

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

int main(void){
    int n;
    std::cin >> n;

    std::vector<int> a(n), b(n), c(n-1);

    for(int i = 0; i < n; i++){
        std::cin >> a.at(i);
    }
    for(int i =0; i < n; i++){
        std::cin >> b.at(i);
    }
    for(int i = 0; i < n - 1; i++){
        std::cin >> c.at(i);
    }
    
    int temp = -2;
    int ans = 0;

    for(int i = 0; i < n; i++){
        ans += b.at(a.at(i) - 1);
        if(1 + temp == a.at(i)){
            ans += c.at(temp - 1);
        }
        temp = a.at(i);
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

string s;

int main(){
  cin >> s;
  vector<string> v;
  REP(i, s.size()) {
    if(s[i] == 'A') {
      continue;
    } else if(s[i] == 'B' && i < s.size() - 1 &&  s[i + 1] == 'C') {
      i++;
    } else {
      s[i] = 'D';
    }
  }
  s += 'D';

  int i = 0;
  int prev = 0;
  REP(i, s.size()) {
    if(s[i] == 'D') {
      v.pb(s.substr(prev, i - prev + 1));
      prev = i;
    }
  }

  ll ans = 0;
  REP(i, v.size()){
    int ct = 0;
    REP(j, v[i].size()){
      if(v[i][j] == 'A') ct++;
      else if (v[i][j] == 'B') ans += ct;
    }
  }

  cout << ans << endl;

  return 0;
}



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

int main() {
  string S;
  cin >> S;
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/abc126/tasks/abc126_c

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, t, cnt;
    cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= n; i++) {
        double tmp = 1.0 / n;
        t = i;
        cnt = 0;
        while (k > t) {
            t = t << 1;
            cnt++;
        }
        ans += tmp / (1 << cnt);
    }
    cout << setprecision(12) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#pragma warning(disable : 4996)
int H, W, h, w, a[509][509];
int main() {
	scanf("%d %d %d %d", &H, &W, &h, &w);
	if (h == 1 && w == 1) printf("No\n");
	else {
		int x = 999999999 / (h * w - 1); long long sum = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if ((i + 1) % h == 0 && (j + 1) % w == 0) a[i][j] = -((h * w - 1) * x + 1);
				else a[i][j] = x;
				sum += a[i][j];
			}
		}
		if (sum <= 0) printf("No\n");
		else {
			printf("Yes\n");
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					printf("%d ", a[i][j]);
				}
				printf("\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
const int RANDOM1 = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return hash<int>{}(x ^ RANDOM1); }
};
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 100001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
int main()
{
    AKASH_PATEL;
    SVNIT_SURAT;
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    ll p[a],q[b],r[c];
    take_arr(p,a)
    take_arr(q,b)
    take_arr(r,c)
    sort(p,p+a);
    sort(q,q+b);
    sort(r,r+c);
    reverse(p,p+a);
    reverse(q,q+b);
    reverse(r,r+c);

    priority_queue <pii> v;
    fpr(i,0,x)
    {
        v.push({p[i],1});
        //cout<<p[i]<<" ";
    }
//    nl
    fpr(j,0,y)
    {
        v.push({q[j],2});
//        cout<<q[j]<<" ";
    }
//    nl;
    fpr(k,0,c)
    {
        v.push({r[k],3});
//        cout<<r[k]<<" ";
    }
//    nl
    ll sum=0,cnt=0,un=x+y;
    while (!v.empty())
    {
        pii pi=v.top();
        v.pop();
        ll val=pi.ff;
        //cout<<val<<" ";
        ll node=pi.ss;
        if(node==1)
        {
            if(x)
            {
                sum+=val;
                x--;
                cnt++;
            }
        }
        else if(node==2)
        {
            if(y)
            {
                sum+=val;
                y--;
                cnt++;
            }
        }
        else
        {
            sum+=val;
            cnt++;
        }
        if(cnt==(un))
        {
            break;
        }
    }
    print(sum)
    return 0;
}


Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
bool c(int x,int y){
    return y<x;
}
int main() {
    int n;cin>>n;
    vector<int > p(n);
    for (int i = 0; i < n; ++i)
        cin>>p[i];
    auto it=unique(p.begin(),p.end());
    p.erase(it,p.end());
    int q=p.size();
    for (int i=0 ;i<q-1;++i)
        cout<<p[i]<<" ";
    cout<<p[q-1]<<endl;
    return 0;
}



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

using namespace std;

int main() {
    unsigned long long n;
    cin >> n;
    unsigned long long result = 1;
    vector<unsigned long long> a(n);
    for (unsigned long long i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return EXIT_SUCCESS;
        }
    }

    long long div = 1000000000000000000;
    bool over = false;
    for (const auto& v : a) {
        div /= v;
        if (div < 1) {
            cout << -1 << endl;
            over = true;
            break;
        } 
        result *= v;
    }
    if (!over) {
        cout << result << endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	ll t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	if( a1 < b1 ){
		swap(a1, b1);
		swap(a2, b2);
	}
	// かならず a1 > b1
	ll d = (t1*a1+t2*a2) - (t1*b1+t2*b2);
	if( d == 0 ){
		cout << "infinity" << endl;
		return 0;
	}
	if( d > 0 ){
		cout << 0 << endl;
		return 0;
	}
	d *= (-1);
	ll a = t1*a1-t1*b1;
	ll p = (a+d-1)/d;
	ll ex = 0;
	if( (t1*a1-t1*b1)%d == 0 ) ex = 1;
	cout << p*2-1+ex << endl;
}

Measured memory_bytes: 256