akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/

using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, W;
    cin >> H >> W;

    map<int, int> s; // s[今]=開始の最大
    multiset<int> vals;

    for (int i = 0; i < W; i++)
        s[i] = i;
    for (int i = 0; i < W; i++)
        vals.insert(0);

    for (int i = 0; i < H; i++)
    {
        int l, r;
        cin >> l >> r;
        l--; // 半開区間
        auto it = s.lower_bound(l);
        int mr = -1;
        while (it != s.end() && it->first <= r)
        {
            mr = max(mr, it->second);
            int x = it->first - it->second;
            vals.erase(vals.find(x));
            s.erase(it++); // 消去してイテレータを進める
        }
        if (mr != -1 && r < W)
        {
            vals.insert(r - mr);
            s[r] = mr;
        }
        int ans = -1;
        if (vals.size() > 0)
        {
            ans = *vals.begin() + (i + 1);
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (n); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

  int ans = 0, temp = 1;
  rep0(i, 100) {
    if (temp >= B) break;
    ans++;
    temp += A - 1;
  }

  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import math
def isprime(x):
    if x == 2:
        return True
    
    if x < 2 or x % 2 == 0:
        return False
    
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return False
        i = i + 2
    return True

def eratos(n):
    isprime = [True for i in range(n+1)]
    isprime[0] = False
    isprime[1] = False
    for i in range(2, int(math.sqrt(n))+1):
        if isprime[i]:
            j = i + i
        while j <= n:
            isprime[j] = False
            j = j + i
    return isprime        

if __name__ == "__main__":
    # maxn = 10**8
    n = int(input())
    ans = 0
    # isprime = eratos(maxn)
    for i in range(n):
        x = int(input())
        ans += int(isprime(x))
        # ans += int(isprime[x])

    print(ans)



Measured memory_bytes: 5688
s=gets.chomp
n=s.size
u=true
i=0
cl,cg=0,0
c=0
while i<n
  if u&&s[i]=="<"
    cl+=1
  elsif u&&s[i]==">"
    cg+=1
    u=false
  elsif !u&&s[i]==">"
    cg+=1
  else
    if cl<cg
      c+=cg*(cg+1)/2+cl*(cl-1)/2
    else
      c+=cg*(cg-1)/2+cl*(cl+1)/2
    end
    u=true
    cl=1
    cg=0
  end
  i+=1
end
if cl<cg
  c+=cg*(cg+1)/2+cl*(cl-1)/2
else
  c+=cg*(cg-1)/2+cl*(cl+1)/2
end
puts c

Measured memory_bytes: 4876
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int n,K,i,j,k,Max,Gcd;

int main()
{
	scanf("%d%d",&n,&K);
	for(i=1;i<=n;++i)
	{
		scanf("%d",&k);
		if(k>Max)Max=k;
		Gcd=__gcd(Gcd,k);
	}
	if(K%Gcd==0&&K<=Max)printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();
		
		for (int i = 0; i <= N; i++) {
			int x = i * 10_000;
			for (int j = N - i; j >= 0; j--) {
				int y = j * 5_000;
				int z = (N - (j + i)) * 1000;
				if (x + y + z == Y) {
					System.out.println(i + " " + j + " " + (N - (j + i)));
					return;
				}
			}
		}
		
		System.out.println("-1 -1 -1");
	}
}


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

using namespace std;

#define mx 1000005
#define mod 998244353

long long cnt[mx],cntSum[mx], lcmSum[mx], modInv[mx];

long long bigmod(long long n, long long p){
    long long ret=1;
    while(p){
        if(p%2) ret=(ret*n)%mod;
        p/=2;
        n=(n*n)%mod;
    }
    return ret;
}

int main(){

    for(int i=1;i<mx;i++) modInv[i]=bigmod(i,mod-2);

    int t;
//    scanf("%d",&t);
    t=1;
    for(int z=1;z<=t;z++){

        memset(cnt,0,sizeof cnt);
        memset(cntSum,0,sizeof cntSum);
        memset(lcmSum,0,sizeof lcmSum);

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

        for(int i=1;i<mx;i++){
            long long pairSum=0,prefixSum=0;
            for(int j=i;j<mx;j+=i){
                pairSum=(pairSum+(prefixSum*cntSum[j])%mod)%mod;
                prefixSum=(prefixSum+cntSum[j])%mod;
            }
            lcmSum[i]=pairSum;
        }

        for(int i=mx-1;i>=1;i--) {
            long long sub=0;
            for(int j=i+i;j<mx;j+=i){
                sub=(sub+lcmSum[j])%mod;
            }
            lcmSum[i]=((lcmSum[i]-sub)%mod + mod)%mod;
        }

        long long ans=0;

        for(int i=1;i<mx;i++){
            ans=(ans+(lcmSum[i]*modInv[i])%mod)%mod;
            long long only_i = (i*(cnt[i]*(cnt[i]-1))/2)%mod;
            ans=(ans+only_i)%mod;
        }

//        printf("Case %d: %lld\n",z,ans);
        printf("%lld\n",ans);
    }

    return 0;
}


Measured memory_bytes: 35060
#include<bits/stdc++.h>
#define mod 1000000007

using namespace std;

using ll = long long;

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

 	ll n;
 	cin >> n;

 	ll cnt = 0;

 	for(ll i=1;i<=n;i++){
 		for(ll j=1;j<=n;j++){
 			for(ll k=1;k<=n;k++){
 				cnt = cnt + __gcd(i,(__gcd(j,k)));
 			}
 		}
 	}   

 	cout << cnt << "\n";
	return 0;
}

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

int main(){
  int N, min = 0, max, a[9] = {0};
  cin >> N;
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    if(x<400) a[0]++;
    else if(x<800) a[1]++;
    else if(x<1200) a[2]++;
    else if(x<1600) a[3]++;
    else if(x<2000) a[4]++;
    else if(x<2400) a[5]++;
    else if(x<2800) a[6]++;
    else if(x<3200) a[7]++;
    else a[8]++;
  }
  for(int i = 0; i < 8; i++)
    if(a[i] > 0) min++;
  max = min + a[8];
  if(a[8] == N){
    min = 1;
    max = N;
  }
  cout << min << " " << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <utility>
#include <limits.h>

#define DIRECTED true //有向か無向か
#define ull unsigned long long
#define mp(X , Y) make_pair(X , Y)

using namespace std;

bool operator>(const pair<ull,int> a, const pair<ull,int> b){
    return a.first > b.first;
}

class dijkstra{
public:
    int num;
    vector<ull> dist;
    vector<int> prev;

    vector<vector<pair<int,ull>>> side; 

    dijkstra(){
    }

    dijkstra(int n){

        num = n;
        //0オリジンとの混合を避けるため+1する
        for(int i = 0; i < n + 1; i++){
            dist.push_back(ULONG_LONG_MAX);
            prev.push_back(-1);
            vector<pair<int,ull>> v;
            side.push_back(v);
        }
    }

    void reset(){
        dist.clear();
        prev.clear();

        for(int i = 0; i < num + 1; i++){
            dist.push_back(ULONG_LONG_MAX);
            prev.push_back(-1);

        }
    }

    void input(int f, int t,ull d){

        side[f].push_back(mp(t, d));
        if(!DIRECTED) side[t].push_back(mp(f,d));
    }

    void search(int start){
        
        dist[start] = 0;
        prev[start] = 0;

        priority_queue<pair<ull,int>, vector<pair<ull,int>>, greater<pair<ull,int>>> pq;
        pq.push(mp(0,start));

        while(!pq.empty()){
            
            ull d = pq.top().first;
            int s = pq.top().second;

            for(auto itr = side[s].begin(); itr != side[s].end(); itr++){

                ull tmp_d = (*itr).second;
                int to = (*itr).first; 

                if(dist[to] > d + tmp_d){
                    dist[to] = d + tmp_d;
                    prev[to] = s;
                    pq.push(mp(d + tmp_d,to));
                }
            }

            pq.pop();
        }
    }

    ull min_distance(int to){
        return dist[to];
    }

};

int main(){

    int n,u,k;

    cin >> n;

    dijkstra dijk;
    dijk = dijkstra(n);

    for(int i = 0; i < n; i++){
        scanf(" %d %d",&u,&k);
        for(int j = 0; j < k; j++){
            int v;
            ull c;

            scanf(" %d %llu",&v,&c);

            dijk.input(u,v,c);

        }
    }

    dijk.search(0);
    for(int i = 0; i < n; i++){
        cout << i << " " << dijk.min_distance(i) << endl;
    }
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll n;
cin >> n;
ll h[n];
for (ll i = 0; i < n; i++) cin >> h[i];
for (ll i = n-1; i >0;i--){
    if((h[i-1]-h[i])>1){
        cout << "No" << endl;
        return 0;
    } else if (h[i - 1] - h[i] == 1) {
        h[i-1]--;
    } else
        continue;
}
cout << "Yes" << endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var abk = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var a = abk[0];
        var b = abk[1];
        var k = abk[2];
        var op1 = Min(a, k);
        a -= op1;
        k -= op1;
        var op2 = Min(b, k);
        b -= op2;
        k -= op2;
        Console.WriteLine($"{a} {b}");
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k;
string str;
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
void dec(int &a,int b) {a-=b; if(a<0) a+=MOD;}
int pow_mod(int a,int i)
{
    int s=1;
    while(i)
    {
        if(i&1) s=1LL*s*a%MOD;
        a=1LL*a*a%MOD;
        i>>=1;
    }
    return s;
}
int main()
{
    cin>>str;
    n=(int)str.size();
    if(n&1) {puts("No"); return 0;}
    for(int i=0;i<n/2;i++)
    {
        if(str[2*i]!='h'||str[2*i+1]!='i')
        {
            puts("No"); 
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

A = list(set(A))
N = len(A)
A.sort()

if K > max(A):
    print("IMPOSSIBLE")
    exit()

if N == 1:
    if A[0] == K:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()

min_diff = min([A[i] - A[i-1] for i in range(1,N)])

for i in range(N):
    if abs(A[i]-K) % min_diff == 0:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 14480
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int p[]=new int[N];
		for(int i=0;i<N;i++) {
			p[i]=in.nextInt();
		}
		int max=0;
		for(int i=0;i<N;i++) {
			max=Math.max(p[i], max);
		}
		int sum=0;
		for(int i=0;i<N;i++) {
			sum=p[i]+sum;
		}
		System.out.println(sum-max/2);
	}
}


Measured memory_bytes: 23124
#include <cstring>
#include <iostream>
#define MOD 1000000007
using namespace std;
int a[10005],f[1000005],lf[1000005],n;
long long lcm=1;
long long fpow(long long x,long long y){
 long long ans=1;
 while(y){
  if(y&1)ans=ans*x%MOD;
  x=x*x%MOD;
  y>>=1;
 }
 return ans;
}
void calc(int x){
 memset(f,0,sizeof(f));
 int x1=x;
 for(int i=2;x!=1&&i*i<=x1;i++){
  while(x%i==0)
   x/=i,f[i]++;
  lf[i]=max(lf[i],f[i]);
 }
 if(x!=1){
  f[x]++;
  lf[x]=max(lf[x],f[x]);
 }
}
int main(){
 cin>>n;
 for(int i=1;i<=n;i++){
  cin>>a[i];
  calc(a[i]);
 }
 long long ans=0;
 for(int i=2;i<=1e6;i++)
  lcm=lcm*fpow(i,lf[i])%MOD;
 for(int i=1;i<=n;i++)
  ans=(ans+lcm*fpow(a[i],MOD-2))%MOD;
 cout<<ans<<endl;
}

Measured memory_bytes: 7808
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
char mem[214514];
char t[214514];
char c[214514];
string s[214514];
int l[214514],r[214514];
int cnt[214514];
signed main(){
	ic(n) ic(q)
	sc(c)
	rep(0,i,q){
		cin>>l[i];
		cin>>r[i];
	}
	cnt[0]=0;	
	rep(1,i,n){
		if(c[i-1]=='A'&&c[i]=='C'){
			cnt[i]=cnt[i-1]+1;
		}
		else cnt[i]=cnt[i-1];
	}
	rep(0,i,q){
		c(cnt[r[i]-1]-cnt[l[i]-1])
	}
}			
			
			

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

int N;
double L;
int s[1145141];
int t[1145141];
double u[1145141];

bool check(double X) {
  double tank = L, tank1, tank2, tank3;
  int time = 0;
  for (int i=0; i<N; i++) {
    tank = min(tank + (s[i]-time)*X, L);
    tank = min(tank + (t[i]-s[i])*(X-u[i]), L);
    if (tank < 0.0) return false;
    time = t[i];
  }
  tank = min(tank + (86400-time)*X, L);
  tank1 = tank;
  time = 0;
  for (int i=0; i<N; i++) {
    tank = min(tank + (s[i]-time)*X, L);
    tank = min(tank + (t[i]-s[i])*(X-u[i]), L);
    if (tank < 0.0) return false;
    time = t[i];
  }
  tank = min(tank + (86400-time)*X, L);
  tank2 = tank;
  time = 0;
  for (int i=0; i<N; i++) {
    tank = min(tank + (s[i]-time)*X, L);
    tank = min(tank + (t[i]-s[i])*(X-u[i]), L);
    if (tank < 0.0) return false;
    time = t[i];
  }
  tank = min(tank + (86400-time)*X, L);
  tank3 = tank;
  return !(L > tank1 && tank1 > tank2 && tank2 > tank3);
}

int main() {
  while (1) {
    scanf("%d%lf", &N, &L);
    if (N == 0 && L == 0) return 0;

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

    double low = 0.0;
    double high = 1e7;
    for (int i=0; i<60; i++) {
      double mid = (low+high)/2;
      if (check(mid)) high = mid;
      else low = mid;
    }

    printf("%.10f\n", high);
  }
}

Measured memory_bytes: 4460
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N int
	var s string
	fmt.Scan(&N)
	for i := 1; i <= N; i++ {
		num := strconv.Itoa(i)
		if i%3 == 0 {
			s += " " + num
		} else {
			for _, d := range num {
				if d == '3' {
					s += " " + num
					break
				}
			}
		}
	}
	fmt.Println(s)
}



Measured memory_bytes: 7236
// ==============================================
// Library
// ==============================================
#define _CRT_SECURE_NO_WARNINGS

// When you are using the gcc compiler, you need only the following lines.
// #include <bits/stdc++.h>

// When you are using other compilers, you need the following line instead.
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

// If you use this function, "cin" speeds up.
// However, you can not mix "cin" and "scanf", "cout" and "printf".
void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ==============================================
// ==============================================

int main()
{
	fastIOS();
	
	int n, l;
	vector<string> S;

	cin >> n >> l;
	REP(i, n)
	{
		string tmp;
		cin >> tmp;
		S.push_back(tmp);
	}

	sort(S.begin(), S.end());

	REP(i, n)
	{
		cout << S[i];
	}
	cout << "\n";
}

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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

ll n;
ll h[100005];
ll ans[100005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    cin >> n;

    fr(i,1,n)
    {
        cin >> h[i];
    }

    ans[1] = 0;
    ans[2] = abs(h[1]-h[2]);

    fr(i,3,n)
    {
        ll x = abs(h[i]-h[i-1]);
        ll y = abs(h[i]-h[i-2]);

        ans[i] = min(ans[i-1]+x, ans[i-2]+y);
    }

    cout << ans[n] << endl;
}

Measured memory_bytes: 1792
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n;cin>>n;
    double s=0;
    rep(i,n){
        double a;cin>>a;
        s+=1/a;
    }
    cout<<fixed<<setprecision(10)<<1/s<<endl;
}

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

int main(){
    int N,t=0;
    cin>>N;
    vector<int>a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
        t^=a[i];
    }
    for(int i=0;i<N;i++){
        int ans=a[i]^t;
        cout<<(a[i]^t)<<" \n"[i==N-1];
    }
    return 0;
}

Measured memory_bytes: 4032
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main(void) {
	int h,w;
	cin >> h >> w;
	char grid[10][10];
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin >> grid[i][j];
		}
	}
	int i=0,j=0;
	while(i<h && j<w){
		int a=0,b=0;
		if(i+1<h && grid[i+1][j]=='#')a=1;
		if(j+1<w && grid[i][j+1]=='#')b=1;
		if((a==1 && b==0)||(a==0 &&b==1)){
			i+=a;
			j+=b;
		}else {
			cout << "Impossible" << endl;
			return 0;
		}
		if(grid[i-1][j]=='#'&&grid[i][j-1]=='#'){
			cout << "Impossible" << endl;
			return 0;
		}
		if(i+1==h && j+1==w){
			cout << "Possible" << endl;
			return 0;
		}
	}
	cout << "Impossible" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[55];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    sort(a,a+n);
    int sum=0;
    for(int i=n-1;i>=n-k;i--) sum+=a[i];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
public class Main {


  private static void solve() {
    int n = ni();
    double[] p = new double[n];
    for (int i = 0; i < n; i ++) {
      p[i] = nd();
    }
    
    double[][] dp = new double[n + 1][n + 1];
    dp[0][0] = 1;
    for (int i = 1; i <= n; i ++) {
      for (int j = 0; j <= i; j ++) {
        dp[i][j] += dp[i - 1][j] * (1 - p[i - 1]);
        if (j > 0)
          dp[i][j] += dp[i - 1][j - 1] * p[i - 1];
      }
    }
    
    double ret = 0;
    for (int i = n / 2 + 1; i <= n; i ++) {
      ret += dp[n][i];
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 129872
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
// #include <atcoder/all>

// using boost::multiprecision::cpp_int;
using namespace std;
// using namespace atcoder;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef pair<ll, ll> p;

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

ll lcm(ll a, ll b)
{
  ll g = gcd(a, b);
  return a / g * b;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];
  ll res = 1;
  rep(i, n) res = lcm(res, v[i]);

  cout << res << endl;
}


Measured memory_bytes: 3568
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var a = int.Parse(line[1]);
            var b = int.Parse(line[2]);
            var c = int.Parse(line[3]);
            var x = int.Parse(line[4]);
            if (n == 0 && a == 0 && b == 0 && c == 0 && x == 0) break;
            line = Console.ReadLine().Trim().Split(' ');
            var d = Array.ConvertAll(line, int.Parse);
            Console.WriteLine(getAns(n, a, b, c, x, d));
        }
    }
    public static int getAns(int n, int a, int b, int c, int x, int[] d)
    {
        var p = 0;
        if (d[0] == x) p++;
        if (p == n) return 0;
        for (int i = 1; i <= 10000; i++)
        {
            var x2 = (a * x + b) % c;
            if (d[p] == x2) p++;
            if (p == n) return i;
            x = x2;
        }
        return -1;
    }
}


Measured memory_bytes: 9204
/**
 *    author:  whohet
 *    created: 11-07-2020 17:32:59
**/

#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

signed main()
{
	//fasterthanlight;
	int n;
	cin >> n;
	int arr[n + 1] = {};
	for (int i = 1; i <= 100; i++)
	{
		for (int j = 1; j <= 100; j++)
		{
			for (int k = 1; k <= 100; k++)
			{
				int x = (i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i);
				if (x <= n)
					arr[x]++;
			}
		}
	}
	for (int i = 1; i <= n; i++)
		cout << arr[i] << endl;




	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

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

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    map<ll, ll> m;
    rep(_, n) {
        ll a, b;
        cin >> a >> b;
        m[a] += b;
    }
    ll f = 0;
    for (auto e : m) {
        f += e.second;
        if (f >= k) {
            cout << e.first << endl;
            ret();
        }
    }
}


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

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

    int n;
    cin >> n;
    int odd = 0;
    rep(i,n)
    {
        int k;
        cin >> k;
        odd += k%2;
    }

    cout << (int)(pow(3,n) - pow(2,n-odd)) << endl;
}




Measured memory_bytes: 384
#include <iostream>

using namespace std;

int n, s, a[100002], ps[100002];

int main() {
	cin >> n >> s;
	ps[0] = 0;
	for (int i = 1; i <= n; i++) {
	    cin >> a[i];
	    ps[i] = a[i] + ps[i - 1];
	}
	int l = 1, r = n;
	int ans = n + 1;
	while (l <= n) {
	    while (ps[r - 1] - ps [l - 1] >= s) r--;
	    if (r > n) break;
	    if (ps[r] - ps[l - 1] >= s) ans = min(ans, r - l + 1);
	    l++, r++;
	}
	cout << (ans <= n ? ans : 0) << endl;
}



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

#define mod 1000000007
#define ll long long int
ll totalWays(int* candies, int n, int k) {

	ll dp[n][k + 1];
	for (int i = 0; i <= k; i++) {
		dp[0][i] = candies[0] >= i ? 1 : 0;
	}

	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= k; j++) {
			if (j == 0) {
				dp[i][j] = dp[i - 1][j];
			}
			else {
				dp[i][j] = (mod + dp[i][j - 1] + dp[i - 1][j] - (j - 1 - candies[i] >= 0 ? dp[i - 1][j - 1 - candies[i]] : 0)) % mod;
			}
		}
	}

	return dp[n - 1][k];

}


int main() {
	int n, k;
	cin >> n >> k;
	int candies[n];
	for (int i = 0; i < n; i++) {
		cin >> candies[i];
	}
	cout << totalWays(candies, n, k) << endl;
}

Measured memory_bytes: 81268
M, K = map(int, input().split())
def binary_digits(n):
  cnt = 0
  while n != 0:
    cnt += 1
    n //= 2
  return cnt
if binary_digits(K) > M:
  print(-1)
else:
  if M == 1:
    if K == 1:
      print(-1)
    elif K == 0:
      print(0, 0, 1, 1)
  else:
    b = 2**(M+1)
    if K == 0:
      for i in range(b):
        if i != b - 1:
          print(i // 2, end = ' ')
        else:
          print(i // 2)
    else:
      A = [0 for i in range(b)]
      A[1], A[b//2+1] = K, K
      p = 1
      for i in range(1, b//2):
        if i != K:
          A[b//2-p+1], A[b//2+p+1] = i, i
          p += 1
      for i in range(b):
        if i != b - 1:
          print(A[i], end = ' ')
        else:
          print(A[i])

Measured memory_bytes: 11192
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
using namespace std;

const int INT__MAX = 2147483647;
const int MOD = 1000000007;

int main() {

	int N, count1 = 0, count2 = 0, count4 = 0;
	int a[100010];
	bool check;//true=gu-su-
	bool ans = false;

	cin >> N;
	if (N % 2 == 0)check = true;
	else check = false;
	for (int i = 1; i <= N; i++) {

		cin >> a[i];
		if (a[i] % 2 == 0)count2++;
		if (a[i] % 4 == 0)count4++;

	}
	count2 = count2 - count4;
	count1 = N - count2 - count4;

	if (count1 == 0)ans = true;
	else {

		if (count4 == 0)ans = false;
		else {

			if (count2 == 0) {

				if (count4 >= count1 - 1)ans = true;

			}
			else if (count2 == 1) {

				if (count4 >= count2 + count1 - 1)ans = true;

			}
			else {

				if (count4 >= count1)ans = true;

			}

		}

	}

	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 640
#!/usr/bin/perl

my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);

if( $n % 2 == 0 ){
  $r = ( $n / 2 ) - 1;
} else {
  $r = ( ( $n - 1) / 2 );
}
print "$r\n";





Measured memory_bytes: 512
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;

int main() 
{  
	fast;
	ll n,x; cin>>n;
	unordered_map<ll,ll>mp;
	ll t = n-1;
	while(t--)
	{
		cin>>x;
		mp[x]++;
	}
	for(ll i = 1; i <= n; i++)
	{
		cout << mp[i] << endl;
	}
}

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

int main()
{
	int S = 0;
	int h = 0;
	int m = 0;
	int s = 0;

	cin >> S;
	h = S / 3600;
	m = (S - h * 3600) / 60;
	s = (S - h * 3600 - m * 60);

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

Measured memory_bytes: 1164
N = int(input())

for h in range(1, 3501):
	for n in range(1, 3501):
		wb = 4*h*n - N*n - N*h
		if wb <= 0:
			continue
		w = N*h*n / wb
		if w.is_integer():
			print(h, n, int(w))
			exit()

Measured memory_bytes: 40668
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,K;
vector<ll> X;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N >> K;
    X = fetch_vec<ll>(N);
}

int solve(){
    ll ans=LL_INF;
    for (int i = 0; i < N-K+1; i++)
    {
        ll m = X[i];
        ll M = X[i+K-1];
        DBG(m)
        DBG(M)
        if(M*m>=0) ans = min(ans,max(abs(m),abs(M)));
        else ans = min(ans,abs(m)+abs(M)+min(abs(m),abs(M)));
    }
    cout << ans << endl;
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 1024
def main():
    n, m = map(int, input().split())
    ac_list = [0 for _ in range(n + 1)] # 1: 正解済 0: 未正解
    wa_list = [0 for _ in range(n + 1)] 

    for _ in range(m):
        p, s = input().split()
        p = int(p)

        if ac_list[p] == 1: # 正解済
            continue
        
        if s == "AC":
            ac_list[p] = 1
        else:
            wa_list[p] += 1

    ac_count = 0
    wa_count = 0
    for i in range(1, n + 1):
        if ac_list[i] == 1:
            ac_count += 1
            wa_count += wa_list[i]

    print(ac_count, wa_count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 85916
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (int)(n); i++)
using namespace std;
int main () {
  int n;cin >> n;
  vector<float> v(n,0);
  rep(i,n){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  rep(i,n-1){
    v[i+1]=(v[i]+v[i+1])/2;
  }
  cout << v[n-1] << endl;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  int n; cin>>n;
  int nmx = 0;
  int ans = 0;
  rep (i,n) {
    int k; cin>>k;
    if (nmx < k) nmx = k;
    ans += k;
  }
  cout << (ans - (int)(nmx / 2)) << endl;
}


Measured memory_bytes: 504
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int i,j,A[100],N,minJ,cnt=0;
    cin >> N;
    for(i=0;i<N;i++) cin >> A[i];
    for(i=0;i<N;i++){
        minJ=i;
        for(j=i+1;j<N;j++){
            if(A[j]<A[minJ]) minJ=j;
        }
        swap(A[i],A[minJ]);
        if(minJ!=i) cnt++;
    }
    for(i=0;i<N;i++) cout << (i!=0?" ":"") << A[i];
    cout << endl << cnt << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long long dp[101][5][5][5] = {};

void solve() {
    dp[0][0][0][0] = 1;
    for(int n=1; n<=100; ++n) {
        for(int i=0; i<5; ++i) {
            for(int j=0; j<5; ++j) {
                for(int k=0; k<5; ++k) {
                    for(int l=1; l<5; ++l) {
                        if(j == 1 && k == 2 && l == 3) continue;
                        if(i == 1 && k == 2 && l == 3) continue;
                        if(j == 2 && k == 1 && l == 3) continue;
                        if(j == 1 && k == 3 && l == 2) continue;
                        if(i == 1 && j == 2 && l == 3) continue;
                        dp[n][j][k][l] = (dp[n][j][k][l] + dp[n-1][i][j][k]) % MOD;
                    }
                }
            }
        }
    }
}

int main() {
    solve();
    int N;
    cin >> N;
    long long res = 0;
    for(int i=1; i<5; ++i) {
        for(int j=1; j<5; ++j) {
            for(int k=1; k<5; ++k) {
                res = (res + dp[N][i][j][k]) % MOD;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef pair<pint,int> ppint;
typedef pair<ppint,int> pppint;
bool querycompare(pppint kukan1,pppint kukan2){
	if(kukan1.first.first.second!=kukan2.first.first.second) return kukan1.first.first.second<kukan2.first.first.second;
	/*else if(kukan1.first.first!=kukan2.first.first) return kukan1.first.first<kukan2.first.first;
	else return kukan1 < kukan2;*/
	else if(kukan1.first.second!=kukan2.first.second) return kukan1.first.second < kukan2.first.second;
	else return kukan1.first.first.first<kukan2.first.first.first;
}
int main(){
	int N,M,Q;
	pint LR[200000];
	pint pq[100000];
	int kukannum[100000]={0};
	int data[501]={0};
	vector<pppint> LRpq;
	scan(N);scan(M);scan(Q);
	rep(i,M){
		pppint LRkukan;
		scan(LR[i].first);scan(LR[i].second);
		LRkukan.first.first=LR[i];
		LRkukan.first.second=0;
		LRkukan.second=0;
		LRpq.push_back(LRkukan);
	}
	rep(i,Q){
		pppint pqkukan;
		scan(pq[i].first);scan(pq[i].second);
		pqkukan.first.first=pq[i];
		pqkukan.first.second=1;
		pqkukan.second=i;
		LRpq.push_back(pqkukan);
	}
	sort(LRpq.begin(),LRpq.end(),querycompare);
	rep(i,LRpq.size()){
		//printf("%d %d %d %d\n",LRpq[i].first.first.first,LRpq[i].first.first.second,LRpq[i].first.second,LRpq[i].second);
		if(LRpq[i].first.second==1){
			for(int j=LRpq[i].first.first.first;j<=LRpq[i].first.first.second;j++){
				kukannum[LRpq[i].second]+=data[j];
			}
		}
		else data[LRpq[i].first.first.first]++;
		/*for(int j=1;j<=N;j++){
			printf("%d ",data[j]);
		}
		kaigyo;*/
	}
	rep(i,Q){
		prin(kukannum[i]);
	}
	return 0;
}


Measured memory_bytes: 13164
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        ABC151a pro = new ABC151a(sc);
        pro.solve(out);

        out.flush();
    }

}

class ABC151a {

    private final char C;

    ABC151a(FastScanner sc) {
        C = sc.next().charAt(0);
    }

    void solve(PrintWriter out) {
        int i = C;
        out.println((char)++i);
    }
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

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


Measured memory_bytes: 21204
import java.util.*;
// import java.util.stream.IntStream;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      int n = scanner.nextInt();
      String ans = solve(n);
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
  
  private static String solve(int n) {
    if (n <= 999) return "ABC";
    return "ABD";
  }
}


Measured memory_bytes: 35736
import math
A, B, H, M = map(int, input().split())

angle_h = (H + (M / 60)) / 12
angle_m = M / 60

if angle_h > angle_m:
    angle = (angle_h - angle_m) * 2 * math.pi
else:
    angle = (angle_m - angle_h) * 2 * math.pi

l = A ** 2 + B ** 2 - 2 * A * B * math.cos(angle)
print(math.sqrt(l))

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

#ifdef HELTHAZAR
#define dbg(x) cerr << #x << " " << x << endl
#define dbg2(x, y) cerr << #x << " " << x << " " << #y << " " << y << endl
#define dbg3(x, y, z) cerr << #x << " " << x << " " << #y << " " << y << " " << #z << " " << z << endl
#else
#define dbg(x) ;
#define dbg2(x, y) ;
#define dbg3(x, y, z) ;
#endif

#define rep(i, from, to) for (int i = from; i < int(to); i++)
#define repn(i, from, to) for (int i = from; i <= int(to); i++)
#define repr(i, from, to) for (int i = int(from); i >= to; i--)
#define trav(a, x) for (auto& a: x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

typedef long long ll;
typedef double dbl;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<ll> vll;

const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int MAXN = 1e5 + 1;

void solve() {
	int n;
	string s;
	cin >> n >> s;

	int e = 0;
	trav(x, s) if (x == 'E') e++;

	int w = 0, mincnt = n - 1;
	rep(i, 0, n) {
		if (s[i] == 'E') e--;
		mincnt = min(mincnt, w + e);
		if (s[i] == 'W') w++;
	}

	cout << mincnt;
}

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

	solve();
}


Measured memory_bytes: 720
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

n = I()
h = Intl()
h = h[::-1]
cnt = 0
ans = 0
for i in range(n-1):
    if h[i] <= h[i+1]:
        cnt += 1
    else:
        cnt = 0
    ans = max(cnt,ans)
print(ans)

Measured memory_bytes: 20424