akhauriyash/Code-Regression huggingface dataset:
// at_abc142d.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<map>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
bool isPrime(ll x) {
    for (int i = 2;i <= sqrt(x);i++) {
        if (x % i == 0 & x != i) {
            return false;
        }
    }
    return true;
}
ll gcd(ll a, ll b) {
    if (a == 0)return b;
    gcd(b % a, a);
}
int main()
{
    ll a, b;cin >> a >> b;
    ll n = gcd(a, b);
    map<ll, ll>mp;
    ll Count = 0;
    for (ll i = 2; (ll)i * i <= (ll)n; i++) {

        if (n % i == 0) {
            while (n % i == 0) {
                n /= i;
               // cout << i << "\n";
                mp[i]++;
            }
            Count++;
        }
    }
    if (n != 1) {
        Count++;
    }
    cout << Count+1 << "\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


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

Measured memory_bytes: 1280
/* 
    AtCoder Beginner Contest 102
    B:Maximum Difference
    AC
*/

#include <iostream>
#include <stdlib.h>
// #include <string>
using namespace std;

int main(void)
{
    int i, j;
    int temp;
    int max = 0;
    int length;
    cin >> length;
    int num[length];
    for (i = 0; i < length; i++)
    {
        cin >> num[i];
    }
    for (i = 0; i < length; i++)
    {
        for (j = i; j < length; j++)
        {
            temp = abs(num[i] - num[j]);
            if(temp > max){
                max = temp;
            }
        }
    }
    cout << max << endl;
}

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

int main() {

  std::string str;
  int n;
  int sum;
  int temp;
  

  for(;;) {
    std::cin >> str;
    if( str == "-" ) break;
    std::cin >> n;
    sum = 0;
    for(int i = 0; i < n; ++i) {
      std::cin >> temp;
      sum += temp;
    }
    for(int i = 0; i < str.size(); ++i) {
      std::cout << str[(i+sum)%str.size()];
    }
    std::cout << std::endl;
  }

  
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <double, double>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "No"; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

int used[3][3], f[3][3];

void solve() {
    loop(i, 3)
        loop(j, 3)
            cin >> f[i][j];
    int n; cin >> n;
    loop(c, n) {
        int x; cin >> x;
        loop(i, 3)
            loop(j, 3)
                if (f[i][j] == x)
                    used[i][j] = 1;
    }
    if (used[0][0] && used[1][1] && used[2][2])
        yes;
    if (used[0][2] && used[1][1] && used[2][0])
        yes;
    loop(i, 3) {
        bool ok1 = 1, ok2 = 1;
        loop(j, 3) {
            if (!used[i][j])
                ok1 = 0;
            if (!used[j][i])
                ok2 = 0;
        }
        if (ok1 || ok2)
            yes;
    }
    no;
}

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


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

//ABC 081 C-1
int cmp(int a,int b){
	return a>b;
}
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1; i<=n; i++){
		a[i]=0;
	}
	for(int i=1; i<=n; i++){
		int t;
		cin>>t;
		a[t]++;
	}
	sort(a+1,a+n+1,cmp);
	int x=0;
	for(int i=k+1; i<=n; i++){
		x+=a[i];
	}
	cout<<x<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int x, a, b;
	scanf("%d %d %d", &x, &a, &b);
	int a1 = x- a;
	int b1 = x -b ;
	if(a1 < 0){
		a1 *= -1;
	}
	if(b1 < 0){
		b1 *= -1;
	}
	if(a1 < b1){
		printf("A");
	}else{
		printf("B");
	}
	
	return 0;
}

Measured memory_bytes: 1664
import Data.Functor ((<$>))
import Numeric (showFFloat)

main = do
  [a, b] <- map read . words <$> getLine
  let typer = a :: Int
      d = a `div` b
      r = a `mod` b
      f = realToFrac a / realToFrac b :: Double
  putStrLn $ unwords $ map show [d, r] ++ [showFFloat Nothing f $ ""]



Measured memory_bytes: 3920
import sys

def diff(N,A,B,C,D):
    mini = (B+(N-1)*D-A)/(C+D)
    for i in range(int(mini), N-1):
        lower_bound = A + i*C - (N-i-1)*D
        upper_bound = A + i*D - (N-i-1)*C
        #print(lower_bound, upper_bound)
        if lower_bound <= B and B <= upper_bound:
            return True
        elif B < lower_bound:
            return False

str = sys.stdin.readline().strip() #"491995 412925347 825318103 59999126 59999339"
N,A,B,C,D = map(int,str.strip().split(" "))
print("YES" if diff(N,A,B,C,D) else "NO")

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <cctype>
#include<cstdio>
//#include <string>
using namespace std;
int main(){
    char ch;
    while(1){
        
        
        scanf("%c",&ch);
        
        if(isalpha(ch)){
            if(islower(ch)){char c=(char)toupper(ch);cout<<c;}//printf("%c",toupper(ch));
            else printf("%c",tolower(ch));
        }else printf("%c",ch);
        if(ch == '\n')break;
        
        
        
    }
    return 0;
}



Measured memory_bytes: 3156
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

X = []
for a,b in zip(A,A[1:]):
    X.append(a ^ b)
X.append(A[-1] ^ A[0])

Y = []
for a,b in zip(B,B[1:]):
    Y.append(a ^ b)
Y.append(B[-1] ^ B[0])

def z_algorithm(s):
    N = len(s)
    ret = [0]*N
    ret[0] = N
    i,j = 1,0
    while i < N:
        while i+j < N and s[j] == s[i+j]:
            j += 1
        ret[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < N and k + ret[k]<j:
            ret[i+k] = ret[k]
            k += 1
        i += k
        j -= k
    return ret

za = z_algorithm(X + [-1] + Y + Y)
for i in range(N):
    if za[-N-i] == N:
        print(i, A[i]^B[0])

Measured memory_bytes: 53780
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
int mod;
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
void solve() {
	int x, n;
	int ans = 0, tar = 1000000000;
	cin >> x >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	map<int, int> ma;
	for (int i = 0; i < n; i++) {
		ma[a[i]] = 1;
	}
	for (int i = -200; i <= 200; i++) {
		if (ma[i]==0 && abs(i - x) < tar) {
			tar = abs(i - x);
			ans = i;
		}
	}
	cout << ans << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 3672
import java.util.*;
public class Main {
	static List<Integer> sengetu = new ArrayList<Integer>();
	static List<Integer> result = new ArrayList<Integer>();
	static boolean hantei(int n){
		for(int i=0;i<sengetu.size();i++)if(n==sengetu.get(i))return true;
		return false;
	}
	static boolean hantei2(int n){
		for(int i=0;i<result.size();i++)if(n==result.get(i))return true;
		return false;
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		boolean sw=false;
		Map<Integer,Integer> m = new HashMap<Integer,Integer>();//数をカウント
		while(in.hasNext()){
			String input = in.nextLine();
			if(input.length()==0){
				sw=true;
				continue;
			}
			String data[] = input.split(",");
			int ban=Integer.parseInt(data[0]);
			int num=Integer.parseInt(data[1]);
			if(m.containsKey(ban)){
				m.put(ban,m.get(ban)+1);
			}else m.put(ban,1);
			if(!sw)if(!hantei(ban))sengetu.add(ban);
			if(sw)if(hantei(ban))if(!hantei2(ban))result.add(ban);
		}
		Collections.sort(result);
		for(int i=0;i<result.size();i++)System.out.println(result.get(i)+" "+m.get(result.get(i)));
	}
}

Measured memory_bytes: 17188
N, M = map(int, input().split())
K = []
S = []
for m in range(M):
    inp = list(map(int, input().split()))
    # K.append(inp[0])
    S.append(inp[1:])

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

X = []


def dfs(A):
    if N == len(A):
        X.append(A.copy())
        return
    for i in [0, 1]:
        A.append(i)
        dfs(A)
        A.pop()


dfs([])


def s(m, x):
    s = 0
    for mm in m:
        s += x[mm - 1]
    return s


count = 0
for x in X:
    flg = True  # 一つでも点灯しないものがあったらFalse
    for m, p in zip(S, P):  # 電球ループ
        su = s(m, x)
        if su % 2 != p:
            flg = False
    if flg:
        count += 1

print(count)


Measured memory_bytes: 3188
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	cout << lcm(2, n) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

string s,t;



signed main(){
	vector<string>ans;
	while(cin>>s,s!="."){
        cin>>t;
        int diff = 0;
        string ss="",tt="";
        vector<string>svec,tvec;
        rep(i,0,s.size()){
            if(s[i]=='"'){
                svec.push_back(ss);
                ss = "";
            }
            else ss += s[i];
        }
		svec.push_back(ss);
        rep(i,0,t.size()){
            if(t[i]=='"'){
                tvec.push_back(tt);
                tt = "";
            }
            else tt += t[i];
        }
		tvec.push_back(tt);
		if(svec.size()!=tvec.size()){
			ans.push_back("DIFFERENT");
			continue;
		}
        rep(i,0,svec.size()){
            if(svec[i]!=tvec[i]){
                if(i%2==0)diff += 101010;
                else diff += 1;
            }
        }
        if(diff==0)ans.push_back("IDENTICAL");
        else if(diff==1)ans.push_back("CLOSE");
        else ans.push_back("DIFFERENT");
    }
	for(auto e:ans){
		cout<<e<<endl;
	}
}


Measured memory_bytes: 3180
from collections import deque
s = deque(input().replace('\n', ''))
q = int(input())
flag = True
for i in range(q):
    query = list(map(str, input().split()))
    if query[0]=='1':
        if flag: flag = False
        else: flag = True
    else:
        
        if (not flag and query[1]=='1') or flag and query[1]=='2':
            s.append(query[2])
        else:
            s.appendleft(query[2])

s = list(s)
if not flag:
    s = s[::-1]

print(''.join(s))


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


int main(){

	int n;
	cin>>n;
	double p[n+1];
	for(int i=1;i<=n;i++) cin>>p[i];

	double dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    dp[1][0]=1.00-p[1];
    dp[1][1]=p[1];
	for(int i=2;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(j>i) continue;
            if(j==0) {
            	dp[i][j]=(dp[i-1][j]*(1.00-p[i]));
                   continue;
            }
			dp[i][j]=(dp[i-1][j-1]*(p[i]))+(dp[i-1][j]*(1.00-p[i]));
			//printf("%lf  ",dp[i][j] );
		}
		//cout<<endl;
	}
	double ans=0;
  for(int i=0;i<=n;i++){
    if(i>n/2){
    	ans+=dp[n][i];
    }
  }
  printf("%0.11lf\n",ans );
 
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = 0, ans_x[n - 1], ans_y[n - 1];
    int x = a[n - 1], y = a[0];
    for (int i = 1; i < n - 1; i++) {
        if (a[i] < 0) {
            ans_x[i - 1] = x;
            ans_y[i - 1] = a[i];
            x -= a[i];
        } else {
            ans_x[i - 1] = y;
            ans_y[i - 1] = a[i];
            y -= a[i];
        }
    }
    ans_x[n - 2] = x;
    ans_y[n - 2] = y;
    ans = x - y;
    cout << ans << endl;
    for (int i = 0; i < n - 1; i++) {
        cout << ans_x[i] << ' ' << ans_y[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
N = gets.to_i
a,b,c,d = 0,0,0,0
N.times do
  s = gets.chomp
  if s == "AC"
    a += 1
  elsif s == "WA"
    b += 1
  elsif s == "TLE"
    c += 1
  else
    d += 1
  end
end
puts "AC x #{a}"
puts "WA x #{b}"
puts "TLE x #{c}"
puts "RE x #{d}"

Measured memory_bytes: 14384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define llu unsigned long long 
#define ll long long 
ll read() { ll  x; if (scanf("%lld", &x) == -1)exit(0); return x; }
#define vi vector<int>
#define vb vector<bool>
#define LOCAL_JUDGE
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef LOCAL_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {
    //c_p_c();
    ll a = read(); ll b = read();ll c = read();ll k = read();
    if (k > a) {
        if ((k - (b + a)) <= c)
            cout << a - (k - (b + a)) << endl;
        else
            cout << a << endl;
    }
    else cout << k << endl;
}



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

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


void solve(long long N, long long K, std::vector<long long> A){
    ll a=0,temp=1;
    if(N==K){
    cout<<1<<endl;
    return;
    }
    while(temp){
        a++;
        N=N-K;
        if(N+1<=K){
            temp=0;
            a++;
        }
        else N++;
    }
    cout<<a<<endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"

//#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define dd(n) cout<<fixed<<setprecision(n)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define pi 3.14159265358979
#define co(x) cout<<x<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

#define lint long long
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
dx8[8] ={ 0,1,1,1,0,-1,-1,-1 },
dy8[8] ={ 1,1,0,-1,-1,-1,0,1 },
dx4[4] ={ 0,1,0,-1 },
dy4[4] ={ 1,0,-1,0 };

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

int main(){
	setc;

	int n,k;cin>>n>>k;
	int pos=n%k,left=n/k+1;

	lint ans=0;
	lint p;
	if (k%2==0){
		p = k/2<=pos?left:left-1;
		ans+= p*p*p;
	}
	p = k<=pos?left:left-1;
	ans+= p*p*p;
	co(ans);
	gc();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N,K;
  cin >> N >> K;
  vector<int>a(N, 0);
  
  for(int i=0;i<K;i++){
    int t;
    cin >> t;
    
    for(int j=0;j<t;j++){
      int p;
      cin >> p;
      a[p-1]++;
    }
  }
  
  int ans = 0;
  for(int i=0;i<N;i++){
    if(a[i] == 0) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

struct sieveOfEratosthenes {
  vi divisor,primes;
  sieveOfEratosthenes(int N) :
    divisor(N+1,0) 
  {
    iota(rng(divisor),0);
    srep(i,2,N+1) {
      if(divisor[i]==i) {
        primes.emplace_back(i);
        for(int j=i;j<=N;j+=i) {
          divisor[j]=i;
        }
      }
    }
  }
  map<ll,int> primefact(ll x) {
    map<ll,int> res;
    if(x < sz(divisor)) {
      while(x>1) {
        res[divisor[x]]++;
        x /= divisor[x];
      }
    } else {
      for(int p:primes) {
        while(x%p==0) {
          x /=p;
          res[p]++;
        }
        if(x==1) break;
      }
      if(x>1) res[x]++;
    }
    return res;
  }
};

sieveOfEratosthenes s(1000000);
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  vi cnt(1000010,0);
  int g = A[0];
  int ma=0;
  rep(i,N) {
    g = __gcd(A[i],g);
    for(auto p:s.primefact(A[i])) {
      cnt[p.first]++;
      chmax(ma,cnt[p.first]);
    }
  }
  if(ma<=1) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  if(g==1) {
    cout << "setwise coprime" << endl;
    return 0;
  }
  cout << "not coprime" << endl;
  return 0;
}

Measured memory_bytes: 15324
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line[] = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int m = Integer.parseInt(line[1]);
			if (n==0) {break;}

			int[] onelist = new int [n+1];
			for(int i=1; i<=n; i++){
				onelist[i] = Integer.parseInt(br.readLine());
			}

			int[] twolist = new int [(n+2)*(n+1)/2];
			for(int i=0; i<=n; i++){
				for(int j=i; j<=n; j++){
					twolist[i*(n+1)-i*(i+1)/2 + j] = onelist[i] + onelist[j];
				}
			}
			Arrays.sort(twolist);

			int maxi = (n+2)*(n+1)/2;
			KOKO: for(int i=0; i<m; i++){
				for(int j=0; j<maxi; j++){
					if(Arrays.binarySearch(twolist, m-i-twolist[j]) > 0){
						System.out.println(m-i);
						break KOKO;
					}
				}
			}
		}
	}
}

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

int main() {
    string s;
    cin >> s;
    for (int z=0;z<s.size()-1;z++){
        if (s[z] == s[z+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}


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

int main() {
	int f = 0;
	string N;
	cin >> N;
	for (int i = 0; i <= 1; i++) {
		if ((N[i] == N[i + 1]) && (N[i+1]== N[i + 2])) {
			f++;
		}
	}
	if (f >= 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll a[n];
    rp(i,n) cin >> a[i];
    sort(a,a+n);
    ll prev = -1;
    ll ind = -1;
    rpd(i,n-1){
      if(a[i+1] == a[i]){
        ind = i;
        break;
      }
    }
    if(ind == -1) {
      cout << 0 << endl;
      return 0;
    }

    ll dlina = a[ind];
    ll b[n-2];
    rp(i,n-2){
      if(i < ind){
        b[i] = a[i];
      }
      else b[i] = a[i+2];
    }
    ind = -1;
    rpd(i,n-3){
      if(b[i+1] == b[i]){
        ind = i;
        break;
      }
    }
    if(ind == -1) {
      cout << "0"<<endl; return 0;
    }
    cout << dlina*b[ind] << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

ll inf = 1000000000LL * 1000000000LL;

void solve(){
	ll L , R;
	cin >> L >> R;
	ll fin = inf;
	for(long long i = L ; i <= min(R,L+2019) ; ++i){
		for(long long j = i+1 ; j <= min(R,L+2019) ; ++j){
			fin = min(fin , i*j % 2019);
		}
	}
	cout << fin << endl;
	return;
}

int main(){
	int q = 1;
	//cin >> q;
	for(int i = 1; i <= q ; ++i){
		solve();
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
int main() {
	std::cin.tie(0); std::cin.sync_with_stdio(false);
	int n; std::cin >> n;
	for (auto i = 1; i < 10; ++i) for (auto j = i; j < 10; ++j) {
		if (i * j == n) {
			std::cout << "Yes\n";
			return 0;
		}
	}
	std::cout << "No\n";
}


Measured memory_bytes: 888
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const int inf=1<<29;

int n,x,y,sum;
ll a[1000000];

int main(){
	scanf("%d",&n);
	if(n>1){
		for(int i=1;i<=n;i++){
			scanf("%lld",&a[i]);
		}
		int mid=1,mis=0,mic=0,mif=0;
		sort(a+1,a+n+1);
		for(int i=1;i<=n;i++){
			if(a[i]==1){
				mis++;
				if(mis>1) mif++;
			}
			else{
				if(a[i]==a[i+1]) mid++;
				else{
					if(mid>=a[i]) y=mid-a[i];
					if(mid<a[i]) y=mid;
					mid=1;
					mic+=y;
				}
			}
		}
				sum=mic+mif;
				printf("%d\n",sum);
	}
else{
	scanf("%d",&x);
	if(x!=1) printf("1\n");
	else printf("0\n");
}
}

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



int main(){
	int n; 
	cin >> n;
	vector<int> l(2*n,0);
	
	for(int i=0; i<2*n;i++)
		cin >> l[i];
	sort(l.begin(), l.end());
	int s;
	for(int i=2*n-1; i>0; i-=2)
		s += min(l[i], l[i-1]);
	
	cout << s;
	return 0;
	}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[105],b[305];
	scanf("%s",&a);
	getchar();
	scanf("%s",&b);
	getchar;
	int len=strlen(a);
	bool flag=0;
	for(int i=len;i<len*2;i++)
	b[i]=b[i-len];
	for(int i=0;i<len;i++)
	{
		int num=0;
		for(int j=0;j<len;j++)
		{
			if(a[j]==b[j+i])
			num++;
		}
		if(num==len)
		{
			flag=1;
			break;
		}
	}
	if(flag)
	printf("Yes\n");
	else
	printf("No\n");
} 

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$height = explode(' ', trim(fgets(STDIN)));

$l = array();
$r = array();
foreach ($height as $key => $value) {
  $l[$key+1 + $value][] = $key+1;
  $r[$key+1 - $value][] = $key+1;
}

$values = array_keys($l + $r);

$cnt = 0;
foreach ($values as $value) {
  if (isset($l[$value]) && isset($r[$value])) {
    $cnt += count($l[$value]) * count($r[$value]);
  }
}

echo $cnt;


Measured memory_bytes: 208472
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;

int main()
{
    ll n;
    cin >> n;
    ll a[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll now1 = 0;
    ll now2 = 0;
    ll ans1 = 0;
    ll ans2 = 0;
    for (ll i = 0; i < n; i++)
    {
        now1 += a[i];
        if (i % 2 == 0)
        {
            ans1 += seinomi(1 - now1);
            now1 += seinomi(1 - now1);
        }
        else
        {
            ans1 += seinomi(now1 + 1);
            now1 -= seinomi(now1 + 1);
        }
    }
    for (ll i = 0; i < n; i++)
    {
        now2 += a[i];
        if (i % 2 == 1)
        {
            ans2 += seinomi(1 - now2);
            now2 += seinomi(1 - now2);
        }
        else
        {
            ans2 += seinomi(now2 + 1);
            now2 -= seinomi(now2 + 1);
        }
    }
    cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 4412
N = int(input())
S = []
for i in range(N):
    S.append(input())

print('AC x '+ str(S.count('AC')))
print('WA x '+ str(S.count('WA')))
print('TLE x '+ str(S.count('TLE')))
print('RE x '+ str(S.count('RE')))

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

int main(){
  vector<int> vec(3);
  vector<int> wa(4);
  int answer;
  
  for(int i = 0;i < 3;i++){
    cin >> vec.at(i);
  }
  
  wa.at(0) = vec.at(0) + vec.at(1);
  wa.at(1) = vec.at(0) + vec.at(2);
  wa.at(2) = vec.at(1) + vec.at(2);
  wa.at(3) = wa.at(0);
  

  if(wa.at(0) <= wa.at(1)){
    answer = wa.at(0);
  } else {
    answer = wa.at(1);
  }
  if(answer >= wa.at(2)){
    answer = wa.at(2);
  }
  cout << answer << endl;
}
  
  

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

int main() {
	int a, b, c[1010], sum = 0;
	cin >> a >> b;

	for (int i = 1; i <= 999; i++) {
		sum += i;
		c[i] = sum;
	}

	for (int i = 1; i <= 999; i++) {
		if (c[i] - a == c[i + 1] - b) {
			cout << c[i] - a << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
int gcd(int x, int y)
{
    if(y==0)
        return x;
    return gcd(y, x%y);
}

 long long numbers[500005];

int a[100005];

  int main(){

   long long n,x,total=0,sum=0;
   cin>>n>>x;



   for(int i=1;i<=n;i++)
    cin>>a[i];

    for(int i=1;i<=n;i++){
        if(a[i] + a[i-1] > x){
            total = (a[i]+a[i-1] -x);
            sum += total;
            a[i] -= total;
        }
    }

    cout<<sum<<endl;

  return 0;
  }

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

constexpr int MAX_N = 200000;

int main() {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  --A, --B, --C, --D;
  string S;
  cin >> S;

  for (int i{A+1}; i < max(C, D) - 1; ++i) {
    if (S[i] == '#' && S[i+1] == '#') {
      cout << "No" << endl;
      return 0;
    }
  }

  if (C > D) {
    bool space{false};
    for (int i{B}; i <= D; ++i) {
      if (S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
        space = true;
        break;
      }
    }
    if (!space) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

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

string s;
int main() {
  cin >> s;
  i64 n = s.size(), p = 0;
  for (char c : s) {
    if (c == 'p') ++p;
  }
  cout << n / 2 - p << '\n';
  return 0;
}


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

int main()
{
    int n,k;
    cin >> n >> k;
    vector<char>s(n);
    for(int i=0;i<n;i++)
    {
        cin >> s.at(i);
    }

    k--;

    switch (s.at(k))
    {
        case 'A':s.at(k)='a';break;
        case 'B':s.at(k)='b';break;
        case 'C':s.at(k)='c';break;
        case 'D':s.at(k)='d';break;
        case 'E':s.at(k)='e';break;
        case 'F':s.at(k)='f';break;
        case 'G':s.at(k)='g';break;
        case 'H':s.at(k)='h';break;
        case 'I':s.at(k)='i';break;
        case 'J':s.at(k)='j';break;
        case 'K':s.at(k)='k';break;
        case 'L':s.at(k)='l';break;
        case 'M':s.at(k)='m';break;
        case 'N':s.at(k)='n';break;
        case 'O':s.at(k)='o';break;
        case 'P':s.at(k)='p';break;
        case 'Q':s.at(k)='q';break;
        case 'R':s.at(k)='r';break;
        case 'S':s.at(k)='s';break;
        case 'T':s.at(k)='t';break;
        case 'U':s.at(k)='u';break;
        case 'V':s.at(k)='v';break;
        case 'W':s.at(k)='w';break;
        case 'X':s.at(k)='x';break;
        case 'Y':s.at(k)='y';break;
        case 'Z':s.at(k)='z';break;
    }

    for(int i=0;i<n;i++)
    {
        cout << s.at(i);
    }
    cout << endl;

    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;
 
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}
 
// g++ -std=c++11 prac.cpp
     
 
int main() {
  ll x,y,z=0,k,n,m,h,w,ans=0,sum=0,Max=-1,Min=1e9+1;
  bool ok = true;
  string s,t,r;
  cin >> s;
  rep(i,s.size()){
    if(s[i]=='7'){
      cout << "Yes" << endl; 
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int l=0,r=n-1;
    int ans=0;
    while(1){
        if(s[l]!='x'&&s[r]!='x'){
            if(s[l]!=s[r]){
                cout<<-1<<endl;
                return 0;
            }
            else{
                r--; l++;
            }
        }
        if(s[l]=='x'&&s[r]!='x')l++,ans++;
        if(s[l]!='x'&&s[r]=='x')r--,ans++;
        if(s[l]=='x'&&s[r]=='x')r--,l++;
        if(r-l<=0)break;
    }
    cout<<ans<<endl;
}

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

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	ll N;
    cin >>N;

    map<ll,ll> mp;

    repn(i,N){
        ll a;
        cin >>a;
        mp[a]++;
    }
	
    ll ans=0;

    for(auto x:mp){
        if(mp[x.first]%2==1){ans++;}
    }

    cout <<ans;

}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	map<int, int> mp;
	rep(i, n) {
		int a;
		cin >> a;
		mp[a]++;
	}
	priority_queue<P, vector<P>, greater<P>> pq;
	for (auto c : mp) {
		pq.emplace(c.first, c.second);
	}
	while (m--) {
		int b, c;
		cin >> b >> c;
		int bt = b;
		while (b && c > pq.top().first) {
			P p = pq.top(); pq.pop();
			if (p.second >= b) {
				if (p.second != b) pq.emplace(p.first, p.second - b);
				b = 0;
				break;
			}
			b -= p.second;
		}
		pq.emplace(c, bt - b);
	}
	ll ans = 0;
	while (pq.size()) ans += (ll)pq.top().first * pq.top().second, pq.pop();
	cout << ans << endl;
	return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    string a, b;
    cin >> a >> b;
    
    if (a == b) cout << "H" << endl;
    else cout << "D" << endl;
    
    return 0;
}


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

namespace id_0338cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var vs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var w = vs[0];
            var h = vs[1];
            var c = vs[2];
            Console.WriteLine(w / Gcd(w, h) * h / Gcd(w, h) * c);

        }
        static int Gcd(int a, int b)
        {
            var result = Math.Min(a, b);
            while (true)
            {
                if(a%result == 0 && b % result == 0)
                {
                    break;
                }
                result--;
            }
            return result;
        }
    }
}



Measured memory_bytes: 9600
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] a = new int[n];
    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
    }
    Arrays.sort(a);
    long gg = (long) Math.pow(2,n-1);
    double sum = (double) a[0]/gg;
    for (int j=1;j<n;j++){
      long power = (long) Math.pow(2,n-j);
      sum += (double) a[j]/power;
    }
    System.out.println(sum);

  }
}


Measured memory_bytes: 36120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


int main(){
    ll a, b, x;    cin >> a >> b >> x;
    ll res=b/x;
    if(0<a) res -= (a-1)/x;
    else res += 1;
    cout << res << endl;
}

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

signed main(){
	int n,m;
	cin>>n>>m;
	vector<vector<int>> adj(n);
	for (int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--,b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	vector<int> out(n);
	vector<int> dp(n);
	queue <int> st;
	st.push(0);
	while (!st.empty()){
		auto cur = st.front();
		st.pop();
		for (auto x:adj[cur]){
			if (out[x]==0){
				out[x]=cur+1;
				st.push(x);
			}
		}
	}
	if (adj[0].size()==0){
		cout<<"No";
		return 0;
	}
	cout<<"Yes"<<endl;
	for (int i=1;i<n;i++){
		cout<<out[i]<<endl;
	}

}

Measured memory_bytes: 13816
# include <bits/stdc++.h>
using namespace std;
int main(){
	int n , ans = 0;
	cin >> n;
	int a[n + 1];
	for(int i = 1; i <= n; i ++) cin >> a[i];
	sort(a + 1 , a + n + 1);
	for(int K = a[1]; K <= a[n]; K ++){
		int l = 1 , r = n , res = 0;
		while(l <= r){
			int m = (l + r) >> 1;
			if(a[m] < K) res = m , l = m + 1;
			else r = m - 1; 
		}
		ans += (res == n / 2);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 640
N = int(input())
S = [input() for _ in range(N)]

res = {}
for s in S:
    if s in res:
        res[s] += 1
    else:
        res[s] = 1
max_ = max(res.values())

ans = []
for k in res:
    if res[k] == max_:
        ans.append(k)
ans.sort()

for a in ans:
    print(a)

Measured memory_bytes: 38428
#include <cstdio>
#include <cstdlib>
#include <algorithm>

typedef long long LL;

const int maxn = 1e6 + 20;
const int mod = 1e9 + 7;

int N, M, K, sum;
LL fac[maxn];
LL inv[maxn];
LL pw[maxn];
 
LL powermod(LL x,LL y)
{
	LL z = 1;
	
	while(y)
	{
		if(y & 1) z = z * x % mod;
		x = x * x % mod, y >>= 1;
	}
	
	return z;
}
LL combine(LL x,LL y)
{
	if(y < 0 || y > x) return 0;
	return fac[x] * inv[y] % mod * inv[x - y] % mod;
}
int main()
{
	scanf("%d%d%d", &N, &M, &K);
	sum = N + M + K;
	
	pw[0] = fac[0] = inv[0] = 1;
	for(int i = 1; i <= sum; i++)
	{
		pw[i] = pw[i - 1] * 3 % mod;
		fac[i] = fac[i - 1] * i % mod;
	}
	
	inv[sum] = powermod(fac[sum], mod - 2);
	for(int i = sum - 1; i >= 1; i--)
	{
		inv[i] = inv[i + 1] * (i + 1) % mod;
	}
	
	LL s = 1, ans = 0;
	
	for(int i = 0; i <= M + K; i++)
	{
		ans += s * combine(N - 1 + i, N - 1) % mod * pw[M + K - i] % mod;
		s = s * 2 - combine(i, M) - combine(i, K);
		s = (s % mod + mod) % mod;
	}
	ans %= mod;
	
	printf("%d", (int) ans);
	return 0;
}

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

int main() {
    string s;cin >> s;
    bool flag = false;
    int l = s.size();
    for(int i=0;i<l-1;i++){
        if(s[i]==s[i+1]){
            flag = true;
        }else{
            continue;
        }
    }

    if(flag == true){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
using namespace std;

int main(){
	char input1=0,input2=0;
	int num1=0,num2=0;
	for(int i=0;i<4;i++){
		char tmp;
		cin>>tmp;
		if(num1==0){
			input1=tmp;
			num1++;
		}else if(input1==tmp){
			num1++;
		}else if(num2==0){
			input2=tmp;
			num2++;
		}else if(input2==tmp){
			num2++;
		}
	}
	if(num1==2 && num2==2){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 256
//Miss Me??
#include<bits/stdc++.h>
using namespace std;
     
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long int
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define N 200009
#define mod 1000000007
#define cn continue
#define bre break
#define pr pair<int,int>

int n;
string s;
int see[26];

signed main()
{
    boost;
    cin>>n>>s;
    for(int i=0;i<26;i++)
    {
        see[i]=1;
    }
    for(int i=0;i<s.length();i++)
    {
        see[s[i]-'a']++;
    }
    int ans=1;
    for(int i=0;i<26;i++)
    {
        ans*=see[i];
        ans%=mod;
    }
    cout<<((ans-1)+mod)%mod<<endl;
 }

Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector< T > >;

template<class T>
T min(T a, T b, T c) {
  T ret = min(a, b);
  ret = min(ret, c);
  return ret;
}

int levenshtein_distance(string a, string b) {
  if (a.length() == 0 && b.length() == 0) {
    return 0;
  }
  if (a.length() == 0) {
    return b.length();
  }
  if (b.length() == 0) {
    return a.length();
  }

  vvi d(a.length()+1, vi(b.length()+1));
  for (int ia = 1 ; ia <= a.length() ; ia++) {
    d[ia][0] = ia;
  }
  for (int ib = 1 ; ib <= b.length() ; ib++) {
    d[0][ib] = ib;
  }
  
  for (int ia = 1 ; ia <= a.length() ; ia++) {
    for (int ib = 1 ; ib <= b.length() ; ib++) {
      const int cost = (a[ia-1] == b[ib-1]) ? 0 : 1;
      d[ia][ib] = min(d[ia-1][ib]+1, d[ia][ib-1]+1, d[ia-1][ib-1]+cost);
    }
  }
  return d[a.length()][b.length()];
}

int main() {
  string a, b;
  cin >> a;
  cin >> b;

  printf("%d\n", levenshtein_distance(a, b));

  return 0;
}

Measured memory_bytes: 6836
import java.util.*;
import java.io.*;
import java.lang.*;

class Main
{
	public static void main(String[] args)
	{
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		try{
			for(int cnt=0;; ++cnt){
				int w = Integer.parseInt(bf.readLine());
				if(w==0) break;
				int n = Integer.parseInt(bf.readLine());
				int[] vs = new int[n];
				int[] ws = new int[n];

				for(int i=0; i<n; ++i){
					String[] strs = bf.readLine().split(",");
					vs[i] = Integer.parseInt(strs[0]);
					ws[i] = Integer.parseInt(strs[1]);
				}

				int ansv = -1;
				int answ = 0;
				int[][] dp = new int[n][w+1];

				for(int i=0; i<n; ++i){
					for(int j=0; j<w+1; ++j){
						if(i == 0)
							dp[i][j] = ws[i]<=j ? vs[i] : 0;
						else{
							dp[i][j] = dp[i-1][j];
							if(j-ws[i]>=0)
								dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-ws[i]]+vs[i]);
						}
						if(ansv < dp[i][j] || (ansv == dp[i][j] && answ > j)){
							ansv = dp[i][j];
							answ = j;
						}
					}
				}

				System.out.println("Case " + (cnt+1) + ":\n" + ansv + "\n" + answ);
			}
		}
		catch(IOException ex)
		{}
	}
}

Measured memory_bytes: 13000
#include <stdio.h>

int main()
{
	int N;
	char S[200001];
	scanf("%d", &N);
	scanf("%s", S);
	
	int i, min, sum = 0;
	for (i = 0; i < N; i++) if (S[i] == '.') sum++;
	for (i = 0, min = sum; i < N; i++) {
		if (S[i] == '.') sum--;
		else sum++;
		if (sum < min) min = sum;
	}
	
	printf("%d\n", min);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 384