akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

int *x=NULL;
int *y=NULL;

int cmpX(const void *a,const void *b){
  return x[*(int *)a]-x[*(int *)b];
}

int cmpY(const void *a,const void *b){
  return y[*(int *)a]-y[*(int *)b];
}

typedef struct minedge{
  int v;
  int a,b;
} edge;

int cmpEdge(const void *a,const void *b){
  edge *p=(edge *)a;
  edge *q=(edge *)b;
  return p->v-q->v;
}

int root(int *u,int k){
  if(u[k]==k) return k;
  return u[k]=root(u,u[k]);
}

int same(int *u,int a,int b){
  return root(u,a)==root(u,b);
}

void unite(int *u,int a,int b){
  a=root(u,a);
  b=root(u,b);
  if(a==b) return;
  u[a]=b;
  return;
}

void run(void){
  int n;
  scanf("%d",&n);
  x=(int *)malloc(sizeof(int)*n);
  y=(int *)malloc(sizeof(int)*n);
  int *index=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++){
    scanf("%d%d",x+i,y+i);
    index[i]=i;
  }
  edge *e=(edge *)malloc(sizeof(edge)*2*(n-1));
  int len=0;
  qsort(index,n,sizeof(int),cmpX);
  for(i=0;i<n-1;i++){
    int a=index[i];
    int b=index[i+1];
    e[len].v=x[b]-x[a];
    e[len].a=a;
    e[len].b=b;
    len++;
  }
  qsort(index,n,sizeof(int),cmpY);
  for(i=0;i<n-1;i++){
    int a=index[i];
    int b=index[i+1];
    e[len].v=y[b]-y[a];
    e[len].a=a;
    e[len].b=b;
    len++;
  }
  qsort(e,len,sizeof(edge),cmpEdge);
  int *u=(int *)malloc(sizeof(int)*n);
  for(i=0;i<n;i++) u[i]=i;
  int64 sum=0;
  for(i=0;i<len;i++){
    int a=e[i].a;
    int b=e[i].b;
    if(same(u,a,b)) continue;
    sum+=e[i].v;
    unite(u,a,b);
  }
  printf("%lld\n",sum);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e10+10;

/*----------------------------------------------*/

signed main(){
  string s;
  int k;
  cin>>s>>k;
  int ans;
  int n=s.size();
  if(k==1){
    int check=1;
    rep(i,s.size()-1){
      if(s[i]==s[i+1]) check++;
      else{
        ans+=check/2;
        check=1;
      }
    }
  }else{
    int i=0;
    while(s[i]==s[i+1]&&i<s.size()-1) i++;
    if(i+1==s.size()){
      ans=s.size()*k/2;
    }else{
      ans=(i+1)/2;
      //
      int ams=0,check=1;
      FOR(j,i+1,i+1+n){
        if(s[j%n]==s[(j+1)%n]) check++;
        else{
          ams+=check/2;
          check=1;
        }
      }
      ans+=ams*(k-1);
      //
      check=1;      
      FOR(j,i+1,n-1){
        if(s[j]==s[j+1]) check++;
        else{
          ans+=check/2;
          check=1;
        }
      }

    }
  }

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

Measured memory_bytes: 256
#include<cstdio>

int main(){
    char s[1201];
    scanf("%[^\n]",s);
    for(int i = 0; s[i] != '\0'; i++){
        char c = s[i];
        if(c >= 'a' && c <= 'z'){
            s[i] = c - 32;
        }
        else if(c >= 'A' && c <= 'Z'){
            s[i] = c + 32;
        }
    }
    printf("%s\n",s);
    return 0;
}


Measured memory_bytes: 2620
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
string arr[1000000];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		char abc[11];
		cin>>abc;
		sort(abc,abc+strlen(abc));
		arr[i]=abc;
	}
	sort(arr,arr+n);
	ll sum=0;
	ll p=0;
	for(int i=0;i<n;i++){
		if(i!=n){
			if(arr[i]==arr[i+1]){
				p++;
			}
			else{
				p++;
				if(p!=1){
					sum+=p*(p-1)/2;
				}
				p=0;
			}
		}
		else{
			p++;
			if(p!=1){
				sum+=p*(p-1);
			}
		}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 12800
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, a, b, c, x;
    int f;
    int[] real;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    a = sc.nextInt();
	    b = sc.nextInt();
	    c = sc.nextInt();
	    x = sc.nextInt();
	    if(n==0 && a==0 && b==0 && c==0 && x==0) break;

	    real = new int[n];
	    for(int i=0; i<n; i++)
		real[i] = sc.nextInt();

	    f = 0;
	    int i=0;
	    while(true){
		if(f>10000) break;
		if(x==real[i]) i++;
		if(i==real.length) break;
		x = (a*x+b)%c;
		f++;
	    }

	    System.out.println(f>10000 ? "-1" : f);
	}
    }
}

Measured memory_bytes: 31876
import sys

def heaven():
    result_dic = {}
    check_num_lis = []
    for i in range(5):
        check_num = card_lis[0]
        if not check_num in check_num_lis:
            for card in card_lis[1:]:
                if card == check_num:
                    if not card in result_dic:
                        result_dic[card] = 2
                    else:
                        result_dic[card] = result_dic[card] + 1
            check_num_lis.append(check_num)
        card_lis.append(check_num)
        del card_lis[0]
    
    suicide(result_dic)
    
def suicide(result_dic):
    result = result_dic.values()
    result.sort()
    if result == [2]:
        print 'one pair'
    elif result == [2,2]:
        print 'two pair'
    elif result == [3]:
        print 'three card'
    elif result == [4]:
        print 'four card'
    elif result == [2,3]:
        print 'full house'
    elif not result:
        card_lis.sort()
        if card_lis == [1,10,11,12,13]:
            print 'straight'
        else:
            check_num = card_lis[0]
            for card in card_lis:
                if card == check_num:
                    check_num = card + 1
                else:
                    print 'null'
                    break
            else:
                print 'straight'

for input_line in sys.stdin:
    card_lis = [int(char) for char in input_line.split(',')]
    heaven()

Measured memory_bytes: 4264
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

// lcm ここから
// gcd ここから
// 最大公約数を返す
template <typename T>
T gcd(T a, T b) {
	if(a < b) {
		swap(a, b);
	}

	T r = a % b;
	while(r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}
// gcd ここまで

// 最小公倍数を返す
template <typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
// lcm ここまで

int div_num(int n) {
	int i;
	for(i = 0; !(n & 1); i++) {
		n >>= 1;
	}
	return i;
}

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	vector<ll> a(n);
	EACH(e, a) { scanf("%lld", &e); }
	int d = div_num(a[0]);
	EACH(e, a) {
		if(div_num(e) != d) {
			puts("0");
			return 0;
		}
	}
	ll l = accumulate(ALL(a), 1LL, lcm<ll>) / 2LL;
	ll result = (m / l + 1LL) / 2LL;
	printf("%lld\n", result);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
//#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    set<int> s;
    Forn(i, 9) Forn(j, 9) s.insert(i*j);
    int x;
    cin >> x;
    if(s.count(x)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll  n; cin>>n;
	ll ans = (n*(n+1))/2;
	cout<<ans - n;
	return 0;
}


Measured memory_bytes: 256
from itertools import combinations, permutations


n = int(input())
xy = [[int(i) for i in input().split()] for _ in range(n)]

edges = [[0] * n for _ in range(n)]
for i, j in combinations(range(n), 2):
    xi, yi = xy[i]
    xj, yj = xy[j]
    distance = ((xi - xj)**2 + (yi - yj)**2)**0.5
    edges[i][j] = edges[j][i] = distance

totals = []
for node in permutations(range(n)):
    total = 0
    for i in range(1, n):
        total += edges[node[i-1]][node[i]]
    totals.append(total)

print(sum(totals) / len(totals))

Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main(){
    int N;
    cin >> N;
    vll T(N);
    cin >> T;
    sort(T.begin(),T.end());
    if(N == 1){
        cout << T[0] << endl;
        return 0;
    }
    ll ans = T[0] * (T[1]/__gcd(T[0],T[1]));
    for(int i=2; i<N; i++){
        if(ans < T[i]){
            ans = ans * (T[i]/__gcd(ans,T[i]));
        }else{
            ans = T[i] * (ans/__gcd(ans,T[i]));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
 int N,K;
 cin >> N >> K;
 vector<int> p(N);
 for(int i =0; i<N; i++)
   cin >> p[i];
 sort(p.begin(),p.end());
 int ans = 0;
 
  for(int i = 0; i<K; i++){
    ans = ans + p[i];
  }
  cout << ans;

   
 return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <atcoder/all>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using namespace atcoder;

void _main() {
    int N, Q;
    cin >> N >> Q;
    dsu d(N);
    REP (i, Q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) d.merge(u, v);
        else cout << (d.same(u, v)) << endl;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int main() {
  int X, Y;
  cin >> X >> Y;
  bool A=false;
  for (int i=0; i<=X; i++){
    if (2*i+4*(X-i)==Y){
      A = true;
      break;
    }
  }
  if (A)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
import itertools,sys
def S(): return sys.stdin.readline().rstrip()
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
H,W = LI()
S = [S() for _ in range(H)]
ans = []
dhdw = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]
for h,w in itertools.product(range(H),range(W)):
    if S[h][w]=='#':
        ans.append('#')
        continue
    count = 0
    for dh,dw in dhdw:
        nh,nw = h+dh,w+dw
        if not(0<=nh<=H-1) or not (0<=nw<=W-1):
            continue
        if S[nh][nw]=='#':
            count += 1
    ans.append(count)
for i,x in enumerate(ans,1):
    print(x,sep='',end='')
    if i%W==0:
        print()

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

int main() {
  
  int N; cin >> N; int count = 0;
  
  for (int i = 0; i < N; i++) {
    
    int A; cin >> A;
    
    if (A % 2 == 0) count++;
    
  }
  
  int64_t ans = int64_t(pow(3, N)) - int64_t(pow(2, count));
  
  cout << ans << endl;
  
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().strip()

def main():
    N,M = map(int,input().split())
    A_list = sorted(list(map(int,input().split())),reverse=True)
    print("Yes" if A_list[M-1]>=sum(A_list)*(1/(4*M)) else "No")

main()


Measured memory_bytes: 2940
import java.util.*;
public class Main {
	public static void main(String args[]) {
      Scanner scan = new Scanner(System.in);
      int row = scan.nextInt();
      int col = scan.nextInt();
      int[][] matrix = new int[row][col];
      int[][]  pathCount = new int[row][col];
      for(int i=0; i<row; i++) {
    	char[] input = scan.next().toCharArray();
        for(int j=0; j<col; j++) {
          if(input[j]=='.') {
            matrix[i][j]=0;
          }else{
            matrix[i][j]=1;
          }
        }
      }
      for(int i=0; i<col; i++) {
        if(matrix[0][i]==0) {
          pathCount[0][i]=1;
        }else {
        	break;
        }
      }
      for(int i=0; i<row; i++) {
        if(matrix[i][0]==0) {
          pathCount[i][0]=1;
        }else {
        	break;
        }
      }
      int n = 1000000007;
      for(int i=1; i<row; i++) {
        for(int j=1; j<col; j++) {
          if(matrix[i][j]==1) 
          continue;
          pathCount[i][j]=(pathCount[i-1][j]+pathCount[i][j-1])%n;;
        }
      }
      System.out.println(pathCount[row-1][col-1]);
      scan.close();
    }
}

Measured memory_bytes: 40340
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    long long dp[n + 1][n + 1];
    for (int i = 1; i <= n; i ++) {
        cin >> dp[i][i];
        dp[i][i - 1] = dp[i - 1][i] = dp[i - 1][i - 1] + dp[i][i];
        for (int j = i - 2; j > 0; j --) {
            dp[i][j] = -1;
            dp[j][i] = -1;
            for (int k = i; k > j; k --) {
                long long sum = dp[i][k] + dp[k - 1][j];
                if (dp[i][j] == -1 || dp[i][j] > sum) {
                    dp[i][j] = sum;
                }
                sum = dp[k][i] + dp[i][k] * (i != k) +
                        dp[j][k - 1] + dp[k - 1][j] * (j != k - 1);
                if (dp[j][i] == -1 || dp[j][i] > sum) {
                    dp[j][i] = sum;
                }
            }
        }
    }
    cout << dp[1][n];
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
vector<int> linear_sieve(const int UPBD) {
  vector<int> primes, last_prime(UPBD, 0);
  for (int p = 2; p < UPBD; ++p) {
    if (not last_prime[p]) primes.push_back(p), last_prime[p] = p;
    for (int j = 0; primes[j] * p < UPBD; ++j) {
      last_prime[primes[j] * p] = primes[j];
      if (p % primes[j] == 0) break;
    }
  }
  return last_prime;
}
template<typename T> vector<T> make_mobius(T limit) {
  auto last_prime = linear_sieve(limit);
  vector<T> mobius(limit, 1);
  mobius[0] = 0;
  for (T p = 2; p < limit; ++p) {
    if (last_prime[p] == last_prime[p / last_prime[p]]) mobius[p] = 0;
    else mobius[p] = mobius[p / last_prime[p]] * -1;
  }
  return mobius;
}


template <int mod>
struct ModInt {
  int val;
  int trim(int x) const { return x >= mod ? x - mod : x < 0 ? x + mod : x; }
  ModInt(int v = 0) : val(trim(v % mod)) {}
  ModInt(long long v) : val(trim(v % mod)) {}
  ModInt &operator=(int v) { return val = trim(v % mod), *this; }
  ModInt &operator=(const ModInt &oth) { return val = oth.val, *this; }
  ModInt operator+(const ModInt &oth) const { return trim(val + oth.val); }
  ModInt operator-(const ModInt &oth) const { return trim(val - oth.val); }
  ModInt operator*(const ModInt &oth) const { return 1LL * val * oth.val % mod; }
  ModInt operator/(const ModInt &oth) const {
    function<int(int, int, int, int)> modinv = [&](int a, int b, int x, int y) {
      if (b == 0) return trim(x);
      return modinv(b, a - a / b * b, y, x - a / b * y);
    };
    return *this * modinv(oth.val, mod, 1, 0);
  }
  bool operator==(const ModInt &oth) const { return val == oth.val; }
  ModInt operator-() const { return trim(mod - val); }
  template<typename T> ModInt pow(T pw) {
    bool sgn = false;
    if (pw < 0) pw = -pw, sgn = true;
    ModInt ans = 1;
    for (ModInt cur = val; pw; pw >>= 1, cur = cur * cur) {
      if (pw&1) ans = ans * cur;
    }
    return sgn ? ModInt{1} / ans : ans;
  }
};

using mint = ModInt<998244353>;

mint sum[1<<20];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  mint ans = 0;
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    sum[a] = sum[a] + a;
    ans = ans - mint(a);
  }
  for (int i = 1; i < (1<<20); ++i) {
    for (int j = i + i; j < (1<<20); j += i) {
      sum[i] = sum[i] + sum[j];
    }
    sum[i] = sum[i] * sum[i];
  }
  auto mu = make_mobius(1<<20);
  for (int i = 1; i < (1<<20); ++i) {
    mint cur = 0;
    for (int j = 1; j * i < (1<<20); ++j) {
      cur = cur + sum[i * j] * mu[j];
    }
    ans = ans + cur / i;
  }
  cout << (ans / 2).val << '\n';
}


Measured memory_bytes: 12724
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define ub upper_bound
#define lb lower_bound
#define clr(x) memset(x,0,sizeof(x))
#define sws ios::sync_with_stdio(false); cin.tie(0)
#define pi acos(-1)
#define rep(I, N) for (ll I = 0; I < (N); ++I)
#define repp(I, A, B) for (ll I = (A); I <= (B); ++I)
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
const ll N = 2e5 + 5 ;
int main()
{
    sws;
    //clock_t clk;
    //clk = clock();
    //freopen("A.in", "r", stdin); 
    //freopen("A.out", "w", stdout);

    int n, ans = 0;
    cin >> n;
    int a[n + 1];
    repp(i,1,n) cin >> a[i];
    for(int i = 1; i < n;)
    {
        if(a[i] == i)
        {
            ans++;
            swap(a[i],a[i + 1]);
            i += 2;
        }
        else i++;
    }
    if(a[n] == n) ans++;
    cout << ans;

    //clk = clock() - clk;
    //cout << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}


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

using namespace std;
int a(int x,int y){
  return x>y;
}
int main(){
  int list[10];
  for(int i=0;i<10;i++){
    cin >> list[i];
  } 
sort(list,list+10,a);
  
  for(int j=0;j<3;j++){
    cout<< list[j] << endl;
  }
  return 0;
}  

Measured memory_bytes: 1180
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
#define INF 1e10
using namespace std;

int n;
int a[22];
double dp[200001][21];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<=200000;i++){
		dp[i][0]=0;
		for(int j=1;j<=n;j++){
			dp[i][j]=INF;
		}
	}
	for(int i=1;i<=200000;i++){
		for(int j=0;j<n;j++){
			double cost=(double)abs(a[j]-i)/a[j];
			for(int k=1;i*k<=200000;k++){
				dp[i*k][j+1]=min(dp[i*k][j+1],dp[i][j]);
				dp[i*k][j+1]=min(dp[i*k][j+1],dp[i][j]);
			}
			dp[i][j+1]=max(dp[i][j+1],cost);
		}
	}
	double res=INF;
	for(int i=1;i<=200000;i++){
		res=min(res,dp[i][n]);
	}
	printf("%.10f\n",res);
	return 0;
}

Measured memory_bytes: 33880
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define lint long long
using namespace std;lint q,x,y,f[99]={0,1},m=1000000007;main(){cin>>q;rep(i,97)f[i+2]=f[i]+f[i+1];rep(i,q){cin>>x>>y;if(x>y)swap(x,y);if(y<=2){cout<<1<<" "<<(y==1?1:x==1?2:4)<<" ";continue;}rep(j,99){if(x<f[j]||y<f[j+1]){lint a=x==1?2:1;rep(k,j-2){lint n=f[j-1]+f[j-3-k]*f[k+2],m=f[j]+f[j-2-k]*f[k+2];if(n<=x&&m<=y)a+=(y-m)/n+1;}if(f[j]<=x){a++;rep(k,j-2)a+=(x-f[j])/(f[j-2-k]*f[k+2]);}cout<<j-2<<" "<<a%m<<" ";break;}}}}

Measured memory_bytes: 4364
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>

using namespace std;

const double SMALL_NUM = 1e-9;

int main()
{
  int A, B;

  cin >> A >> B;

  if (B / 0.1 - SMALL_NUM < ceil(A / 0.08) and ceil(A / 0.08) < (B + 0.9) / 0.1 + SMALL_NUM) {
    cout << ceil(A / 0.08) << endl;
    return 0;
  }

  if (A / 0.08 - SMALL_NUM < ceil(B / 0.1) and ceil(B / 0.1) < (A + 0.9) / 0.08 + SMALL_NUM) {
    cout << ceil(B / 0.1) << endl;
    return 0;
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define N 100005
#define MXN 2000005
const int mod=1e6+3;
int main(){
    int n;
    scanf("%d",&n);
    LL sum=0;
    for(int i = 0;i<n;i++){
        int x;
        scanf("%d",&x);
        sum+=x;
        //scanf("%d",&d[i]);
    }
    printf("%lld\n",sum);

    return 0;
}


Measured memory_bytes: 3224
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};

intl pow(intl a,intl n){
  intl ans=1;
  Rep(i,n) ans *=a;
  return ans;
}

int main(){
  int K;
  string S;
  cin >> K;
    cin>>S;
  if( int(S.size()) <= K){cout<<S;return 0;}
  else{
    Rep(i,K){
      cout<<S.at(i);
    }
  }
  cout<<"...";
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

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


int solve()
{
    ll N;

    cin >> N;

    int counter = 0;

    for (int i = 1; i <= N; ++i)
    {
        ll num;

        cin >> num;

        if (i != num)
            ++counter;
    }

    if (counter == 0 || counter == 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

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

using namespace std;

int get_rank(long long n) {
    int rank = 1;
    while (n >= 2) {
        n /= 2;
        rank++;
    }
    return rank;
}

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

    int rank_k = get_rank(K);
    vector<int> rank_counts(rank_k);

    vector<long long> A(N);
    for (auto& a : A) {
        cin >> a;
        long long b = a;
        for (int j = 0; j < rank_k; j++) {
            if (b % 2 == 0) {
                rank_counts.at(j)++;
            }
            b /= 2;
        }
    }
    long long x = 0;
    for (int i = rank_k - 1; i >= 0; i--) {
        long long y = 1LL << i;
        if (rank_counts.at(i) > N / 2 and x + y <= K) {
            x += y;
        }
    }
    long long ans = 0;
    for (auto a : A) {
        ans += x ^ a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){
  int A, B;
  cin >> A >> B;
  if(A >= 13){
    cout << B;
  } else if (A <= 5){
    cout << 0;
  } else {
    cout << B / 2;
  }
}


Measured memory_bytes: 256
import math
def f(x):return math.factorial(x)
n,m=map(int,input().split())
b=0
c={}
for a in input().split():
  b+=int(a)
  c[b%m]=c.get(b%m,0)+1
print(sum(map(lambda x:f(x)//(f(x-2)*f(2))if x>1else 0,c.values()))+c.get(0,0))

Measured memory_bytes: 16100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int s = sc.nextInt();

		if(s <= 2){
			System.out.println(0);
			return;
		}

		long result = 0;
		int mod = 1_000_000_007;
		long dp[] = new long[s + 1];
//		dp[0] = dp[1] = dp[2] = 1;
		for(int i = 3; i <= s; i++){
			dp[i] = 1;
			for(int j = 0; j <= i - 3; j++){
				dp[i] += dp[j];
				dp[i] %= mod;
			}
//			System.out.println("i = "+i+" "+dp[i]);
		}

		System.out.println(dp[s]);
	}
}



Measured memory_bytes: 27252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) cin >> v[i];
	sort(v.begin(), v.end());
	double value = (v[0] + v[1]) * 1.0 / 2;
	for (int i = 2; i < N; i++) {
		value = (value + v[i]) / 2;
	}
	cout << fixed << setprecision(5) << value << endl;
	return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<int> A(N);
    for (int &a: A)
        cin>>a;

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    long long ans = 0;
    multiset<tuple<int, int, int>> S;
    for (int a: A)
    {
        if (S.empty())
            S.insert(make_tuple(-a, a, a));
        else
        {
            int w = -get<0>(*S.begin());
            int x = get<1>(*S.begin());
            int y = get<2>(*S.begin());
            S.erase(S.begin());
            ans += w;
            S.insert(make_tuple(-min(x, a), x, a));
            S.insert(make_tuple(-min(y, a), y, a));
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 12832
while True:
  a,b = map(int,input().split())
  if a == 0 and b == 0:
    break
  n = int(input())
  dp = [[0 for i in range(b)] for j in range(a)]
  for i in range(n):
    i,j = map(int,input().split())
    dp[i - 1][j - 1] = -1

  for i in range(a):
    if dp[i][0] == -1:
      break
    else:
      dp[i][0] = 1
  for i in range(b):
    if dp[0][i] == -1:
      break
    else:
      dp[0][i] = 1
  for i in range(1,a):
    for j in range(1,b):
      if dp[i][j] >= 0:
        dp[i][j] = max(dp[i - 1][j] + dp[i][j - 1],dp[i - 1][j],dp[i][j - 1])
  if (dp[a - 1][b - 1] <= 0):
    print(0)
  else: print(dp[a - 1][b - 1])


Measured memory_bytes: 5612
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
x = int(raw_input())

cnt = 0
for i in range(a + 1):
    ai = i * 500
    if x < ai:
        continue
    for j in range(b + 1):
        bj = j * 100
        if x < bj:
            continue
        for k in range(c + 1):
            ck = k * 50
            if x < ck:
                continue
            total = sum([ai, bj, ck])
            if total == x:
                cnt += 1
print cnt

Measured memory_bytes: 2568
n,m=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]

a_ruiseki_wa=[0]
for i in range(n):
    a_ruiseki_wa.append((a_ruiseki_wa[i]+a[i])%m)

from collections import defaultdict
d=defaultdict(int)
for key  in a_ruiseki_wa:
    d[key]+=1

print(sum([x*(x-1)//2 for x in d.values()]))

Measured memory_bytes: 63768
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

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

  if (a < 10 && b < 10) {
    cout << a * b << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()

a = LIST()
C = Counter(a)
A = sorted(set(a))


if len(A) == 1 and A[0] == 0:
	print("Yes")
elif N%3 == 0:
	if len(A) == 3 and A[0]^A[1] == A[2] and len(set(C.values())) == 1:
		print("Yes")
	elif len(A) == 2 and A[0] == 0 and C[0] == N//3:
		print("Yes")
	else:
		print("No")

else:
	print("No")
	


Measured memory_bytes: 21924
"use strict";
const main = arg => {
  let word = arg.trim().split("").reverse().join('');
  let dream = "dream".split("").reverse().join('');
  let dreamer = "dreamer".split("").reverse().join('');
  let erase = "erase".split("").reverse().join('');
  let eraser = "eraser".split("").reverse().join('');
  let judge = "YES";
  let isNeedLoop = true;
  while(isNeedLoop){
    if(word.startsWith(dream) ){
      word = word.slice(5);
    } else if(word.startsWith(dreamer)){
      word = word.slice(7);
    } else if(word.startsWith(erase)){
      word = word.slice(5);  
    } else if(word.startsWith(eraser)){
      word = word.slice(6);
    } else if(word == ""){
      	isNeedLoop = false;
    } else {
      	judge = "NO"
		isNeedLoop = false;
    }
  }
  console.log(judge);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 9368
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	int n,a[3];

	cin >> n;

	for (int j = 0; j < n; j++)
	{
		for (int i = 0; i < 3; i++)
		{
			cin >> a[i];
		}

		sort (a,a + 3);

		if ((a[0] * a[0]) + (a[1] * a[1]) == (a[2] * a[2]))
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
		a[0] = 0;
		a[1] = 0;
		a[2] = 0;
	}
}




Measured memory_bytes: 3108
#include<iostream>
#include<string>
#include<cmath>
//#include<array>
#include<algorithm>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>

using namespace std;
using LLI = long long int;
LLI N;

//vector<int>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//vector<int>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//vector<int>dir_x2 = { 0,0,1,-1 };
//vector<int>dir_y2 = { 1,-1,0,0 };
//vector<char>alp = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI tmp, r;
//	if (x < y) {
//		tmp = x;
//		x = y;
//		y = tmp;
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x,LLI y) {
//	return x / gcd(x,y) * y;
//}

//long nCr(int n,int r) {
//	long ans = 1;
//	for (int i = n; i > n - r;i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1;i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

int main(void) {
	LLI Q,a,b,res = 0;
	cin >> N >> Q;
	vector<LLI>sum(N);
	vector<LLI>vec;
	string S;
	cin >> S;
	for (int i = 0; i < N - 1;i++) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			sum[i + 1] = sum[i] + 1;
		}
		else {
			sum[i + 1] = sum[i];
		}
	}
	for (int i = 0; i < Q;i++) {
		cin >> a >> b;
		vec.push_back(sum[b - 1] - sum[a - 1]);
	}
	for (int i = 0; i < Q;i++) {
		cout << vec[i] << endl;
	}
}

Measured memory_bytes: 2676
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<ctime>
#include<set>
#include<queue>
#include<map>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);++(i))
#define fd1(i,n) for ((i)=(n);(i)>=1;--(i))
#define fz0g(i,n) for ((i)=0;(i)<=(n);++(i))
#define fd0g(i,n) for ((i)=(n);(i)>=0;--(i))
#define fz0k(i,n) for ((i)=0;(i)<(n);++(i))
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;--(i))
#define fz(i,x,y) for ((i)=(x);(i)<=(y);++(i))
#define fd(i,y,x) for ((i)=(y);(i)>=(x);--(i))
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
using namespace std;
int n,m,i,j,dis[200005];
vector<int> bi[200005];
map<int,int> s[200005];
void add(int x,int y)
{
	bi[x].push_back(y);
	bi[y].push_back(x);
}
bool dfs(int x,int fa)
{
	s[x][(x>n?x-1:x)]=x;
	ff(bi[x],it)
	{
		if(*it==fa)continue;
		if(dfs(*it,x))return 0;
		if(s[x].size()<s[*it].size())
		{
			swap(s[x],s[*it]);
		}
		ff(s[*it],it2)
		{
			if(s[x].count(n^it2->first))
			{
				add(n,it2->second);
				add(n+n,s[x][n^it2->first]);
				return 1;
			}
		}
		ff(s[*it],it2)
		{
			s[x][it2->first^(x>n?x-1:x)]=it2->second;
		}
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	int m=1;
	while(m+m<=n)m=m+m;
	if(n==m)
	{
		puts("No");
		return 0;
	}
	add(1,2);
	add(2,3);
	add(3,n+1);
	add(n+1,n+2);
	add(n+2,n+3);
	for(i=4;i+1<=n;i+=2)
	{
		add(i,i+1);
		add(i+1,1);
		add(1,i+n);
		add(i+n,i+n+1);
	}
	if(n%2==0)
	{
		add(n,n-1);
		add(n+(n^1^(n-1)),n+n);
	}
	puts("Yes");
	fz1(i,n+n)
	{
		ff(bi[i],it)
		{
			if(*it>i)
			{
				printf("%d %d\n",i,*it);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 23288
#include <iostream>
#include <numeric>

inline int read(){
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

int cnt[1000001];

int main(){
  int n = read(), num = read(), g = num, ex = (n-1)/8;
  cnt[num] = 1;

  for(int i=0;i<ex;i++){
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    if(i-cnt[1]>80000){
      if(g==1) printf("setwise coprime\n");
      else printf("not coprime\n");
      return 0;
    }
  }

  for(int i=0;i<(n-1)%8;i++){
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
  }

  if(n - cnt[1] > 80000){
    if(g==1) printf("setwise coprime\n");
    else printf("not coprime\n");
    return 0;
  }

  if(g!=1){
    printf("not coprime\n");
    return 0;
  }

  int use[1000001];
  int max_S = 0;
  for(int i=2;i<=1000000;i++){
    if(use[i]==-1) continue;
    int S = 0;
    for(int j=i;j<=1000000;j+=i) {
      S += cnt[j];
      use[j] = -1;
    }
    if(max_S<S) max_S = S;
  }
  if(max_S<2) printf("pairwise coprime\n");
  else printf("setwise coprime\n");
}


Measured memory_bytes: 11436
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void pk()
{
    ll n;
    cin>>n;
    ll cn=0;
    ll a,b;
    ll f=0;
    while(n--)
    {
        cin>>a>>b;
        if(a==b)
           cn++;
        else cn=0;
        if(cn>=3)
        {
            f=1;
        }
    }
    if(f==1)
       cout<<"Yes";
    else cout<<"No";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //a #ifndef ONLINE_JUDGE 
    // freopen("/home/priyanshu/Hackercup/input.txt", "r", stdin); 
    // freopen("/home/priyanshu/Hackercup/output.txt", "w", stdout); 
    // #endif 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        pk();
    }
} 

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

signed main(){

    int N, M; cin >> N >> M;
    string S; cin >> S;
    vec l(M), r(M);
    REP(i, M){
        cin >> l[i] >> r[i];
        l[i]--; r[i]--; 
    }
    l.push_back(N);
    r.push_back(N);

    vec n1(N + 1, 0);
    REP(i, N){
        n1[i + 1] = n1[i];
        if(S[i] == '1') n1[i + 1]++;
    }

    vec rmax(N);
    REP(i, N) rmax[i] = i;
    int r0 = -1;
    REP(i, M){
        r0 = max(r0, r[i]);
        FOR(j, l[i], min(l[i + 1], r0 + 1)) rmax[j] = r0;
    }

    int mod = 1000000007;

    mat dp(N + 1, vec(N + 1, 0));
    dp[0][0] = 1;
    REP(i, N){
        int t = n1[rmax[i] + 1];
        int u = max(t - (rmax[i] - i), 0LL);
        FOR(j, u, t + 1){
            if(j == 0) dp[i + 1][0] = dp[i][0];
            else dp[i + 1][j] = (dp[i][j - 1] + dp[i][j]) % mod;
        }
    }
    //debug(dp);
    
    cout << dp[N][n1[N]] << endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;


int main() {
    int a,b,k;cin >> a >> b >> k;
    for(int i=a;i<=b;i++){
        if(i<=a+k-1){
            cout << i << endl;
        }
        else if(i>=b-k+1){
            cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
P1 = list(map(int, input().split()))
P2 = list(map(int, input().split()))
a = [4,6,9,11]
if P1[0] != 2 and P2[0] == P1[0]+1:
  if P1[0] in a and P1[1]==30 and P2[1]==1:
    print(1)
  if P1[0] not in a and P1[1]==31 and P2[1]==1:
    print(1)
else:
 if P1[0] ==2 and P1[1]==28 and P2[0] == 3 and P2[1]==1:
    print(1)
 else :
    print(0)
    

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10 ** 9)

n, u, v = map(int, input().split())
u -= 1
v -= 1
ab = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    ab[a - 1].append(b - 1)
    ab[b - 1].append(a - 1)

def dfs1(pos, before_pos):
    for next_pos in ab[pos]:
        if next_pos == before_pos:
            continue
        if next_pos == u:
            return True, [pos]
        tf, root = dfs1(next_pos, pos)
        if tf:
            root.append(pos)
            return True, root
    return False, []
    
root = dfs1(v, -1)[1]
root = root[::-1]
root.append(u)
n = (len(root) + 1) // 2
pos = root[n]
before_pos = root[n - 1]

max_len = n

def dfs2(pos, before_pos, cnt):
    global max_len
    cnt += 1
    max_len = max(max_len, cnt)
    if cnt < n - 1:
        dfs2(root[cnt + 1], pos, cnt)
    else:
        for next_pos in ab[pos]:
            if next_pos == before_pos:
                continue
            dfs2(next_pos, pos, cnt)


dfs2(pos, before_pos, n - 1)
ans = max_len - 1
ans = max(ans, 0)
print(ans)


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<long long,long long> ii;
vector<pair<long long,ii>> edge;
long long n,up[100005],sz[100005];
pair<ii,long long> x[100005];

bool cmp(const pair<ii,long long> &a,const pair<ii,long long> &b){
    return a.fi.fi<b.fi.fi;
}
bool cmp1(const pair<ii,long long> &a,const pair<ii,long long> &b){
    return a.fi.se<b.fi.se;
}
int findSet(int x){
    if(x==up[x]) return x;
    else return findSet(up[x]);
}
void unionSet(int x,int y){
    long long x1=findSet(x),y1=findSet(y);
    if(sz[x1]<sz[y1]) swap(x1,y1);
    up[y1]=x1;
    sz[x1]+=sz[y1];
}
bool checkSet(int x,int y){
    long long x1=findSet(x),x2=findSet(y);
    if(x1==x2)
        return 1;
    else
        return 0;
}
int main(){
    cin.tie(0),cout.tie(0),ios::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x[i].fi.fi>>x[i].fi.se;
        x[i].se=i;
    }
    sort(x+1,x+1+n,cmp);
    for(int i=1;i<=n;i++){
        up[i]=i;
        sz[i]=1;
    }
    for(int i=1;i<n;i++){
        long long x1=x[i].se,x2=x[i+1].se;
        long long val=abs(x[i].fi.fi-x[i+1].fi.fi),val1=abs(x[i].fi.se-x[i+1].fi.se);
        edge.pb(mp(min(val,val1),mp(x1,x2)));
    }
    sort(x+1,x+1+n,cmp1);
    for(int i=1;i<n;i++){
        long long x1=x[i].se,x2=x[i+1].se;
        long long val=abs(x[i].fi.fi-x[i+1].fi.fi),val1=abs(x[i].fi.se-x[i+1].fi.se);
        edge.pb(mp(min(val,val1),mp(x1,x2)));
    }
    long long sum=0;
    sort(edge.begin(),edge.end());
    for(int i=0;i<edge.size();i++){
        long long x1=edge[i].se.fi,x2=edge[i].se.se;
        if(checkSet(x1,x2)==0){
            unionSet(x1,x2);
            sum+=edge[i].fi;
        }
    }
    cout<<sum;
}


Measured memory_bytes: 12400
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(N==1) {
			System.out.println("Hello World");
		}else {
			int A = sc.nextInt(), B = sc.nextInt();
			System.out.println(A+B);
		}
		sc.close();
	}

}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(){
    int num1,num2;
    char type;
    cin >> num1 >> type >> num2;
    while(type!='?'){
            if(type=='+'){
            cout << num1+num2 << endl;
        }
        else if(type=='-'){
            cout << num1-num2 << endl;
        }
        else if(type=='*'){
            cout << num1*num2 << endl;
        }
        else if(type=='/'){
            cout << num1/num2 << endl;
        }
        cin >> num1 >> type >> num2;
    }
    return 0;
}


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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 1000000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll n, m; cin >> n >> m;
    ll v[n], tot = 0, aux = 0;
    for (int i = 0; i < n; ++i){
        cin >> v[i];
        tot+=v[i];
    }
    for (int i = 0; i < n; ++i){
        if(v[i]*4*m >= tot) aux++;
    }
    if( aux>=m) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 3556
N,X,Y = map(int,(input().split()))
lList = [ 0 for i in range(N) ]
for i in range(N):
  for j in range(i + 1,N):
    l1 = j - i
    l2 = abs(X - 1 - i) + abs(Y - 1 - j)  + 1
    l = min(l1,l2)
    lList[l] += 1
    
for i in lList[1:]:
  print(i)

Measured memory_bytes: 3444
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split()))) - np.array(list(range(1, N+1)))
A = A.astype(np.int64)
m = np.median(A)
m = m.astype(np.int64)
A -= m
ans = sum(np.abs(A))
print(ans.astype(np.int64))

Measured memory_bytes: 49324