akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

int main() {
    int N;
    scanf("%d", &N);
    ll A[N];
    rep(i,0,N) scanf("%lld", &A[i]);
    ll x[N+1];
    x[0]=0;
    rep(i,1,N+1) x[i]=x[i-1]+A[i-1];
    
    ll a=A[0];
    ll b=A[1];
    ll c=A[2];
    ll d=x[N]-x[3];
    int e=1;
    int f=3;
    if (c<d){
        while(c<d){
            c+=A[f];
            d-=A[f];
            f++;
        }
        if (c-d>A[f-1]) {
            c-=A[f-1];
            d+=A[f-1];
            f--;
        }
    }
    ll ans=max(max(a,b), max(c,d))-min(min(a,b), min(c,d));
    rep(i,2,N-2){
        b+=A[i];
        c-=A[i];
        if (a<b){
            while(a<b){
                a+=A[e]; b-=A[e]; e++;
            }
            if (a-b>A[e-1]) {
                a-=A[e-1];
                b+=A[e-1];
                e--;
            }
        }
        if (c<d) {
            while(c<d){
                c+=A[f]; d-=A[f]; f++;
            }
            if (c-d>A[f-1]) {
                c-=A[f-1];
                d+=A[f-1];
                f--;
            }
        }
        //cout <<a<<" " <<b<<" "<< c<<" " <<d<<" "<<max(max(a,b), max(c,d))-min(min(a,b), min(c,d)) << endl;
        ans=min(ans, max(max(a,b), max(c,d))-min(min(a,b), min(c,d)));
     }
    printf("%lld\n",ans);
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
int main() {
	ll a, b;
	cin >> a >> b;
	ll g = gcd(a, b);
	int cnt = 1;
	for (ll i = 2; i * i <= g; i++) {
		if (g % i == 0) {
			cnt++; 
			while (g % i == 0) g /= i;
		}
	}
	if (g > 1) cnt++;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

s = set()
c = 0

for i in range(n):
    if 1 <= a[i] <= 399:
        s.add(1)

    elif 400 <= a[i] <= 799:
        s.add(2)

    elif 800 <= a[i] <= 1199:
        s.add(3)

    elif 1200 <= a[i] <= 1599:
        s.add(4)

    elif 1600 <= a[i] <= 1999:
        s.add(5)

    elif 2000 <= a[i] <= 2399:
        s.add(6)

    elif 2400 <= a[i] <= 2799:
        s.add(7)

    elif 2800 <= a[i] <= 3199:
        s.add(8)

    else:
        c += 1

if len(s):
    print(len(s), len(s)+c)
else:
    print(1, c)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){

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

  for(int ans = 0; ; ans++){
    if(1+ (a-1)*ans >= b){
      cout << ans << endl;
      return 0;
    } else {
      
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    int n; cin >> n;
    V<int> A(n);
    loop (n, i) cin >> A[i];
    V<int> B = A;
    sort(B.begin(), B.end());
    int m1 = B[n - 1], m2 = B[n - 2];
    loop (n, i) {
        if (A[i] == m1) cout << m2 << endl;
        else cout << m1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3200
// Copyright lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<long long, long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, j, k)  for (register int i = (int)(j); i <= (int)(k); i++)
#define rrep(i, j, k) for (register int i = (int)(j); i >= (int)(k); i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}

const int mod = 1e9 + 7;
const int maxn = 3030;
int n, m;
int f[maxn][maxn];
int a[maxn];

void work() {
  ll inv2 = (mod + 1) / 2;
  n = read(), m = read();
  rep(i, 1, n) a[i] = read();
  rep(i, 1, n) rep(j, 1, n) if (a[i] < a[j]) f[i][j] = 1;
  rep(i, 1, m) {
    int x = read(), y = read();
    rep(j, 1, n) {
      if (j == x || j == y) continue;
      f[x][j] = f[y][j] = (f[x][j] + f[y][j]) * inv2 % mod;
      f[j][x] = f[j][y] = (f[j][x] + f[j][y]) * inv2 % mod;
    }
    f[x][y] = f[y][x] = (f[x][y] + f[y][x]) * inv2 % mod;
  }
  int ans = 0;
  rep(i, 1, n) rep(j, 1, i - 1) ans = (ans + f[i][j]) % mod;
  rep(i, 1, m) ans = ans * 2 % mod;
  printf("%d\n", ans);
}

int main() {
  #ifdef LZT
    freopen("in", "r", stdin);
  #endif

  work();

  #ifdef LZT
    Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
  #endif
}


Measured memory_bytes: 35712
#include <iostream>
#include <string>

using namespace std;

using Int = long long;

const int MOD = 1000000007;

int N;
Int dp[3005][3005];
Int dp_sum[3005][3005];

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

	dp[0][0] = 1;

	for (int i = 1; i < N; ++i) {
		for (int j = 0; j <= i; ++j) {
			dp_sum[i - 1][j] = dp[i - 1][j];
			if (j - 1 >= 0) {
				dp_sum[i - 1][j] += dp_sum[i - 1][j - 1];
				dp_sum[i - 1][j] %= MOD;
			}
		}
		for (int j = 0; j <= i; ++j) {
			if (s[i - 1] == '<') {
				// [0, j) に対しての累積和
				if (j - 1 >= 0) {
					dp[i][j] += dp_sum[i - 1][j - 1];
					dp[i][j] %= MOD;
				}
			} else {
				// [j, i) に対しての累積和
				dp[i][j] += dp_sum[i - 1][i - 1];
				if (j - 1 >= 0) {
					dp[i][j] -= dp_sum[i - 1][j - 1];
					dp[i][j] += MOD;
				}
				dp[i][j] %= MOD;
			}
		}
	}

	Int ans = 0;
	for (int i = 0; i <= N - 1; ++i) (ans += dp[N - 1][i]) %= MOD;

	cout << ans << endl;
}


Measured memory_bytes: 139648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(
                System.in));

        int len = Integer.parseInt(reader.readLine());
        int[] arr = new int[len];

        String arrStr = reader.readLine();
        StringTokenizer tokenizer = new StringTokenizer(arrStr, " ");

        int i = 0;
        while (tokenizer.hasMoreElements()) {
            arr[i++] = Integer.parseInt((String) tokenizer.nextElement());
        }

//         int[] arr = {1,2,3,4,5};
//         int len = arr.length;

        bubblesort(arr, len);
    }
    

    private static void bubblesort(int[] arr, int len) {
      
        int swapCnt = 0;
        
        for (int i = 0; i < len - 1; i++) {
            
//            System.out.println("===========================");
            for (int j = (len - 1); j > i ; j--) {

//                System.out.println("i:" + i + " j:" + j);
                
                int current = arr[j];
                int target = arr[j - 1];

                if (target > current) {

                    swapCnt++;

                    int swap = arr[j -1];
                    arr[j - 1] = arr[j];
                    arr[j] = swap;
                }
                
                
            }
            
            
        }
        printArr(arr);
        System.out.println(swapCnt);
    }

    static void printArr(int[] arr) {
        String msg = "";
        for (int i = 0; i < arr.length; i++) {
            msg += arr[i];
            if (i == arr.length - 1) {
                break;
            }
            msg += " ";
        }

        System.out.println(msg);
    }

}

Measured memory_bytes: 9376
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int ans[1000][1000];

signed main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;

	for (int i = 0; i < b; ++i) {
		for (int j = 0; j < a; ++j)
			ans[i][j] = 1;
	}
	for (int i = b; i < h; ++i) {
		for (int j = a; j < w; ++j)
			ans[i][j] = 1;
	}

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w - 1; ++j)
			cout << ans[i][j];
		cout << ans[i][w - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 5120
#include<iostream>

using namespace std;

int S[100005],A[100005];

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

    int n;
    cin>>n;

    for(int i=0; i<n; i++)
    {
        char c;
        cin>>c;
        if(c=='o')
            A[i]=0;
        else
            A[i]=1;
    }

    bool ok=0;
    for(int i=0; i<4; i++)
    {
        S[0]=i%2;
        S[1]=(i/2)%2;

        for(int j=1; j<n; j++)
        {
            int cr;
            if(S[j]==0)
                cr=A[j];
            else
                cr=1-A[j];

            if(cr==0)
                S[j+1]=S[j-1];
            else
                S[j+1]=1-S[j-1];
        }

        int cr;
        if(S[n-1]==0)
            cr=A[n-1];
        else
            cr=1-A[n-1];

        bool ok1=0;
        if(cr==0)
        {
            if(S[0]==S[n-2])
                ok1=1;
        }
        else
        {
            if(S[0]!=S[n-2])
                ok1=1;
        }

        if(!ok1)
            continue;

        if(S[0]==0)
            cr=A[0];
        else
            cr=1-A[0];

        if(cr==0)
        {
            if(S[1]==S[n-1])
            {
                ok=1;
                break;
            }
        }
        else
        {
            if(S[1]!=S[n-1])
            {
                ok=1;
                break;
            }
        }
    }

    if(!ok)
    {
        cout<<"-1\n";
        return 0;
    }

    for(int i=0; i<n; i++)
    {
        if(S[i]==0)
            cout<<'S';
        else
            cout<<'W';
    }
    cout<<"\n";
    return 0;
}


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

int64_t dfs(string s, string t, int i, int n, int64_t sum){
  if(i==n-1){
    t = t + s.at(i);
    int64_t p = stoll(t);
    return sum+p;
  }
  else{
    t = t + s.at(i);
    int64_t z = stoll(t);
    return dfs(s, t, i+1, n, sum)+dfs(s, "", i+1, n, sum+z);
  }
}

int main(){
  /*
  int n, i, j;
  cin >> n;
  vector<int> A(n);
  rep(i, n) cin >> A[i];
  */
 string s;
 cin >> s;
 int sz = s.size();
 int64_t ans = dfs(s, "", 0, sz, 0);
 cout << ans << endl;

}

Measured memory_bytes: 256
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
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CDiceAndCoin solver = new CDiceAndCoin();
        solver.solve(1, in, out);
        out.close();
    }

    static class CDiceAndCoin {
        static double pow(double x, long y, int p) {
            double res = 1;
            x = x % p;

            while (y > 0) {
                if ((y & 1) == 1)
                    res = (res * x) % p;
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }

        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            double res = 0;
            double each = 1d / n;
            for (int i = 1; i <= n; i++) {
                res += each * pow(0.5, (int) Math.ceil(Math.log((double) k / i) / Math.log(2)), 1000000009);
            }
            out.println(res);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
n, k = map(int,input().split())
p = list(map(int,input().split()))
sum_p = []
for i in p:
    sum_p.append((1 + i) / 2)

ans = sum(sum_p[0:k])
check = sum(sum_p[0:k])
p = 0
for i in range(k,n):
    check = check + sum_p[i] - sum_p[i - k]
    if check > ans:
        ans = check
print(ans)

Measured memory_bytes: 77448
#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;

int main(void){
  long long int N,K,tmp;
  vector<long long int> p;
  long long int max;
  long long int sum=0;

  cin >> N >> K;

  for(int i=0; i<N; i++){
    cin >> tmp;
    p.push_back(tmp);
  }

  for(int i=0; i<K; i++){
    sum += (p[i] + 1);
  }

  max = sum;
  // cout << 2 <<" : " << sum << endl;

  for(int i=K;i<N;i++){
    sum -= (p[i-K]+1);
    sum += (p[i]+1);
    // cout << i <<" : " << sum << endl;
    if(sum >= max){
      max = sum;
    }
  }

  //cout << max/2.0 << endl;

  printf("%.15lf\n", max/2.0);

  return 0;
}

Measured memory_bytes: 2420
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int count = Integer.parseInt(sc.next());
		ArrayList<Integer> integers = new ArrayList<Integer>(count);
		for (int i = 0; i < count; i++) {
			integers.add(Integer.parseInt(sc.next()));
		}
		int left = 0;
		int right = 0;
		for (int i = 0; i < count; i++) {
			if (right <= left) {
				int size = integers.size() - 1;
				right += integers.get(size);
				integers.remove(size);
			} else {
				left += integers.get(0);
				integers.remove(0);
			}
		}

		if(right>=left) {
			System.out.println(right-left);
		}else {
			System.out.println(left-right);
		}
		sc.close();
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}
const int N=18,mod=1e9+7;
typedef long long ll;
ll n,arr[N][N],dp[1<<N],cm[1<<N];
ll solve(int msk = (1<<n)-1)
{
    if (!msk)
        return 0;
    ll &ret = dp[msk];
    if (~ret)
        return ret;
    ret = -1e9;
    for(int cur=msk;cur;cur=((cur-1)&msk)){
        int tmp=cur^msk;
        ret=max(ret,cm[cur]+solve(tmp));
    }
    return ret;
}
void gen1()
{
    for(int i=0; i<(1<<n); i++)
    {
        ll sum=0;
        vector<int>tmp;
        for(int j=0; j<n; j++)
        {
            if((1<<j)&i)
            {
                tmp.push_back(j);
            }
        }
        for(int x=0; x<tmp.size(); x++)
        {
            for(int y=x+1; y<tmp.size(); y++)
            {
                int idx1=tmp[x],idx2=tmp[y];
                sum+=arr[idx1][idx2];
            }

        }
        cm[i]=sum;

    }
}
int main()
{
    Elhabashy
    input();
    cin>>n;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
            cin>>arr[i][j];
    }
    gen1();
    memset(dp,-1,sizeof dp);
    cout<<solve()<<endl;
}


Measured memory_bytes: 6184
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, h[100005], memo[100005];

lli dfs(lli x) {
  if (memo[x] >= 0) return memo[x];
  return memo[x] = min(
    abs(h[x]-h[x+1]) + dfs(x+1),
    abs(h[x]-h[x+2]) + dfs(x+2)
  );
}

int main() {
  cin >> n;
  read_n(h, n);
  fill(&memo[0], &memo[n], -1);
  memo[n-1] = 0;
  memo[n] = memo[n+1] = 1e18;
  cout << dfs(0) << '\n';
  return 0;
}



Measured memory_bytes: 3328
<?php
//error_reporting(0);
//$S = trim(fgets(STDIN));
list($A,$B) = explode(" ",trim(fgets(STDIN)));
//$a[] = array_map('intval',explode(" ",trim(fgets(STDIN))));

for($i=0;$i<1000000;$i++) {
  $keigen = (int)floor($i*0.08);
  $tax    = (int)floor($i*0.10);
  if ($A==$keigen && $B==$tax) {
    printf("%d\n",$i);
    exit;
  }
}
printf("%d\n",-1);


Measured memory_bytes: 4856
#include<iostream>
#include<set>
using namespace std;
#define int long long

signed main(){
    int N;cin>>N;
    set<int> num;
    for(int i=0;i<N;++i){
        int A;cin>>A;
        if(num.find(A) != num.end()) num.erase(A);
        else num.insert(A);
    }

    cout<<num.size()<<endl;

}

Measured memory_bytes: 4864
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    
    int count_r = 0;
    int count_b = 0;
    
    for(int i = 0; i < n; ++i){
      if('R'==s.charAt(i)){
        count_r++;
      }else{
        count_b++;
      }
    }
    
    if(count_r > count_b){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    
  }
}

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

int main(){
  string N;
  cin >> N;
  if (N.at(0) == '7' || N.at(1) == '7' || N.at(2) == '7'){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int is_prime(int *prime, int num,int k);

int main(){
    int i,j,k;
    int *prime;
    prime = malloc(1400*sizeof(int));
    k=1;
    prime[0] = 2;
    int num;
    for (i=3;i<10000;i++){
        num = 0;
        for (j=0;j<k;j++){
            if (i%prime[j]!=0) num+=1;
        }
        if (num == k){
            prime[k] =i;
            //printf("%d ",prime[k-1]);
            k++;
            //prime[k] = end;
        }
    }

    //printf("%d\n",k);
    int n;
    scanf("%d",&n);
    int cnt=0;
    for (i=0;i<n;i++){
        scanf("%d",&num);
        if (is_prime(prime,num,k)==1) cnt+=1;
    }
    printf("%d\n",cnt);
    return 0;
}


int is_prime(int*prime,int num,int k){
    int i;
    for (i=0;i<k;i++){
        if (num<=prime[i]) return 1;
        else if (num%prime[i]==0) return 0;
    }
    return 1;
}




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

int main(void){
  int A, B, C;
  int ans;
  cin >> A >> B >> C;
  ans = C - (A - B);
  if(ans > 0) cout << ans << "\n";
  else cout << 0 << "\n";
  return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/arc100/tasks/arc100_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(){
    ll res = LINF;
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    vector<ll> cusum(N+1);
    for(int i = 0; i < N;i++) cusum[i+1] = cusum[i] + A[i];
    ll th = 1;
    for(ll m = 2; m <= N - 2;m++){
        ll Lsum = cusum[m], Rsum = cusum[N] - Lsum;
        ll lidx = lower_bound(cusum.begin()+1, cusum.end(), Lsum/2) - cusum.begin();
        ll ridx = lower_bound(cusum.begin()+1, cusum.end(), Lsum+Rsum/2) - cusum.begin();
        for(ll l = max(lidx-th,1LL); l <= min(lidx+th,m-1);l++){
            for(ll r = max(ridx-th,m+1); r <= min(ridx+th,N-1); r++){
                ll P = cusum[l], Q = cusum[m] - cusum[l], R = cusum[r] - cusum[m], S = cusum[N] - cusum[r];
                res = min(res,max({P,Q,R,S}) - min({P,Q,R,S}));
            }
        }
    }
    cerr << "cerr test" << endl;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		int M = Integer.parseInt(scan.next());
		if (N >= M) {
			System.out.println(0);
			return;
		}
		int[] X = new int[M];
		for (int i = 0; i < M; i++) {
			X[i] = Integer.parseInt(scan.next());
		}
		Arrays.sort(X);
		int[] dis = new int[M - 1];
		for (int i = 0; i < M - 1; i++) {
			dis[i] = X[i + 1] - X[i];
		}
		Arrays.sort(dis);
		int sum = 0;
		for (int i = 0; i < M - N; i++) {
			sum += dis[i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 49460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=409;
const int T=80010;
int v[N],t[N],Vg[T],n,Vw[T];
double ans;
 
int main(){
	cin >> n;
	CLR(Vw);CLR(Vg);CLR(v);CLR(t);
	FOR(i,0,n){
		cin >> t[i];
	}
	FOR(i,0,n){
		cin >> v[i];
	}
	int tw=0;
	Vg[0]=0;++tw;
	FOR(i,0,n){
		FOR(j,0,4*t[i]){
			Vg[tw]=4*v[i];
			tw++;
		}
		Vw[tw-1]=4*v[i+1];
	}
	tw--;
	int ta=tw;
	for(int i=n-1;i>=0;i--){
		for(int j=ta;j>=0;j--){
			Vg[j]=min(Vg[j],Vw[ta]+ta-j);
		}
		ta -= 4*t[i];
	}
	for(int i=0;i<=tw;i++)
		Vw[i]=Vg[i];
	ta=0;
	for(int i=0;i<n;i++){
		for(int j=ta;j<=tw;j++){
			Vg[j]=min(Vg[j],Vw[ta]+j-ta);
		}
		ta += 4*t[i];
	}
	ans = 0;
	for(int i=1;i<=tw;i++)
		ans += ((double)Vg[i]+(double)Vg[i-1])/2.0;
	printf("%.10lf\n",ans/16.0);
	return 0;
}

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

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

  int n,k; cin >> n >> k;
  vector<int> a(n),G[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
    a[i]--;
    if(i) G[a[i]].push_back(i);
  }

  int f = 0;
  if(a[0] != 0) a[0] = 0,f = 1;

  vector<int> size(n,0);
  function< int(int) > rec =
  [&](int i){
    int ans = 0;
    for(int v : G[i]){
      ans += rec(v);
      size[i] = max(size[i],size[v] + 1);
    }
    if(size[i] == k-1 && a[i] != 0){
      ans++;
      size[i] = -1;
    }
    return ans;
  };
  cout << rec(0) + f << endl;

  return 0;
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;
string a,b,c;

queue<char>q[3];


int main()
{
    fast;
  
  ll w,h,n;
  cin>>w>>h>>n;
  
  ll x,y,a,x1=0,y1=0;
  
  for(ll i=0;i<n;i++)
  {
  	
  	cin>>x>>y>>a;
  	
  	ll x3=x;
  	ll y3=y;
  	x=x-x1;
  	y=y-y1;
  	if(a==1)
  	{
  		if(x>=0)
  	{
  			w-=x;
  		x1=x3;
	  }
  		
	  }
  	if(a==2)
  	{
  		if(x<=w)
		  w=x;
  		
  		
  		
	  }
  	if(a==3)
  	{
  		if(y>=0){
  				h-=y;
  		y1=y3;
		  }
  	
	  }
  	if(a==4)
  	{
  		if(y<=h)
  		h=y;
  		
	  
	  }
	  
	 // cout<<w<<" "<<h<<"\n";
  	
  }
  w=max(w,0LL);
  h=max(h,0LL);
  cout<<w*h;
}

		
	
	
	
	


Measured memory_bytes: 3608
import sys
READ = lambda : sys.stdin.readline().strip().split()
READi = lambda : map(int, sys.stdin.readline().strip().split())

N, M = READi()
LINES = []
for i in xrange(M):
  LINES += [READi()]
P = READi()

count = 0
for i in xrange(2**N):
  bits = [(i>>b)&1 for b in xrange(N)]
  ok = True
  for line, p in zip(LINES, P):
    tmp = map(lambda x: bits[x-1], line[1:])
    ok &= (sum(tmp)%2) == p
  count += int(ok)
print count

Measured memory_bytes: 2692
###Prediction and Restriction
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
win=[False]*n
def janken(char):
    if char=='r':
        return p
    elif char=='s':
        return r
    else:
        return s
cnt=0
for i in range(n):
    if i-k<0:
        point=janken(t[i])
        cnt+=point
        win[i]=True
    else:
        if t[i]!=t[i-k]:
            point=janken(t[i])
            cnt+=point
            win[i]=True
        else:
            if not win[i-k]:
                point=janken(t[i])
                cnt+=point
                win[i]=True

print(cnt)


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

ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll ans = 1e18;

void f(ll x, ll y) {
    if(gcd(x, y) != 1) return;
    ll score = inv_mod(x, y) * x;
    if(score <= 1) {
        score += x * y;
    }
    ans = min(ans, score - 1);
}

int main() {
    ll n;
    cin >> n;
    n *= 2;
    for (ll x = 1; x * x <= n; ++x) {
        if(n % x == 0) {
            f(x, n/x);
            f(n/x, x);
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 3632
from collections import deque

N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u, v = u - 1, v - 1
    graph[u].append([v, w])
    graph[v].append([u, w])

colors = [-1 for _ in range(N)]
stack = deque()
stack.append(0)
colors[0] = 0

while stack:
    n = stack.popleft()
    for _next, w in graph[n]:
        if colors[_next] != -1:
            continue
        colors[_next] = (colors[n] + w) % 2
        stack.append(_next)

for c in colors:
    print(c)


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  int cnt = 0, ans = 0;
  rep(i, n) {
    if (a[i] == b[i])
      cnt++;
    else
      cnt = 0;
    ans = max(cnt, ans);
  }
  if (ans >= 3)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define TC int tt; cin >> tt; for(int t=0; t<tt; t++)
#define ll long long
#define pb push_back
#define Mod 1000000007
#define limit 2000008
using namespace std;

void solve(int t)
{
    int i,j,n,m,k,ct=0;
    cin >> n;
    string s;
    cin >> s;
    for(i=0,j=n-1; i<=j; i++)
    {
        if(s[i]=='W')
        {
            for( ;j>i; j--)
            {
                if(s[j]=='R')
                {
                    swap(s[j],s[i]);
                    ct++;
                    break;
                }
            }
        }
    }
    cout <<ct<<endl;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int tt=1,t;
  //  cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
  return 0;
}



Measured memory_bytes: 3752
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())printf("%d ",v[_]);cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

//行列累乗
#define MOD 1000000007
vvi mul(vvi A,vvi B){
	vvi C(A.size(),vi(B[0].size()));
	rep(i,A.size())rep(k,B.size())rep(j,B[0].size())
		(C[i][j]+=A[i][k]*B[k][j])%=MOD;
	return C;
}
vvi pow(vvi A,ll n){
	vvi B(A.size(),vi(A.size()));
	rep(i,A.size())B[i][i]=1;
	while(n){
		if(n&1)B=mul(B,A);
		A=mul(A,A);
		n>>=1;
	}
	return B;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,m;
	cin>>n>>m;
	vvi A(n,vi(n));
	rep(i,n)rep(j,n)cin>>A[i][j];
	A=pow(A,m);
	int out=0;
	rep(i,n)rep(j,n)(out+=A[i][j])%=MOD;
	cout<<out<<endl;
}


Measured memory_bytes: 384
'use strict';
(function(stdin) {
  var EOF = /\w* \? \w*/;
  var inputs  = stdin.toString().split(EOF,1).join().trim().split('\n');
  var result = (function(data) {

    var Calc = {
      '+':function(a,b){return a + b;}
     ,'-':function(a,b){return a - b;}
     ,'*':function(a,b){return a * b;}
     ,'/':function(a,b){return a / b >> 0;}
    };

    return data.map(function(v) {
      return Calc[v[1]](parseInt(v[0],10),parseInt(v[2]));
    }).join('\n');

 }(inputs.map(function(v){return v.split(' ')})
  )); 
  console.log(result); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++){
        cin >> A[i];
    }
    int ans = 0;
    sort(A.begin(), A.end(), std::greater<int>());
    int i=0;
    while(i < N / 2){
        ans += A[2 * i];
        ans -= A[2 * i + 1];
        i++;
    }
    if (i * 2 != N){
        ans += A[2 * i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline


def solve():
    N = int(readline())

    anses = [0] * N

    for x in range(1, N):
        for y in range(x, N):
            for z in range(y, N):
                a = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if a > N:
                    break
                if x == y == z:
                    anses[a - 1] += 1
                elif x == y or y == z or z == x:
                    anses[a - 1] += 3
                else:
                    anses[a - 1] += 6
    
    for a in anses:
        print(a)

solve()

Measured memory_bytes: 68912
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =998244353;
const int maxn = 300005;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()
typedef long double dbl;
#define pw(x) (1LL << (x))
#define forn(i, n) for (int i = 0; i < (n); i++)
const ll md = (ll) 1e9 + 7;
 
inline ll add(ll a, ll b) {
  a += b;
  if (a >= md) a -= md;
  return a;
}
 
inline ll sub(ll a, ll b) {
  a -= b;
  if (a < 0) a += md;
  return a;
}
 
inline ll mul(ll a, ll b) {
  return (ll) ((long long)((a%md) * (b%md)) % md);
}
 
inline ll power(ll a, long long b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
 
inline ll inv(ll a) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

vector<int> g[maxn], ed;
int n;
int dfs(int u, int p){
  int sub = 1;
  for(auto v:g[u]){
    if(v == p){
      continue;
    }
    int now = dfs(v, u);
    sub += now;
    ed.push_back(now*(n-now));
  }
  return sub;
}

int32_t main()
{ 
  IOS

  int n;
  cin >> n;
  int a[n];
  int maxi = 0, ans = 0;;
  for(int i = 0;i<n;i++){
    cin >> a[i];
    maxi = max(maxi, a[i]);
    ans += maxi - a[i];
  }
  cout << ans << endl;

  

  










  
    
} 
 

Measured memory_bytes: 12240
#include <string>
#include <iostream>

using namespace std;
string buf;
bool found(){
    return buf.find("this",0) != string::npos ||
        buf.find("that",0) != string::npos ||
        buf.find("the",0) != string::npos;
}

bool isalpha(char c){
    return 'a' <= c && c <= 'z';
}

int main(){
    while(getline(cin, buf)){
        while(!found()){
            for(int i=0; i<buf.size(); i++){
                if(isalpha(buf[i])) buf[i]++;
                if(buf[i] == 'z'+1) buf[i] = 'a';
            }
        }
        cout << buf << endl;
    }
}

Measured memory_bytes: 1176
N,A,B = [int(x) for x in input().split()]
ans = 0
def douka(a):
  wa = 0
  for i in range(4,-1,-1):
    if a // (10**i) == 0:
        continue
    wa += a//(10**i)
    a -= (a//(10**i))*(10**i)
  return wa
for i in range(1,N+1):
    if A <= douka(i) and douka(i) <= B:
      ans += i
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int,P> P3;
typedef pair<double, P3> P4;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(3e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

struct edge{
    int to, c;
    double d;
};

int n, m, s, g;
vector<vector<edge> > G;
double tmin[35][35][35];  // 頂点iに頂点jから速さkで到着するときの最短時間

void dijkstra(){
    REP(i,n)REP(j,n)fill(tmin[i][j],tmin[i][j]+35,double(IINF));
    priority_queue<P4, vector<P4>, greater<P4> > que;
    tmin[s][s][0] = 0.0;
    que.push({0.0,{s,{s,0}}});
    while(!que.empty()){
        P4 p = que.top();
        que.pop();
        int from = p.second.second.first, v = p.second.second.second, pre = p.second.first;
        if(p.first > tmin[from][pre][v] + EPS)continue;
        for(auto &e : G[from]){
            if(e.to == pre)continue;
            for(int dv=-1; dv<=1; dv++){
                int nv = v+dv;
                if(nv<=0 || nv>e.c)continue;
                if(tmin[e.to][from][nv] > tmin[from][pre][v] + e.d/double(nv) + EPS){
                    tmin[e.to][from][nv] = tmin[from][pre][v] + e.d/double(nv);
                    que.push(P4(tmin[e.to][from][nv],{from,{e.to,nv}}));
                }
            }
        }
    }
}


int main() {
    while(cin >> n >> m, n){
        cin >> s >> g;
        s--; g--;
        G.clear();
        G.resize(n);
        REP(i,m){
            int x, y, c;
            double d;
            cin >> x >> y >> d >> c;
            x--; y--;
            G[x].push_back({y,c,d});
            G[y].push_back({x,c,d});
        }
        dijkstra();
        double ans = double(IINF);
        REP(i,n) ans = min(ans, tmin[g][i][1]);
        if(ans<IINF/2){
            printf("%.8lf\n",ans);
        }
        else{
            cout << "unreachable" << endl;
        }
    }
    return 0;
}



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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  vector<int> b(n);  // copy of a
  REP(i, n) b[i] = a[i];
  sort(ALL(b));
  REP(i, n) {
    if (a[i] == b[n - 1]) {
      cout << b[n - 2] << endl;
    } else {
      cout << b[n - 1] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3200
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
long long x,d;
long long ans;
struct data
{
	long long l,r;
	friend bool operator < (data a,data b)
	{
		if((a.l%d+d)%d!=(b.l%d+d)%d)return (a.l%d+d)%d<(b.l%d+d)%d;
		else return a.l<b.l;
	}
}p[200020];
int main()
{
	scanf("%d %lld %lld",&n,&x,&d);
	if(d==0)
	{
		if(x==0)printf("1");
		else printf("%d",n+1);
		return 0;
	}
	if(d<0)d=-d,x-=(n-1)*d;
	for(int i=0;i<=n;++i)p[i].l=1ll*i*x+1ll*i*(i-1)/2*d,p[i].r=1ll*i*x+1ll*(2*n-1-i)*i/2*d;
	sort(p,p+1+n);
//	for(int i=0;i<=n;++i)printf("%lld %lld\n",p[i].l,p[i].r);
	for(int i=0;i<=n;++i)
	{
		int r=i;
		while(r<n&&(p[r+1].l%d+d)%d==(p[i].l%d+d)%d)++r;
		long long ed=-9223372036854775807ll;
		for(int j=i;j<=r;++j)
		{
			if(p[j].r<=ed)continue;
			if(p[j].l<=ed)ans-=(ed-p[j].l)/d+1;
			ans+=(p[j].r-p[j].l)/d+1;
			ed=p[j].r;
		}
		i=r;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3456
import math
a,b,x = map(int,input().split())
if x <= a**2*b/2:
  theta = (math.pi/2 - math.atan(2*x/(a*b**2)))/(2*math.pi)*360
else:
  theta = (math.atan(2*(b*a**2-x)/a**3))/(2*math.pi)*360

print(theta)

Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

#define MOD (long long int)(1e9+7)
#define ll long long
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()


int main(void) {
	ll A, B, C;
	cin >> A >> B >> C;
	
	ll tmp = C - A - B;
	if (tmp > 0 && 4 * A*B < tmp*tmp) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int h, w;
    cin >> h >> w;
    int d[h][w];
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++) d[i][j] = 0;
    string s[h];
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == '#')
            {
                if (i > 0)
                {
                    d[i - 1][j]++;
                    if (j > 0) d[i - 1][j - 1]++;
                    if (j < w - 1) d[i - 1][j + 1]++;
                }
                if (j > 0) d[i][j - 1]++;
                if (j < w - 1) d[i][j + 1]++;
                if (i < h - 1)
                {
                    d[i + 1][j]++;
                    if (j > 0) d[i + 1][j - 1]++;
                    if (j < w - 1) d[i + 1][j + 1]++;
                }
            }
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == '#') cout << '#';
            else cout << d[i][j];
        }
        cout << endl;
    }
    
}

Measured memory_bytes: 3604
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.Set;
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
 *
 * @author koneko096
 */
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);
    BTrickOrTreat solver = new BTrickOrTreat();
    solver.solve(1, in, out);
    out.close();
  }

  static class BTrickOrTreat {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
      Set<Integer> S = new HashSet<>();

      int n = in.nextInt(), k = in.nextInt();
      for (int i = 0; i < k; i++) {
        int d = in.nextInt();
        for (int j = 0; j < d; j++) {
          S.add(in.nextInt());
        }
      }

      out.println(n - S.size());
    }

  }


  static class InputReader {
    private BufferedReader reader;
    private 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: 27104
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  string s;
  cin >> s;
  
  int maxcount = 0;
  for(int i = 0; i < s.size(); i++){
    int count;
    count = 0;
    if(s[i] == 'A' || s[i] == 'G' || s[i] == 'T' || s[i] == 'C'){
      while(s[i] == 'A' || s[i] == 'G' || s[i] == 'T' || s[i] == 'C'){
      count++;
      i++;
      }
      if(maxcount <= count) maxcount = count;
    }
  }
  cout << maxcount;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int g1[7]={1,3,5,7,8,10,12};
  int g2[4]={4,6,9,11};
  int x,y;
  scanf("%d %d",&x,&y);

  if(x==y){
    puts("Yes");
    return 0;
  }

  int flag1=0;
  for(int i=0;i<7;i++){
    if(g1[i]==x){
      flag1=1;
    }
    if(flag1==1&&g1[i]==y){
      puts("Yes");
      return 0;
    }
  }

  int flag2=0;
  for(int i=0;i<4;i++){
    if(g2[i]==x){
      flag2=1;
    }
    if(flag2==1&&g2[i]==y){
      puts("Yes");
      return 0;
    }
  }

  puts("No");

  return 0;
}


Measured memory_bytes: 128
N,T=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(N)]
ans=[]
for list in lists:
  if list[1]<=T:
    ans.append(list)
if len(ans)==0:
  print('TLE')
else:
  ans.sort(key=lambda x:x[0])
  print(ans[0][0])

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0) break;
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[111111];
  vector<int>vec;
  cin>>n;
  for(int i=1;i<=n;i++) cin>>a[i];
  int count=0;
  for(int i=1;i<=n-1;i++){
    if(a[i]==i){
      swap(a[i],a[i+1]);
      count++;
    }
  }
  if(a[n]==n){
    swap(a[n-1],a[n]);
    count++;
  }
  cout<<count<<endl;
  return(0);
}


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

using namespace std;

int n, c[505], s[505], f[505], x[505];

int main()
{
    cin >> n;
    for (int i = 1; i < n; i++)
        cin >> c[i] >> s[i] >> f[i];
    if (n==1) cout << 0;
    else
    {
        for (int i = 1; i < n; i++)
        {
            x[i]=s[i];
            for (int j = i+1; j <= n; j++)
            {
                x[i]+=c[j-1];
                if (j==n) break;
                if (x[i]<s[j]) x[i]=s[j];
                else if (x[i]%f[j]!=0) x[i]+=f[j]-x[i]%f[j];
            }
        }
        for (int i = 1; i < n; i++)
            cout << x[i] << '\n';
        cout << 0;
    }
}


Measured memory_bytes: 256
import math
a, b, x = map(float, input().split())

empty = a * a * b - x
if empty > a * a * b * 0.5:
    c = 2 * x / (a * b)
    theta = 90 - math.degrees(math.atan(c / b))
else:
    c = 2 * empty / (a * a)
    theta = math.degrees(math.atan(c / a))

print(theta)

Measured memory_bytes: 3060
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    K = int(input())

    if K % 2 == 0:
        print(-1)
        return

    a = 7
    for i in range(K):
        if a % K:
            a = (a*10 + 7) % K
        else:
            print(i+1)
            break
    else:
        print(-1)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 63052