akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=10000000;


int dp[11][200001];


int main(){
    int D,G;
    cin >> D >> G;
    G/=100;
    int p[D],c[D];
    for(int i=0;i<D;i++){
        cin >> p[i] >> c[i];
        c[i]/=100;
    }
    for(int i=0;i<=D;i++){
        for(int j=0;j<200001;j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<D;i++){
        for(int j=0;j<=p[i];j++){
            for(int k=0;k<100001;k++){
                if(j==p[i]) dp[i+1][k+(i+1)*j+c[i]]=min(dp[i+1][k+(i+1)*j+c[i]],dp[i][k]+j);
                else dp[i+1][k+(i+1)*j]=min(dp[i+1][k+(i+1)*j],dp[i][k]+j);
            }
        }
    }
    int ans=INF;
    for(int i=G;i<200001;i++){
        ans=min(ans,dp[D][i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

int main(){
  int N, K; cin >> N >> K;
  int now = 1;

  for (int i = 0; i < N; i++){
    if (now <= K){
      now = now * 2;
    }else{
      now += K;
    }
  }
  
  cout << now << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        List<Integer> list = new LinkedList<>();
        for(int i = 0; i < n; i++){
            list.add(Integer.parseInt(sc.next()));
        }
        
        int[] x = new int[n];
        for(int i = n-1; i >= 0; i--){
            for(int j = i; j >= 0; j--){
                if(list.get(j) == j+1){
                    x[i] = list.get(j);
                    list.remove(j);
                    break;
                }
                if(j == 0){
                    System.out.println("-1");
                    return;
                }
            }
        }
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(x[i]).append(System.lineSeparator());
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 23764
import java.math.BigInteger;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        BigInteger res=in.nextBigInteger();--n;
        while(n--!=0){
            BigInteger b=in.nextBigInteger();
            res=res.multiply(b).divide(res.gcd(b));
        }
        System.out.print(res);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <sstream>
int used[101]={0};
int V[101][101]={0};
int first[101]={0};
int finish[101]={0};
int t=1;
int n;

void search(int i){
  first[i]=t++;
  used[i]++;
  for(int j=0;j<n;j++){
    if(V[i][j]==1 and used[j]==0){
      search(j);
    }
  } 
  finish[i]=t++;
}



int main () {
  int k;
  int u1,u;
  std::cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      V[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    std::cin>>u1>>k;
    for(int j=0;j<k;j++){
      std::cin>>u;
      V[u1-1][u-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    if(used[i]==0){
      search(i);
    }
  }
  for(int i=0;i<n;i++){
    std::cout<<i+1<<" "<<first[i]<<" "<<finish[i]<<"\n";
  }


  return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b&&b!=c || a==c&&b!=c || b==c&&a!=c) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
    

f=lambda:map(int,input().split())
N,M=f()
uf=UnionFind(N+1)
for _ in range(M):
    a,b=f()
    uf.Unite(a,b)
    
print(max([uf.Count(i+1) for i in range(N)]))

Measured memory_bytes: 95236
import java.util.Scanner;
import java.util.Arrays;
 
class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt(), M = in.nextInt(), R = in.nextInt();
        int[] r = new int[R];
        int[][] dist = new int[N][N];
        for (int i = 0; i < N; i++) {
            Arrays.fill(dist[i], Integer.MAX_VALUE/2);
        }
        for (int i = 0; i < R; i++) {
            r[i] = in.nextInt() - 1;
        }
        for (int i = 0; i < M; i++) {
            int a = in.nextInt() - 1, b = in.nextInt() - 1, c = in.nextInt();
            dist[a][b] = dist[b][a] = Math.min(dist[a][b], c);
        }
        in.close();
        for(int k = 0; k < N; k++){
            for(int i = 0; i < N; i++){
                for(int j = 0; j < N; j++){
                    dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
        int min = Integer.MAX_VALUE;
        boolean[] visited = new boolean[R];
        for(int i = 0; i < R; i++){
            visited[i] = true;
            min = Math.min(min, dfs(0, i, visited, r, dist));
            visited[i] = false;
        }
        System.out.println(min);
    }
    public static int dfs(int cost, int pos, boolean[] visited, int[] r, int[][] dist){
        int min = Integer.MAX_VALUE;
        for(int i = 0; i < visited.length; i++){
            if(i == pos) continue;
            if(!visited[i]){
                visited[i] = true;
                min = Math.min(min, dfs(cost + dist[r[pos]][r[i]], i, visited, r, dist));
                visited[i] = false;
            }
        }
        return min == Integer.MAX_VALUE ? cost : min;
    }
}

Measured memory_bytes: 46300
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        vector<int> v(n);
        for (auto &&i : v) scanf("%d", &i);
        int x; cin >> x;
        int l = 0, r = n-1, ans = 0;
        while(l <= r){
            ans++;
            int mid = (l+r)/2;
            if(v[mid] == x) break;
            if(v[mid] > x) r = mid-1;
            else l = mid+1;
        }
        cout << ans << "\n";
    }
    return 0;
}


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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

const int M = 1000 * 1000;
int main() {
  int N; cin>>N;
  vector<int> A(M+1, 0);
  vector<bool> B(M+1, true);
  REP(i,N) {
    int v; cin>>v;
    A[v]++;
  }
  int ans = 0;
  for(int i = 1; i <= M; i++) {
    if(A[i] > 0 && B[i]) {
      if(A[i] == 1) {
	//	cout << i << endl;
	ans++;
      }
      for(int j = i; j <= M; j+= i) {
	B[j] = false;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6840
total, count = gets.split.map(&:to_i)
dists = gets.split.map(&:to_i).sort

gaps = [0, dists, total].flatten.each_cons(2).map{|a, b| b - a}
first = gaps.shift
gaps[-1] += first
max_gap = gaps.max
min_dist = total - max_gap

puts min_dist

Measured memory_bytes: 25512
#include <stdio.h>
int main(void)
{
    int N;
    long long int x;
    scanf("%d", &N);
    int t[N], a[N];
    for(int i=0; i<N; i++)
    {
        scanf("%d %d", &t[i], &a[i]);
    } 
    long long int avote=1, tvote=1, temp[2];
    for(int i=0; i<N; i++)
    {
        temp[0]=avote;
        temp[1]=tvote;
        while(temp[0]%a[i]!=0) temp[0]++;
        while(temp[1]%t[i]!=0) temp[1]++;
        
        if((temp[0]/a[i])<(temp[1]/t[i])) x=temp[1]/t[i];
        else if((temp[0]/a[i])>(temp[1]/t[i])) x=temp[0]/a[i];
        else x=temp[1]/t[i]; 
        
        avote=a[i]*x;
        tvote=t[i]*x;
    }
    printf("%lld", avote+tvote);
    return 0;
}

Measured memory_bytes: 128
x = int(input())

x2 = int(x**0.5)
if x2**5 == x:
  print(x2, 0)
  exit()
elif x2**5-1 == x:
  print(X2, -1)
  exit()

for i in range(1, int(x**0.5)+2):
  if x%i == 0:
    tmp1 = 0
    tmp2 = 0
    a1 = i
    b1 = 0
    a2 = i-1
    b2 = -1
    while abs(tmp1) <= x**2 or abs(tmp2) <= x**2:
      tmp1 = a1**5 - b1**5
      tmp2 = a2**5 - b2**5
      if tmp1 == x:
        print(a1, b1)
        exit()
      elif tmp2 == x:
        print(a2, b2)
        exit()
      a1+=1
      b1+=1
      a2-=1
      b2-=1


Measured memory_bytes: 68124
n = int(input())
a = map(int, input().split())
l = {}
s = 0
for i in a:
  l[i] = l.get(i, 0) + 1
  s += i
q = int(input())
for i in range(q):
  b, c = map(int, input().split())
  s -= l.get(b, 0) * b + l.get(c, 0) * c
  l[c] = l.get(c, 0) + l.get(b, 0)
  l[b] = 0
  s += l.get(c, 0) * c
  print(s)


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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int ans = 0;
  for(int i=1; i<N; ++i) {
    string a = S.substr(0, i);
    string b = S.substr(i,S.size());
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    a.erase(unique(a.begin(), a.end()),a.end());
    b.erase(unique(b.begin(), b.end()),b.end());
    int cnt=0;
    for(int n=0; n<a.size(); ++n) {
      if(count(b.begin(), b.end(), a[n])) cnt++;
    }
    if(cnt > ans) ans = cnt;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author ilyakor
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    TaskA solver = new TaskA();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskA {

    public void solve(int testNumber, InputReader in, OutputWriter out) {
      char[] s = in.nextToken().toCharArray();
      int numW = 0;
      for (char c : s) {
        if (c == 'W') {
          ++numW;
        }
      }
      long res = 0;
      for (char c : s) {
        if (c == 'W') {
          --numW;
        } else {
          res += numW;
        }
      }
      out.printLine(res);
    }

  }

  static class InputReader {

    private InputStream stream;
    private byte[] buffer = new byte[10000];
    private int cur;
    private int count;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public static boolean isSpace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public int read() {
      if (count == -1) {
        throw new InputMismatchException();
      }
      try {
        if (cur >= count) {
          cur = 0;
          count = stream.read(buffer);
          if (count <= 0) {
            return -1;
          }
        }
      } catch (IOException e) {
        throw new InputMismatchException();
      }
      return buffer[cur++];
    }

    public int readSkipSpace() {
      int c;
      do {
        c = read();
      } while (isSpace(c));
      return c;
    }

    public String nextToken() {
      int c = readSkipSpace();
      StringBuilder sb = new StringBuilder();
      while (!isSpace(c)) {
        sb.append((char) c);
        c = read();
      }
      return sb.toString();
    }

  }

  static class OutputWriter {

    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
      for (int i = 0; i < objects.length; i++) {
        if (i != 0) {
          writer.print(' ');
        }
        writer.print(objects[i]);
      }
    }

    public void printLine(Object... objects) {
      print(objects);
      writer.println();
    }

    public void close() {
      writer.close();
    }

  }
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll  long long int 
using namespace std;
int main()
{
	string s;
	ll num;
	ll mm=1145141919;
	cin>>s;
	for(ll i=0;i<s.size()-2;i++){
		num=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
		if(mm>abs(num-753)) mm=abs(num-753);
	}
	cout<<mm;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void){
  int i, N, MIN, INPUT, count;
  
  count = 1;
  scanf("%d%d", &N, &MIN);
  for(i = 1; i < N; i++)
  {
    scanf("%d", &INPUT);
    if(INPUT <= MIN)
    {
      count++;
      MIN = INPUT;
    }
  }
  printf("%d", count);
    
    return(0);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

const int MX = 50001;
bool sieve[MX];

void prepare() {
    memset(sieve, false, sizeof sieve);
    sieve[0] = sieve[1] = true;
    for (int i=2; i*i<MX; ++i) {
        if ( ! sieve[i]) {
            for (int j=i*i; j<MX; j+=i) {
                sieve[j] = true;
            }
        }
    }
}

int main() {
    prepare();
    int n;
    while (cin >> n, n) {
        int cnt = 0;
        for (int i=1; i<=n-i; ++i) {
            if ( ! sieve[i] && ! sieve[n-i]) {
                cnt ++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <thread>///////////////////

#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<long long int> vll;
vector<long long int> w;
vector<vector<int>> vec(50, vector<int>(4, 0));

int N, Y;
int mode = 0;

//tuple<int, int, int> calc(int A, int B, int C) {}



int main() {
	int N, M;
	int ans = 0;
	double vote = 0;
	cin >> N >> M;
	v.resize(N);
	rep(i, 0, N) { 
		cin >> v[i];
		vote += v[i];
	}
	sort(v.begin(), v.end());

	rem(i, N-1, N-1-M) {
		//cout << v[i] << " " << vote << " " << vote * (1. / (4. * M)) << '\n';
		if (v[i] >= vote * (1. / (4. * M)))++ans;
	}
	if (ans == M)cout << "Yes" << '\n';
	else cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include <numeric>
#include <cmath>
#include <bits/stdc++.h>

using ll = long long;
using namespace std;

unsigned long long gcd(unsigned long long n,unsigned long long m){
  unsigned long long nn,mm;
  if(n > m){
    nn = n;
    mm = m;
  }
  else{
    nn = m;
    mm = n;
  }

  if(nn % mm == 0){
    return mm;
  }else{
    return gcd(mm,nn % mm);
  }
}

int main(){
  unsigned long long a,b,c,d,ii,num=0;
  unsigned long long ac,ad,bc,bd,acd,bcd;
  unsigned long lc,gc;
  
//  __uint128_t ii128;
  cin >> a >> b >> c >> d;

//  for(ii=a;ii<=b;ii++){
//    if(ii % c != 0 && ii % d != 0){
//      num++;
//    }
//  }
  gc = __gcd(c,d);
  //  cout << "gc:" << gc << endl;
  lc = (c*d)/gc;
  ac = (a-1)/c;
  ad = (a-1)/d;
  bc = b/c;
  bd = b/d;
  acd = (a-1)/lc;//(c*d);
  bcd = b/lc;//(c*d);
//  cout << "lc :" << lc << endl;
//  cout << "ac :" << ac << endl;
//  cout << "ad :" << ad << endl;
//  cout << "bc :" << bc << endl;
//  cout << "bd :" << bd << endl;
//  cout << "acd:" << acd << endl;
//  cout << "bcd:" << bcd << endl;
// 532105071133627368
// 532105071279727843
  cout << (b-a+1)-(bc-ac)-(bd-ad) + (bcd-acd) << endl;
  //cout << (b-a+1)-(bc-ac)-(bd-ad)  << endl;
  //cout << (b-a+1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
bool is_prime(int x)
{
	if(x<=2)return false;
	For(i,2,sqrt(x))if(x%i==0)return false;
	return true;
}
int main()
{
	int n,cnt=0,i=0;
	cin>>n;
	while(cnt<n)
	{
		int p=3+10*i;
		if(is_prime(p))
		{
			cnt++;
			cout<<p<<" ";
		}
		i++;
	}
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var A = G;
		var M = A.Select(x => Abs(x)).Max();
		var dp = new long[N + 1, 2];
		dp[0, 1] = -(M + 2) * (N + 2L);
		for (var i = 0; i < N; i++) for (var k = 0; k < 2; k++) dp[i + 1, k] = Max(dp[i, k] + A[i], dp[i, 1 - k] - A[i]);
		WriteLine(dp[N, 0]);
	}
}


Measured memory_bytes: 33588
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

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

    vector<int> l(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];        
    }
    bool z = true;
    reverse(l.begin(), l.end());
    for(int i = 0; i < n; i++){
        if(i != n-1){
            if(l[i+1] - l[i] > 1){
                z = false;
                break;
            }else if(l[i+1] - l[i] == 1){
                l[i+1]--;
            }
        }
    }

    if(z) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cfloat>

using namespace std;

int main(){
   int N,T,A;
   cin >> N;
   cin >> T >> A;
   int H[N];
   for(int i=0; i<N; i++){
      cin >> H[i];
   }
   double T_i[N];
   for(int i=0; i<N; i++){
      T_i[i] = T - H[i] * 0.006;
   }
   double min_delta_T = DBL_MAX;
   int min_idx = 0;
//   for(int i=0; i<N; i++){
//      for(int j=0; j<N; j++)
//      {
//         if(fabs(T_i[i]-A) < fabs(T_i[j]-A)){
//            min_delta_T = fabs(T_i[i]-A);
//            min_idx = i;
//         }
//      }
//   }
 
//   for(int i=0; i<N; i++)
//   {
//      maxv = max(maxv, R[i] - minv);
//      minv = min(minv, R[i]);
//   }
   
  for(int i=0; i<N; i++)
  {
     if(fabs(T_i[i]-A) < min_delta_T)
     {
        min_delta_T = fabs(T_i[i] - A);
        min_idx = i;
     }
  }

   std::cout << min_idx+1 <<std::endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)
#define debug(x) cerr << #x << ' ' << x << endl;
using namespace std;

typedef long long ll;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;
const double EPS=1e-8;
inline int sign(double a){return a<-EPS?-1:a>EPS;}
inline int cmp(double a,double b){return sign(a-b);}
//点
struct P{
    double x,y;
    P(){}
    P(double _x,double _y):x(_x),y(_y){}
    P operator + (P p){return P(x+p.x,y+p.y);}
    P operator - (P p){return P(x-p.x,y-p.y);}
    P operator * (double k){return P(x*k,y*k);}
    P operator / (double k){return P(x/k,y/k);}
    double dot(P p){return x*p.x+y*p.y;}
    double det(P p){return x*p.y-y*p.x;}
    double distTo(P p){return (*this-p).abs();}
    double alpha(){return atan2(y,x);}
    void read(){scanf("%lf%lf", &x, &y);}
    void write(){printf("%.10lf %.10lf\n", x, y);}
    double abs(){return sqrt(abs2());}
    double abs2(){return x*x+y*y;}
    P rot90(){return P(-y,x);}
    P unit(){return *this/abs();}
    int quad(){return sign(y)==1||(sign(y)==0&&sign(x)>=0);}
    P rot(double an){return P(x*cos(an)-y*sin(an),x*sin(an)+y*cos(an));}
    bool operator < (P p)const{int c=cmp(x,p.x);if(c)return c==-1;return cmp(y,p.y)==-1;}
    bool operator == (P o)const{return cmp(x,o.x)==0&&cmp(y,o.y)==0;}
}s[105];

int main(int argc, char const *argv[])
{
    int n;
    scanf("%d", &n);
    rep(i, 0, n-1) s[i].read();
    double area = 0;
    rep(i, 0, n-1) area += s[i].det(s[(i+1)%n]);
    printf("%.1lf\n", area/2);
    return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
int dp[3003][3003][2];
int n,a[3003];

int dfs(int l,int r,int t){
  if(l>r)return 0;
  if(dp[l][r][t]!=-1e16)return dp[l][r][t];
  if(t==0){
    int res=-1e15;
    res=max(res,dfs(l+1,r,1)+a[l]);
    res=max(res,dfs(l,r-1,1)+a[r]);
    return dp[l][r][t]=res;
  }
  else{
    int res=1e15;
    res=min(res,dfs(l+1,r,0)-a[l]);
    res=min(res,dfs(l,r-1,0)-a[r]);
    return dp[l][r][t]=res;
  }
}

signed main(){
  r(i,3003)r(j,3003)r(k,2)dp[i][j][k]=-1e16;
  cin>>n;
  r(i,n) cin>>a[i];
  cout<<dfs(0,n-1,0)<<endl;
}

Measured memory_bytes: 141312
d = Hash.new
1.upto(150) do |i|
    (i+1).upto(150) do |j|
        d[[i,j]] = i**2 + j**2
    end
end
d = d.sort{|a,b| (a[1] <=> b[1]).nonzero? || a[0][0] <=> b[0][0]}.to_a
loop do
    h, w = gets.split.map(&:to_i)
    break if h == 0 && w == 0
    puts [d[d.index([[h,w], h**2 + w**2]) + 1][0]].map{|i| "#{i[0]} #{i[1]}"}
end

Measured memory_bytes: 7360
#include <iostream>

using namespace std;

int main(){
	int N, K;
	cin >> N >> K;

	int l[N];
	for(int i = 0; i < N; i++){
		cin >> l[i];
	}

	int swap;
	int sum_length = 0;
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			if(l[j] > l[i]){
				swap = l[j];
				l[j] = l[i];
				l[i] = swap;
			}
		}
		if(i < K){
			sum_length += l[i];
		}
	}

	cout << sum_length << endl;

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int map[150][150];

int issomelen(int len,int h){
	int i,j;
	
	for(i = h+1;i < 150;i++){
		for(j = i+1;j < 150;j++){
			if(map[i][j] == len){
				printf("%d %d\n",i,j);
				return 1;
			}
		}
	}
	return 0;
}

int search(int len){
	int i,j;
	
	for(i = 1;i < 150;i++){
		for(j = i+1;j < 150;j++){
			if(map[i][j] == len){
				printf("%d %d\n",i,j);
				return 1;
			}
		}
	}
	
	return 0;
}

int main(void) {
	int i,j,h,w,len;
	
	for(i = 1;i < 150;i++){
		for(j = i+1;j < 150;j++){
			map[i][j] = i*i+j*j;
		}
	}
	
	while(1){
		scanf("%d %d",&h,&w);
		if(!h && !w){
			break;
		}
		len = h*h+w*w;
		if(!issomelen(len,h)){
			while(!search(++len));
		}
	}
	
	return 0;
}

Measured memory_bytes: 688
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var r = int.Parse(line[1]);
        Console.WriteLine(n >= 10 ? r : r + 100 * (10 - n));
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <map>

using namespace std;

long long func(long long *list)
{
	long long ans = list[0] * list[1] * list[2];

	ans += list[0] * list[1] * list[3];

	ans += list[0] * list[1] * list[4];

	ans += list[0] * list[2] * list[3];

	ans += list[0] * list[2] * list[4];

	ans += list[0] * list[3] * list[4];

	ans += list[1] * list[2] * list[3];

	ans += list[1] * list[2] * list[4];

	ans += list[1] * list[3] * list[4];

	ans += list[2] * list[3] * list[4];

	return ans;
}

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

	long long list[5] = {};

	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;

		char ss = s[0];

		switch (ss)
		{
		case 'M':
			list[0]++;
			break;
		case 'A':
			list[1]++;
			break;
		case 'R':
			list[2]++;
			break;
		case 'C':
			list[3]++;
			break;
		case 'H':
			list[4]++;
			break;
		default:
			break;
		}
	}

	long long ans = 1;

	cout << func(list) << endl;

	return 0;
}

Measured memory_bytes: 256
N, M=map(int, input().split())
a=[int(input()) for _ in range(M)]
tmp=[1,1,2]
for i in range(N):
    tmp.append(tmp[-1]+tmp[-2])
def func(x):
    if x==-1:
        return 0
    elif x==-2:
        return 1
    else:
        return tmp[x]

if M==0:
    print(func(N)%1000000007)
    exit(0)
s=func(a[0]-1)
for i in range(0, M-1):
    s*=func(a[i+1]-a[i]-2)
s*=func(N-a[M-1]-1)
print(s%1000000007)
         
    


Measured memory_bytes: 464040
#include <bits/stdc++.h>
using namespace std;
int n,w[104],goukei,g2,g3,meyasu,a1,a2,meyasu2;
bool ok;
int main() {
    // insert code here...
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>w[i];
        goukei+=w[i];
    }
    g2=goukei/2;
    for (int i=0; i<n; i++) {
        
        if (ok) {
            g3=meyasu+w[i];
            break;
        }else meyasu+=w[i];
        if(meyasu>=g2){ok=true;meyasu2=meyasu-w[i];}
    }
    cout<<min(min(abs(goukei-(meyasu*2)),abs(goukei-(g3*2))),goukei-(meyasu2*2))<<endl;
    
}

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

typedef long long ll;

int main() {
    ll N, P;
    cin >> N >> P;

    map<ll, ll> m;
    for (ll i = 2; i * i <= P; i++) {
        while (P % i == 0) {
            m[i]++;
            P /= i;
        }
    }
    if (P != 1) m[P]++;

    ll res = 1;
    for (auto it = m.begin(); it != m.end(); it++) {
        pair<ll, ll> p = *it;
        while (p.second >= N) {
            res *= p.first;
            p.second -= N;
        }
    }

    cout << res << endl;
    return 0;
}

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

using namespace std;

const int Maxn = 1e5+7;

int n, q;
int a[Maxn];
long long s[Maxn], ss[Maxn];

int main()
{
    cin >> n >> q;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        s[i] = (i-2 > 0 ? s[i-2] : 0)+a[i];
        ss[i] = ss[i-1]+a[i];
    }

    for(int i = 1, x; i <= q; ++i)
    {
        cin >> x;
        if(x >= a[n-1])
        {
            cout << s[n] << endl;
            continue;
        }
        int l = 0, r = a[n]-x, pl, pr;
        while(l < r)
        {
            int mid = (l+r+1)>>1;
            pl = lower_bound(a+1, a+n, x-mid)-a;
            pr = upper_bound(a+1, a+n, x+mid)-a;
            if(pr-pl > n-pr+1) r = mid-1;
            else l = mid;
        }
        pl = lower_bound(a+1, a+n, x-l)-a;
        pr = upper_bound(a+1, a+n, x+l)-a;
        if(n-pr == pr-pl) cout << (ss[n]-ss[pr-1])+(pl-2 > 0 ? s[pl-2] : 0) << endl;
        else if(pr-pl == n-pr+1) cout << (ss[n]-ss[pr-1])+(pl-1 > 0 ? s[pl-1] : 0) << endl;
        else if(pr-pl == n-pr-1)
        {
            // choose pr
            if(pl-1 < 1 || x-a[pl-1] > a[pr]-x)
                cout << (ss[n]-ss[pr])+(pl-1 > 0 ? s[pl-1] : 0) << endl;
            else // choose pl
                cout << (ss[n]-ss[pr-1])+(pl-3 > 0 ? s[pl-3] : 0) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3712
import Data.List
import Control.Monad

main =  readLn >>= flip replicateM readLn >>= print . solve . sort

solve :: [Int] -> Int
solve ss
    | s `mod` 10 == 0 = edit ss
    | otherwise = s
    where
        s = sum ss

        edit (x : xs)
            | x `mod` 10 == 0 = edit xs
            | otherwise = s - x
        edit _ = 0


Measured memory_bytes: 1020
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<queue>
#define MN 505
using namespace std;
const int INF=1e9;
int c[MN],d[MN],bo[MN];
char s[MN][MN];
queue<int> q;
int n,mmh=INF,id=0,ma;
void work(){
	int i,x;
    for(i=1;i<=n;i++)
	if(!d[i]) q.push(i),bo[i]=1;
    while(!q.empty()){
        bo[x=q.front()]=0;q.pop();
        for(i=1;i<=n;i++) 
		if(d[i]>d[x]+1) if(d[i]=d[x]+1,!bo[i]) q.push(i),bo[i]=1;
    }
}
int main(){
	register int i,j;
   	scanf("%d",&n);
    for(i=1;i<=n;i++)
	for(scanf("%s",s[i]+1),j=1;j<=n;j++){
        s[i][j]=(s[i][j]=='#');
        c[i]+=s[i][j];ma=max(ma,c[i]);
    }
    if(!ma) return puts("-1"),0;
    for(i=1;i<=n;i++) d[i]=INF;
    
    for(i=1;i<=n;i++)
	for(j=1;j<=n;j++)
	if (s[i][j]) d[j]=0;
    work();
    
    for(i=1;i<=n;i++) if(d[i]!=INF&&n-c[i]<mmh) mmh=min(mmh,n-c[i]+d[i]),id=i;
    
    for(j=1;j<=n;j++) for(i=1;i<=n;i++) if (!s[i][j]) {mmh++;break;}
    printf("%d\n",mmh);
}

Measured memory_bytes: 512
// https://atcoder.jp/contests/abc079/tasks/abc079_c
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.length();
    REP(i, BIT(n - 1)) {
        ll t = s[0] - '0';
        string so;
        so += s[0];
        REP(j, n - 1) {
            if (i & BIT(j)) {
                t -= s[j + 1] - '0';
                so = so + "-" + s[j + 1];
            } else {
                t += s[j + 1] - '0';
                so = so + "+" + s[j + 1];
            }
        }
        if (t == 7) {
            cout << so << "=7\n";
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> tpi;
typedef pair<pii,pii> qpi;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX = 1e5;
const int MV = 1e5;
int MA = -INF , MI = INF , ANS;

int32_t main()
{
	IO;
	int n , m , s = 0;
	cin >> n;
	m = n;

	while( m > 0 )
	{
		s += (m%10);
		m /= 10;
	}
	
	if( n % s  == 0 )
		cout << "Yes \n";
	else
		cout << "No \n";
	return 0;
}

Measured memory_bytes: 256
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
// clang-format off
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {
  REP(i, v.size()) print(v[i]);
}
template <typename T> inline void print(const vector<T>& v, string s = " ") {
  REP(i, v.size()) {
    if (i != 0) cout << s;
    cout << v[i];
  }
  cout << '\n';
}
// clang-format on
/* }}} */

signed main() {
  int a = in(), b = in(), c = in();

  if (a == b + c || b == a + c || c == a + b) {
    print("Yes");
  } else {
    print("No");
  }

  return 0;
}


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

#define INF 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int num = a;
    rep(i, b) {
        if (num % b == c) {
            cout << "YES" << endl;
            return 0;
        }
        else num += a;
    }
    cout << "NO" << endl;
}

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

using namespace std;
 
#define rep(i, n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back


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

    vector<int> v;

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

    int min = *std::min_element(v.begin(), v.end());
    int max = *std::max_element(v.begin(), v.end());

    cout<<max-min<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <set>
#include <vector>
#include <array>
#include <cmath>
#include <queue>

#define r(i, v, n) for(int i = v; i < n; i++)
#define re(i, v, n) for(int i = v; i <= n; i++)
#define rr(e, v) for(auto&& (e) : (v))

using namespace std;
using ll = long long;
using ul = unsigned long;

typedef tuple<string, int, int> mtp;

bool compare(const mtp &lhs, const mtp &rhs) {
    if(get<0>(lhs) != get<0>(rhs)) return get<0>(lhs) < get<0>(rhs);
    if(get<1>(lhs) != get<1>(rhs)) return get<1>(lhs) > get<1>(rhs);
    return get<2>(lhs) < get<2>(rhs);
}

int main() {
    ios_base::sync_with_stdio(false);

    int n, p;
    string s;
    cin >> n;

    auto v = vector<mtp>(n);
    r(i, 0, n) {
        cin >> s >> p;
        v[i] = make_tuple(s, p, i + 1);
    }
    sort(v.begin(), v.end(), compare);

    r(i, 0, n){
        cout << get<2>(v[i]) << std::endl;
    }

    return 0;
}



Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto C = RD;
	auto K = RD;
	auto T = new long[](N);
	foreach (i; 0..N)
	{
		T[i] = RD;
	}
	T.sort();

	long u = T[0] + K;
	long cnt;
	long ans = 1;
	foreach (i; 0..N)
	{
		if (T[i] <= u && cnt < C)
		{
			++cnt;
		}
		else
		{
			u = T[i] + K;
			cnt = 1;
			++ans;
		}
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 3708
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  ll n;
  cin >> n;
  double a = 0;
  rep(i, n) {
    ll x;
    cin >> x;
    a += 1.0 / (double)x;
  }
  cout << setprecision(10) << fixed << 1.0 / a << endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
	int l;
	char s[102];
	while (cin >> s)
	{
		l = strlen(s);
		int flag = 0;
		for (int i=0; i<l; i++)
		{
			if (s[i] == 'C')
			{
				flag = 1;
			}
			if (s[i] == 'F' && flag == 1)
			{
				flag = 2;
				cout << "Yes" << endl;
				break;
			}
		}
		if (flag != 2) 
		{
			cout << "No" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [int(s) for s in input().split()]
A.sort()
MAX_VAL = A[-1]+1

duplicate = {}
for a in A:
    if a in duplicate:
        if duplicate[a]:
            continue
        else:
            duplicate[a] = True
            continue
    duplicate[a] = False

ng_map = {}
counter = 0
for a in A:
    if a in ng_map:
        continue
    if not(a in duplicate and duplicate[a]):
        counter += 1
    for i in range(a, MAX_VAL, a):
        ng_map[i] = True

print(counter)


Measured memory_bytes: 175212
#include <bits/stdc++.h>
using namespace std;
long long MOD=1e9+7;
long long p2[100005], p3[100005], pos[100005];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	p2[0]=p3[0]=1;
	for(int i=1;i<100005;i++){
		p2[i]=(p2[i-1]*2)%MOD;
		p3[i]=(p3[i-1]*3)%MOD;
	}
	string s;
	cin>>s;
	int n=s.size(), cnt=0;
	for(int i=0;i<n;i++){
		if(s[i]=='1') pos[cnt++]=i;
	}
	long long ans=0;
	for(int i=0;i<cnt;i++){
		ans=(ans+(p2[i]*p3[n-pos[i]-1]))%MOD;
	}
	ans=(ans+p2[cnt])%MOD;
	cout<<ans;
}

Measured memory_bytes: 2768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//ITP1_11-A

namespace ConsoleApplication24
{
    class Dice
    {
        string[] D;

        public Dice(string[] DArray)
        {
            D = DArray;
        }

        public string DiceRoll(string roll)
        {

            string D1 = "";
            string D2 = "";
            string D3 = "";
            string D4 = "";
            string D5 = "";
            string D6 = "";

            for (int i = 0; i < roll.Length; ++i)
            {
                switch (roll[i])
                {
                    case 'E':
                        D1 = D[3];
                        D2 = D[1];
                        D3 = D[0];
                        D4 = D[5];
                        D5 = D[4];
                        D6 = D[2];
                        break;

                    case 'N':
                        D1 = D[1];
                        D2 = D[5];
                        D3 = D[2];
                        D4 = D[3];
                        D5 = D[0];
                        D6 = D[4];
                        break;

                    case 'S':
                        D1 = D[4];
                        D2 = D[0];
                        D3 = D[2];
                        D4 = D[3];
                        D5 = D[5];
                        D6 = D[1];
                        break;

                    case 'W':
                        D1 = D[2];
                        D2 = D[1];
                        D3 = D[5];
                        D4 = D[0];
                        D5 = D[4];
                        D6 = D[3];
                        break;
                }
                D[0] = D1;
                D[1] = D2;
                D[2] = D3;
                D[3] = D4;
                D[4] = D5;
                D[5] = D6;
            }
            return D[0];
        }
    }


    class Program
    {
        static void Main()
        {
            string[] DiceArray = Console.ReadLine().Split(' ');
            string str = Console.ReadLine();

            Dice DClass = new Dice(DiceArray);

            string top = DClass.DiceRoll(str);

            Console.WriteLine(top);
        }
    }
}

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

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

  if (N == 0) {
    cout << 0 << endl;
    return 0;
  }
  
  string ans = "";
  while (N != 0) {
    if (N % 2 == 0) {
      ans = '0' + ans;
    } else {
      ans = '1' + ans;
      N--;
    }
    N /= -2;
  }

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

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	ll n; cin >> n;
	ll ret = 0;
	if (n%2==1) {
		cout << ret << endl;
		return 0;
	}
	n /= 2;
	while(n) {
		ret += n/5;
		n /= 5;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
an = list(map(int, input().split()))


count = 0
for a in an:
  if a >= sum(an) / (4.0 * m):
    count += 1

if count >= m:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    set<ll> st;
    rep(i,n) {
        cin >> a[i];
        st.insert(a[i]);
    }

    cout << (st.size() == n ? "YES" : "NO") << endl;

}

Measured memory_bytes: 11776
import sys
sys.setrecursionlimit(1000000)

n, m, x = list(map(int, input().split()))
lis = [list(map(int, input().split())) for i in range(n)]
ans = float('inf')
ima = [0]*m
def solve(i,ima,sum):
  newima=[0]*m
  #print("i: "+str(i))
  #print("ima")
  #print(ima)
  #print("sum: "+str(sum))
  global ans
  mini = float('inf')
  for j in range(m):
    if ima[j] <= mini:
      mini = ima[j]
  #print("mini "+str(mini))
  if mini >= x:
    if sum <= ans:
      ans = sum
      return
 
  if i == n:
    return
  for j in range(m):
    newima[j]=ima[j]+lis[i][j+1]
  solve(i+1, newima, sum+lis[i][0])
  solve(i+1, ima, sum)
  
solve(0, ima, 0)
if ans == float('inf'):
  ans = -1
print(ans)

Measured memory_bytes: 9268
var n,i,x,a,b:Longint;
cnt:array[0..9]of Longint;
begin
read(n);
for i:=1 to n do begin
read(x);
if x<3200 then begin
if cnt[x div 400]=0 then inc(a);
inc(cnt[x div 400]);
end else inc(b);
end;
if a=0 then writeln(1)else writeln(a);
writeln(a+b);
end.

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

typedef long long ll;

int M = 1000000007;

int main() {
	ios::sync_with_stdio(0);
	srand(time(NULL));
	
	int n;
	string s;
	cin >> n >> s;
	int w = 0, e = 0;
	for (int i = 0; i < n; i++) {
		w += (s[i] == 'W');
		e += (s[i] == 'E');
	}
	
	int ans = 10000000;
	int ww = 0, ee = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') {
			w--;
			ww++;
			ans = min(ans, e+ww-1);
		} else {
			e--;
			ee++;
			ans = min(ans, e+ww);
		}
	}
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 720