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

int main(){
    int n;cin>>n;
    vector<int>A(n);
    for(int i=0;i<n;++i)cin>>A[i];

    int ok=1;
    for(int i=0;i<n;++i){
        if(A[i]%2==0){
            if(A[i]%3!=0&&A[i]%5!=0){
                ok=0;
                break;
            }
        }
    }
    if(ok)cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0;
	cin>>n;
	if(n%1000==0) cout<<'0';
	else
	{
       s+=n/1000+1;
       cout<<1000*s-n;
	}
	return 0;
 } 

Measured memory_bytes: 3544
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll ct=0;
    ll mi=1LL<<60;
    ll ans=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i]<0) ct++;
        mi = min(mi,llabs(A[i]));
        ans+=llabs(A[i]);
    }
    cout << (ct&1 ? ans-2*mi : ans) << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

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

    public Main(){
    	new AOJ().doIt();
    }
    
    class AOJ{
    	void doIt(){
    		ArrayList<Integer> list = new ArrayList<Integer>();
    		while(in.hasNext())list.add(in.nextInt());
    		Collections.sort(list);
    		for(int i=list.size()-1;i>=list.size()-3;i--)System.out.println(list.get(i));
    		
    	}
    }
    
}

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

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

typedef int64_t ll;

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

#define SPRE(x) setprecision(x) // 精度を指定

int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	int a,b,c;
	a = b = c = 0;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		if(tmp % 2)
			a++;
		else {
			tmp /= 2;
			if(tmp %= 2)
				b++;
			else
				c++;
		}
	}
	if(b == 0)
		c++;
	if(c >= a)
		cout << "Yes\n";
	else
		cout << "No\n";
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
int W,H,D,a[625][625],b[625];
int id(int i,int j){
	return i*W+j;
}
int main(){
	while(true){
		cin>>W>>H>>D;
		if(W==0) break;
		rep(i,H) rep(j,W) cin>>b[id(i,j)];
		rep(i,H) rep(j,W) rep(k,H) rep(h,W){
			a[id(k,h)][id(i,j)]=0;
			int d=abs(i-k)+abs(j-h);
			if(d==D||d==0) a[id(k,h)][id(i,j)]=1;
		}
		bool used[625]={};
		int eq=H*W;
		rep(j,eq){
			int i=0;
			while(i<eq && (used[i]||a[i][j]==0)) i++;
			if(i==eq) continue;
			used[i]=true;
			rep(k,eq){
				if(i==k) continue;
				if(a[k][j]==0) continue;
				rep(l,eq) a[k][l]^=a[i][l];
				b[k]^=b[i];
			}
		}
		bool can=true;
		rep(i,eq) if(!used[i]&&b[i]!=0) can=false;
		cout<<can<<endl;
	}
}

Measured memory_bytes: 2688
def read_input():
    s = input()
    return s

def submit():
    s = read_input()

    char_appear = {}
    for c in s:
        char_appear[c] = 1

    test = 'abcdefghijklmnopqrstuvwxyz'
    for t in test:
        if t not in char_appear.keys():
            print(t)
            return
    print('None')


if __name__ == '__main__':
    submit()

Measured memory_bytes: 39280
#include <stdio.h>

int h, w, n, ng[16][16];

void init(void){
    int x, y;
    for(x = 0; x <= h; x++){
        for(y = 0; y <= w; y++){
            ng[x][y] = 0;
        }
    }
}

int rec(int x, int y){
    if(ng[x][y]) return 0;
    if(x == 0 && y == 0) return 1;
    if(x == 0) return rec(0, y-1);
    if(y == 0) return rec(x-1, 0);
    return rec(x-1, y) + rec(x, y-1);
}

int main(void){
    int x, y, a, b;
    while(scanf("%d%d", &h, &w) && (h||w)){
        h--; w--;
        init();
        scanf("%d", &n);
        for(x = 0; x < n; x++){
            scanf("%d%d", &a, &b);
            ng[a-1][b-1] = 1;
        }
        printf("%d\n", rec(h, w));
    }
    return 0;
}

Measured memory_bytes: 600
def read_input():
    n, k = map(int, input().split())
    alist = map(int, input().split())

    return n, k, alist


def submit():
    n, k, alist = read_input()

    if k >= n:
        print(1)
        return

    n = n - k
    if n % (k - 1):
        print(n // (k - 1) + 2)
    else:
        print(n // (k - 1) + 1)


if __name__ == "__main__":
    submit()
    
        

Measured memory_bytes: 10420
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
	#ifndef DavidLaptop
		#ifdef FILIN
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define endl '\n'
#define N 4005
ll a[N],dp[N][N],n,k;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;i++){
            cin>>a[i];
            sum+=a[i];
    }
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n-i+1;j++){
            ll e=i+j-1;
            ll x=0,y=0,z=0;
            if(j+2<=e)x=dp[ll(j+2)][ll(e)];
            if(j+1<=e-1)y=dp[ll(j+1)][ll(e-1)];
            if(j<=e-2)z=dp[ll(j)][ll(e-2)];
            dp[j][e]=max(a[j]+min(x,y),a[e]+min(y,z));
        }
    }
    ll rem=sum-dp[1][n];
    cout<<dp[1][n]-rem<<endl;
return 0;
}


Measured memory_bytes: 94208
#include<stdio.h>
int main()
{
	int n,u,k,v,i,j;
	int G[100][100];

	scanf("%d",&n);

	for (i = 0; i < n; i++) {
		for (j = 0; j< n; j++) {
			G[i][j] = 0;
		}
	}

	for (i = 0; i < n; i++) {
		scanf("%d",&u);
		scanf("%d",&k);
		for (j = 0; j < k; j++) {
			scanf("%d",&v);
			G[u - 1][v - 1] = 1;
		}
	}

	for (i = 0; i < n; i++) {
              printf("%d",G[i][0]);
		for (j = 1; j < n ; j++) {
			printf(" %d",G[i][j]);
		}
		printf("\n",G[i][0]);
	}
	return 0;
}

Measured memory_bytes: 632
import itertools
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
perms = []
for i in itertools.permutations([j+1 for j in range(n)]):
    perms.append(list(i))
perms.sort()
for i in range(len(perms)):
    if perms[i]==p:
        rp = i
    if perms[i] ==q:
        rq = i
print(abs(rq-rp))


Measured memory_bytes: 46940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>

#define max 1005

struct node{
    int x;
    int y;
    int cnt;
    char c;
};

int arr[max][max];
int arr_bk[max][max];
int xd[]={-1,0,1,0};
int yd[]={0,-1,0,1};
int dot,cheese,cnt;
int h,w;
int energy;

using namespace std;

void bfs(int *i,int *k)
{
    queue <node> qu;
    node tp,tp2;
    tp.x=*k;tp.y=*i;tp.c='S',tp.cnt=0;
    int n,m;
    qu.push(tp);
    for(n=0;n<h;++n)
        for(m=0;m<w;++m)
            arr_bk[n][m]=arr[n][m];
    while(!qu.empty())
    {
        tp=qu.front();
        qu.pop();
        for(n=0;n<4;n++)
        {
            tp2.x=tp.x+xd[n];
            tp2.y=tp.y+yd[n];
            tp2.c=tp.c;
            tp2.cnt=tp.cnt;
            if(tp2.x<0||tp2.x>=w||tp2.y<0||tp2.y>=h||arr_bk[tp2.y][tp2.x]=='X')
                continue;
            if(arr_bk[tp2.y][tp2.x]=='.'||arr_bk[tp2.y][tp2.x]=='S')
            {
                tp2.cnt++;
                arr_bk[tp2.y][tp2.x]='X';
                qu.push(tp2);
            }
            if(arr_bk[tp2.y][tp2.x]-48>=0&&arr_bk[tp2.y][tp2.x]-48<=9)
            {
                if(arr_bk[tp2.y][tp2.x]-48<=energy)
                {
                    energy++;
                    cheese--;
                    arr[tp2.y][tp2.x]='.';
                    tp.cnt++;
                    *k=tp2.x;*i=tp2.y;cnt+=tp.cnt;
                    return;
                }
                else
                {
                    tp2.cnt++;
                    qu.push(tp2);
                }
            }
        }
    }
}

int main()
{
    int i,k,n,x,y;
    while(scanf("%d %d %d",&h,&w,&n)==3)
    {
        cheese=0;
        for(i=0;i<h;i++)
        {
            for(k=0;k<w;k++)
            {
                scanf(" %c",&arr[i][k]);
                if(arr[i][k]=='S')
                {
                    x=k;y=i;
                }
                if(arr[i][k]>='1'&&arr[i][k]<='9')
                    cheese++;
            }
        }
        energy=1;cnt=0;
        while(cheese)
        {
            bfs(&y,&x);
        }
        printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 9076
import sys, heapq
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 1000000007
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def warshall_floyd(d):
    V = len(d)
    for i in range(V):
        d[i][i] = 0
    for k in range(V):
        for i in range(V):
            for j in range(V):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

def resolve():
    V, E = LI()
    con = [[INF]*V for _ in range(V)]
    for _ in range(E):
        s, t, d = LI()
        con[s][t] = d

    ans = warshall_floyd(con)

    has_ns = [ans[i][i]<0 for i in range(V)].count(True)>0
    if has_ns:
        print('NEGATIVE CYCLE')
    else:
        for i in ans:
            print(' '.join([str(j) if j<INF else 'INF' for j in i]))

if __name__ == '__main__':
    resolve()


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

int main()
{

ll h,n,x;
cin>>h>>n;

for(ll i=0;i<n;i++)
{
    cin>>x;
    h-=x;
}
if(h>0)
{
    cout<<"No"<<endl;
}
else
{
    cout<<"Yes"<<endl;
}


    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n;
    int a[101]={0};
    int i,j,tmp=0,cnt=0;
    
    scanf("%d",&n);
    for(i=1; i<=n; i++){
        scanf("%d",&a[i]);
    }
    
    for(i=1; i<=n-1; i++){
        for(j=1; j<=n-i; j++){
            if(a[j]>a[j+1]){
                tmp=a[j];
                a[j]=a[j+1];
                a[j+1]=tmp;
                cnt++;
            }
        }
    }
    
    for(i=1; i<=n; i++){
        if(i!=n)printf("%d ",a[i]);
        if(i==n)printf("%d\n",a[i]);
    }
    printf("%d\n",cnt);
    
    return 0;
}

Measured memory_bytes: 600
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static int[] a = new int[3];
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		while(0 != n--){
			for (int i = 0; i < a.length; i++) {
				a[i] = cin.nextInt();
			}
			solve();
		}
	}
	
	public static void solve() {
		Arrays.sort(a);
		System.out.println(a[0] * a[0] + a[1] * a[1] == a[2] * a[2] ? "YES" : "NO");
	}
}

Measured memory_bytes: 23376
#include <iostream>

using namespace std;

long long N;

int main()
{
    cin >> N;

    if(N == 1)
    {
        cout << 0 << '\n';
        return 0;
    }

    cout << (1LL * N * (N - 1)) / 2 << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy" << endl;
    if (s == "Cloudy") cout << "Rainy" << endl;
    if (s == "Rainy") cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
temp=21
ans=0
for i in range(N):
  a=A[i]
  b=B[a-1]
  ans+=b
  if temp==a-1:
    c=C[a-2]
    ans+=c
    temp=a
  else:
    temp=a
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	string s1,s2;
	cin>>s1>>s2;
	ll n = s1.size();
	if(s2.substr(0,n) == s1)
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}  


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

int main(){
    long long n, u, v; std::cin >> n;
    long long res = n * (n + 1) * (n + 2) / 6;
    while(std::cin >> u >> v) res -= std::min(u, v) * (n + 1 - std::max(u, v));
    std::cout << res << '\n';
}

Measured memory_bytes: 3584
#define _GLIBCXX_DEBUG
#define rep(i,N) for(int i = 0; i < N;i++)
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;


/* template */
int main (){
 int H, W;
 cin >> H >> W;
 vector<string> vec(H);
for(int i=0; i <H;i++){
    cin >> vec.at(i);
}
for(int i=0 ;i < W+2; i++)  {
    cout << '#';
  }
  cout << endl;
for(int i=0; i<H; i++){
  cout <<'#'<< vec.at(i) <<'#'<<endl;
}
for(int i=0; i< W+2; i++){
    cout << '#';
 }
  cout <<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
typedef pair<int,int> P;

int main(void){
    // Your code here!
    string s,t; cin >> s >> t;
    int n = s.size();
    int m = t.size();
    int cnt = 0;
    rep(i,n-m+1) {
        int now = 0;
        rep(j,m) {
            if (s[i+j] == t[j]) now++;
        }
        if (now > cnt) cnt = now;
    }
    cout << m - cnt << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n, m;
  cin >> n >> m;
  vector<int> num(n,1);
  vector<bool> possible(n, false);
  possible[0] = true;
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    x--; y--;
    num[x]--; num[y]++;
    if (possible[x]) possible[y] = true;
    if (num[x] == 0) possible[x] = false;
  }
  int ans = 0;
  rep(i,n) {
    if (possible[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
	int n;
	while(scanf("%d",&n) != EOF){
		int ans = 0;
		for(int i = 0; i < 10; i++){
			for(int j = 0;j < 10; j ++){
				for(int k = 0; k < 10; k++){
					for(int l = 0; l < 10; l++){
						if(i+j+k+l == n){
							ans++;
						}
					}
				}
			}
		}
		printf("%d\n",ans);
	}
	
	return 0;
}

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

#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
template<typename T, typename... Args> void read(T &first, Args& ... args) {
	read(first);
	read(args...);
}
int n,a[200020];
map<int,int> cmp;
int main() {
	read(n);
	for(int i=0;i<n;i++){
		read(a[i]);
		cmp[a[i]]+=1;
	}
	sort(a,a+n);
	int ans  =0;
	for(int i=n-1;i>=0;i--){
		if(!cmp[a[i]])continue;
		cmp[a[i]]-=1;
		int b = a[i];
		b+=b&(-b);
		while(b!=(b&(-b)))b+=b&(-b);
		if(cmp[b-a[i]]){
			ans++;
			cmp[b-a[i]]--;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 19712
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS

main = do
  [w,h,x,y] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let s = fromIntegral w * fromIntegral h / 2
  let t | x * 2 == w && y * 2 == h = 1
        | otherwise = 0
  putStrLn $ unwords [show s, show t]


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

int main() {
  int A,B,C,D,N,c;
  char n;
  A=0;
  string S,T;
  cin >> N;
  vector<int>L(N);
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  std::sort(L.begin(),L.end(),std::greater<int>());
  for(int i=0;i<(N-2);i++){
    int j;
    j=i+1;
    while(L.at(j)>(L.at(i)/2)){
      int k,l;
      l=0;
      k=j+1;
      while((L.at(k)+L.at(j))>L.at(i)){
        l++;
        k++;
        if(k>(N-1)){
          break;
        }
      }
      A+=l;
      j++;
      if(j>(N-2)){
        break;
      }
           
    }
    
  }
  
  cout << A << endl;

}







Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

ll n, k;
ll ans = 1;

vector<ll> g[114514];
bool used[114514] = {};
void dfs(int i, int rank, int col) {
	used[i] = true;
	ans *= max(k - min(rank, 2) - col, 0ll);
	ans %= MOD;
	ll cnt = 0; //直下のノード数
	for (int j = 0; j < g[i].size(); j++) {
		if (!used[g[i][j]]) {
			dfs(g[i][j], rank + 1, cnt);
			cnt++;
		}
	}
	//cout << i << " " << rank << " " << col << " " << cnt << " " << k - min(rank, 2) - col << endl;
}

int main() {
	IOS();
	cin >> n >> k;
	for (int i = 0; i < n - 1; i++) {
		ll a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1, 0, 0);
	dump(ans);
	return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    int n, x; std::cin >> n >> x;
    std::vector<int> m(n);

    int min = 10000;
    int sum = 0;
    int ans = n;
    for(int i = 0;i < n; i++) {
        std::cin >> m[i];
        sum += m[i];
        min = std::min(min, m[i]);
    }

    ans += (x - sum)/min;

    std::cout << ans << std::endl;
}

Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  int d=0;
  for(int i=a;i<=b;i++){
  if(i%c==0)
    d++;
  }
  out(d);
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
string s;
int hsh[35];
int main()
{
	cin >> s;
	for(int i=0;i<s.size();i++)
	{
		++hsh[s[i]-'a'];
	}
	for(int i=0;i<26;i++)
	{
		if(hsh[i]>1)
		{
			printf("no");
			return 0;
		}
	}
	printf("yes");
}

Measured memory_bytes: 256
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function main(arg) {
    arg=arg.split("\n")[0].split("")
    var n = arg.length;
    var ijougen = Math.floor(n/2);
    var kekka = 0;
    var honbun = arg;
    for(i=0;i<ijougen;i++){
    	if(honbun[i]!=honbun[n-i-1])
        {kekka += 1;
        }
    }
    console.log(kekka);
}



Measured memory_bytes: 21064
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


int main()
{
  int N;
  cin >> N;
  auto cnt_digit = [](int x) {
    int ret = 0;
    while (x > 0) x /= 10, ret++;
    return ret;
  };
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (cnt_digit(i) % 2) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{

    long double a, b;

    cin >> a >> b;
  //  b *= 100; b += 0.5;
    long double ans = (a * b)+0.0001;
    cout << (ll)ans<< endl;

    return 0;

}


Measured memory_bytes: 3692
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
ll mod_pow(ll a, ll n, T mod) {
    mod = (ll)mod;
    ll res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}
void print() { std::cout << std::endl; }
template <typename T, typename... A>
void print(const T& first, const A&... rest) {
    cout << sizeof...(rest) << endl;
    std::cout << first;
    if (sizeof...(rest)) std::cout << " ";
    print(rest...);
}
template <typename... A>
void print(const A&... rest) {
    print(rest...);
}
template <typename A>
void print(const std::vector<A>& v) {
    std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    map<int, int> nums;
    rep(i, N) {
        cin >> a[i];
        nums[a[i]]++;
    }
    set<int> cards(all(a));
    int cnt_even = 0;
    for (auto& c : cards) {
        if (!(nums[c] & 1)) cnt_even++;
    }
    if (!(cnt_even & 1))
        cout << cards.size() << endl;
    else
        cout << (int)cards.size() - 1 << endl;

    return 0;
}

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

using namespace std;

struct panel {
  char name[1001];
  int x1, y1;
  int x2, y2;
  vector<panel> child;
};

void parse(panel &p, char tag[])
{
  while(1){
    char tmp[1100];
    sscanf(tag, "<%[^>]>%s", tmp, tag);
    char aaa[1100] = "/";
    strcat(aaa, p.name);
    if(strcmp(aaa, tmp) == 0) return;
    panel c;
    char next[1100];
    strcpy(c.name, tmp);
    sscanf(tag, "%d,%d,%d,%d%s", &c.x1, &c.y1, &c.x2, &c.y2, next);
    //cout << c.name << " " << next << endl;
    parse(c, next);
    strcpy(tag, next);
    p.child.push_back(c);
  }
}

bool inPanel(panel &p, int x, int y)
{
  if(p.x1 <= x && x <= p.x2 && p.y1 <= y && y <= p.y2){
    for(int i = 0; i < p.child.size(); i++){
      if(inPanel(p.child[i], x, y)) return true;
    }
    if(strcmp(p.name, "#$%123") == 0) return false;
    cout << p.name << " " << p.child.size() << endl;
    return true;
  }
  return false;
}

int main()
{
  int n;
  while(cin >> n, n){
    panel app;
    char tag[1100];
    scanf("%s", tag);
    strcpy(app.name, "#$%123");
    app.x1 = -1; app.y1 = -1;
    app.x2 = 10001; app.y2 = 10001;
    strcat(tag, "</#$%123>");
    parse(app, tag);
    for(int i = 0; i < n; i++){
      int x, y;
      cin >> x >> y;
      if(!inPanel(app, x, y)) cout << "OUT OF MAIN PANEL 1" << endl;
    }
  }
  return 0;
}

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

struct point{
  int x;
  int y;
};

string s;
vector <point> a;
int n, k, xx, yy, res=0;

int main(){
  cin >> n >> k;
  cin >> s;
  s = '1' + s + '1';
  for (int i=1; i<=n+1; ++i){
    if (s[i]=='1'){
      if (s[i-1]=='0'){
        xx = yy = i;
      }
      else yy++;
    }
    else if (s[i-1]=='1') a.push_back({xx, yy});
  }
  a.push_back({xx, yy});
  if (k>=a.size()-1) res=n;
  else{
    for (int i=0; i<a.size()-k; ++i){
      if (a[i+k].y-a[i].x+1 > res){
        res = a[i+k].y-a[i].x+1;
        if (i+k == a.size()-1 || i==0) res--;
      }
    }
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 1016
package main

import (
        "fmt"
)

func solution(a, b, k int) []int {

        out := make([]int, 0, 2*k)
        for i := a; i <= min(b, a+k-1); i++ {
                out = append(out, i)
        }

        for i := max(b-k+1, a+k); i <= b; i++ {
                out = append(out, i)
        }
        return out
}

func min(x, y int) int {
        if x < y {
                return x
        }
        return y
}

func max(x, y int) int {
        if x > y {
                return x
        }
        return y
}
func main() {
        var a, b, k int
        fmt.Scan(&a, &b, &k)
        for _, n := range solution(a, b, k) {
                fmt.Println(n)
        }
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int gcd(int x, int y);
int main(){
  int x,y,z;
  while(cin >>x>>y){
    z = gcd(x,y);
    cout <<z<<" "<<x/z*y<<endl;
  }
  return 0;
}
int gcd(int x, int y){
  if(y == 0) return x;
  return gcd(y,x%y);
}

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

int main(void)
{
	unsigned cur_line, cur_column, min, record_size,
	        *A;
	const unsigned alpha = 26;
	int i,
	    flag;
	char ch;

	scanf("%u\n",&record_size);
	
	A = (unsigned *)malloc(sizeof(unsigned) * alpha * record_size);
	i = alpha * record_size;
	while(0 <= --i) A[i] =0;
	
	cur_line = 0;
	while (cur_line < record_size)
	{
		while ('\n' != ( ch=fgetc(stdin) ) )
			A[cur_line * alpha + ch - 'a'] += 1;
		
		cur_line++;
	}
	
	cur_column  =0;
	while (cur_column < alpha)
	{
		cur_line = 0;
		min = -1;
		flag = 1;
		while (cur_line < record_size)
		{
			
			if (A[alpha * cur_line + cur_column] == 0){
				flag = 0;
				break;
			}
			else if (min > A[alpha * cur_line + cur_column] )
				min = A[alpha * cur_line + cur_column];
			
			cur_line++;
		}
		if (flag ==1)
			while (min--) printf("%c",cur_column + 'a');
		
		cur_column++;
	}
	fputc('\n',stdout);
	
	free(A);
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N,K;
	string S;
	cin>>N>>K>>S;
	K--;
	S[K]=tolower(S[K]);
	cout<<S<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

int main(){
  double l;
  cin >> l;

  double ans = (l * l * l) / 27;

  cout << fixed << setprecision(12) << ans << endl;

  return 0;
}


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

using namespace std;

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

    int x = (a + d - 1) / d;
    int y = (c + b - 1) / b;

    puts(x >= y ? "Yes" : "No");
}


Measured memory_bytes: 3688
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int a, b, c;
    cin >> a >> b >> c;

    int ans = 0;
    ans = min(a + b + 1, c);
    ans += b;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if (i+k)%2 == 0:
                print("#",end = "")
            else:
                print(".",end = "")
        print()

    print()


Measured memory_bytes: 7004
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    W = list(map(int, input().split()))

    ans = float("inf")
    for t in range(1, N):
        t_low_sum = sum(W[:t])
        t_up_sum = sum(W[t:])
        ans = min(ans, abs(t_low_sum-t_up_sum))
    
    print(ans)
        


if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using ll = long long;
using namespace std;

struct P {
    ll taste;
    int a;
    int b;
    int c;

    bool operator<(const P &another) const {
        return taste < another.taste;
    };
};

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X + 2000, -10000000000);
    vector<ll> B(Y + 2000, -10000000000);
    vector<ll> C(Z + 2000, -10000000000);
    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];
    sort(rall(A));
    sort(rall(B));
    sort(rall(C));

    priority_queue<P> pq;
    P init = {A[0] + B[0] + C[0], 0, 0, 0};
    pq.push(init);
    map<vector<int>, int> cnt;
    cnt[{0, 0, 0}]++;
    vector<ll> ans;

    while (!pq.empty() && ans.size() < K) {
        P q = pq.top();
        pq.pop();
        // printf("taste=%d a=%d b=%d c=%d\n", q.taste, q.a, q.b, q.c);
        ans.push_back(q.taste);
        P newq1 = {A[q.a + 1] + B[q.b] + C[q.c], q.a + 1, q.b, q.c};
        P newq2 = {A[q.a] + B[q.b + 1] + C[q.c], q.a, q.b + 1, q.c};
        P newq3 = {A[q.a] + B[q.b] + C[q.c + 1], q.a, q.b, q.c + 1};

        if (q.a+1<X && cnt[{q.a + 1, q.b, q.c}] == 0) {
            // cout << "1だよ" << endl;
            pq.push(newq1);
            cnt[{q.a + 1, q.b, q.c}]++;
        }
        if (q.b+1<Y && cnt[{q.a, q.b + 1, q.c}] == 0) {
            // cout << "2だよ" << endl;
            pq.push(newq2);
            cnt[{q.a, q.b + 1, q.c}]++;
        }
        if (q.c+1<Z && cnt[{q.a, q.b, q.c + 1}] == 0) {
            // cout << "3だよ" << endl;
            pq.push(newq3);
            cnt[{q.a, q.b, q.c + 1}]++;
        }
    }
    rep(i, K) cout << ans[i] << endl;
}


Measured memory_bytes: 1280
import collections
 
N = int(input())
A = [int(i) for i in input().split()]
 
sub = [A[i]-(i+1) for i in range(N)]
res = 0
sub = sorted(sub)
b = sub[int(N/2)]
 
res = 0
for i in range(N):
    res += abs(A[i]-(b+i+1))
 
print(res)

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

using namespace std;
using ll = long long;

int main() {
	string s;
	cin >> s;

	int cnt = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'x') { ++cnt; }
	}

	if (cnt >= 8) { cout << "NO" << endl; }
	else { cout << "YES" << endl; }

	return 0;
}



Measured memory_bytes: 256
import random
import time
import copy

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    ans = []    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][idx]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)
        

    while time.time() - start < 1.9:
        cp = ans.copy()
        last_d = [0 for i in range(26)]
        score2 = 0  
        
        idx1 = random.randint(0,25)
        idx2 = random.randint(0,25)
        if random.randint(0,1):
            d1 = random.randint(0,D-1) 
            d2 = random.randint(0,D-1)
            if idx1 == idx2:
                continue
            if random.randint(0,1):
                ans[d1] = idx1
            else:
                ans[d1] = idx1
                ans[d2] = idx2
             
        #2値入れ替え
        elif random.randint(0,1):           
            d1 = random.randint(0,D-19) 
            d2 = random.randint(d1+1,d1+18)
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp1
            
        #3値入れ替え          
        else:
            d1 = random.randint(0,D-17) 
            d2 = random.randint(d1+1,d1+8)
            d3 = random.randint(d2+1,d2+8) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp3
                ans[d3] = tmp1
            else:
                ans[d1] = tmp3
                ans[d2] = tmp1
                ans[d3] = tmp2
            
        for i in range(D):
            score2 += s[i][ans[i]]
            last_d[ans[i]] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans = cp.copy()
        else:
            score1 = score2
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


Measured memory_bytes: 10036
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
  long long a, b, c, d;
  long long ans;
  cin >> a >> b >> c >> d;
  ans = max(a*c, a*d);
  ans = max(ans, b*c);
  ans = max(ans, b*d);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3088
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int M = in.nextInt();
            int D = in.nextInt();
            int ans = 0;
            for (int m = 1; m <= M; m++)
                for (int d = 10; d <= D; d++) {
                    int d1 = d % 10;
                    int d10 = (d / 10) % 10;
                    if (d1 >= 2 && d10 >= 2 && d1 * d10 == m)
                        ans++;
                }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }
}



Measured memory_bytes: 21460
N,W=map(int,input().split())
WV=[]
for i in range(N):
    WV.append(list(map(int,input().split())))
dp=[[0 for j in range(W+1)] for i in range(N+1)]
dp[0]=[-1e-30 for i in range(W+1)]
dp[0][0]=0
for i in range(1,N+1):
    for j in range(W+1):
        if j-WV[i-1][0]>=0:
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-WV[i-1][0]]+WV[i-1][1])
        else:
            dp[i][j]=dp[i-1][j]
print(int(dp[N][W]))

Measured memory_bytes: 317008
#include <stdio.h>

int main(){
    int i, n;
    int nm[100];

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

    for(i = n-1; i > 0; i--){
        printf("%d ", nm[i]);
    }
    printf("%d\n", nm[i]);

    return 0;
}


Measured memory_bytes: 2052
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{

    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var oneCount = 0;
        var zeroCount = 0;
        foreach(var c in S)
        {
            if(c == '0')
            {
                zeroCount++;
            }
            else
            {
                oneCount++;
            }
        }

        var pairCount = Math.Min(zeroCount, oneCount);
        Console.WriteLine(pairCount * 2);

    }
}



Measured memory_bytes: 11232
using System;
using System.Linq;

namespace Volume0_0001
{
    class Program0_0001
    {
        static void Main(string[] args)
        {
            int[] height = new int[10];

            for (int i = 0; i < 10; i++)
            {
                height[i] = int.Parse(Console.ReadLine());
            }

            int[] orderedHeight = height.OrderByDescending(x => x).ToArray();

            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine("{0}", orderedHeight[i]);
            }
        }
    }
}

Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define double long double
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define ren(i,n) for(int i=n-1;i>=0;i--)
#define iter(it,v) for(auto it:v)
#define iterp(it,v) for(auto it=v.begin(),it!=v.end();it++)
#define itern(it,v) for(auto it=v.rbegin();it!=v.rend();it++)
#define w(n) while(n--)
#define forp(i,a,b) for(int i=a;i<=b;i++)
#define forn(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%d",&a)
#define pf(a) printf("%d",a)
#define init(a,r) for(auto&i:a) i=r;
#define initi(a,r) memset(a,r,sizeof(a))
#define inpt(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define inp(a) for(auto&i:a) cin>>i;
#define diss(a) for(auto i:a) cout<<i<<' ';
#define disn(a) for(auto i:a) cout<<i<<'\n';
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<'\n';
#define mpii map<int,int>
#define sii set<int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define all(v) v.begin(),v.end()
#define bitc __builtin_popcount
#define fst ios::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define pq priority_queue
#define pii pair<int,int>
#define cs(a) cout<<a<<' '
#define cn(a) cout<<a<<'\n'
#define deb(a,b) cout<<a<<' '<<b<<endl;
#define yy "YES"
#define nn "NO"
#define ff first
#define ss second
typedef long long ll;
const int mod=1e9+7,mod1=998244353;
const int N=2e5+7;
int ar[N];
void a_b_l(){
    int n;
    cin>>n;
    double ar[n+1];
    ar[0]=0;
    forp(i,1,n)
        cin>>ar[i];
    double dp[n+1][n+1];
    initi(dp,0);
    dp[0][0]=1.0;
    forp(i,1,n){
        forp(j,0,i){
            if(j==0){
                dp[i][j]=dp[i-1][j]*(1-ar[i]);
                continue;
            }
            dp[i][j]=dp[i-1][j]*(1-ar[i])+dp[i-1][j-1]*ar[i];
        }
    }
    double ans=0;
    forp(i,(n+1)/2,n){
        ans+=dp[n][i];
    }
    cout<<setprecision(15)<<ans;
}
signed main(){
    fst;
    int t=1;
    //cin>>t;
    w(t)
    	a_b_l();
}

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

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        
        ArrayList<Integer> vs = new ArrayList<>();
        
        for (int i = 0; i < n; i ++) {
            vs.add(s.nextInt());
        }
        
        Collections.sort(vs);
        
        double output = vs.get(0);
        
        for (int i = 1; i < vs.size(); i ++) {
            output = (double) (output + vs.get(i)) / 2;
        }
        
        
        System.out.println(output);
        
    }
    
}


Measured memory_bytes: 21972