akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String A = sc.next();
    String B = sc.next();
    if (A.length() < B.length()) {
      System.out.println("LESS");
      return;
    } else if (A.length() > B.length()) {
      System.out.println("GREATER");
      return;
    }
    
    for (int i = 0; i < A.length(); i++) {
      if(A.charAt(i) < B.charAt(i)) {
        System.out.println("LESS");
        return;
      } else if (A.charAt(i) > B.charAt(i)) {
        System.out.println("GREATER");
        return;
      }
    }
    System.out.println("EQUAL");
  }
}

Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>

using namespace std;

int main(void){
    int N, M, c[50] = {0};
    scanf("%d%d", &N, &M);
    for(int i = 0; i < M; i++){
        int a, b;
        scanf("%d%d", &a, &b);
        c[a-1]++;
        c[b-1]++;
    }
    for(int i = 0;i < N; i++){
        printf("%d\n", c[i]);
    }
    return 0;
}


Measured memory_bytes: 256
/*

Author : AllKilled
Date   : 202001197 19:50:00 UTC+8

Website: https://atcoder.jp/contests/abc152
Contest: AtCoder Beginner Contest 152
Problem: Task D.
Result :

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

typedef long long LL;
typedef pair<LL, LL> PLL;

const int inf = 0x3f3f3f3f;
const int N = 18;
const LL MAXN = (1 << N) + 3;

///--------------------------------------------///

LL f[N][N], n;

int main()
{
    cin >> n;
    for (int m, k, i = 1; i <= n; ++i) {
        m = i; k = 0;
        while (m) {
            k = k * 10 + m % 10;
            m /= 10;
        }
        int head = k % 10;
        int tail = i % 10;
        f[head][tail] += 1;
    }
    LL ans = 0;
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 10; ++j) {
            ans += f[i][j] * f[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < 3; i++)
			set.add(sc.nextInt());
		
		System.out.println(set.size());
		
		sc.close();
	}
}



Measured memory_bytes: 27088
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 5;

int main()
{
	int a[MaxN];
	for(int i = 0 ; i < 3 ; i++)
		scanf("%d",&a[i]);
		sort(a,a + 3);
	if(a[0] == 5 && a[1] == 5 && a[2] == 7)printf("YES\n");
	else printf("NO\n");
	return 0;
	}

Measured memory_bytes: 256
#define N 5
#include <stdio.h>

int main(){
    
    int x[N],y[N];
    int i,j;
    int z = 10;
    int sum = 0;
    
    for(i = 0; i < N; i++){
        scanf("%d",&x[i]);
        y[i] = x[i];
        while(y[i] > 10){
            y[i] = y[i] % 10;
        }
        if(y[i] != 0 && z > y[i]){
            z = y[i];
            j = i;
        }
    }
    for(i = 0; i < N; i++){
        if(j == i)sum = sum + x[i];
        else if(y[i] == 0){
            sum = sum + x[i];
        }
        else{
            sum = sum + x[i] - y[i] + 10;
        }
    }
    
    printf("%d\n",sum);
    
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_168_b
    {

#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            int[] hon = new int[] { 2, 4, 5, 7, 9 };

            int K = ReadInt();
            string S = ReadString();

            if (S.Length <= K)
            {
                Write(S);
            } else
            {
                Write(S.Substring(0, K) + "...");
            }
        }


        private static void Write(string s)
        {
            Console.WriteLine(s);
        }

        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }
        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static void ReadInt(out int a, out int b)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
        }
        private static void ReadInt(out int a, out int b, out int c)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
            c = ar[2];
        }
        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            return ss;
        }
#if !TEST
    }
}
#endif

Measured memory_bytes: 27552
import java.util.Scanner;

public class Main{


	public static void main(String[] args){

		Scanner scan =new Scanner(System.in);
		int W=scan.nextInt();
		int H=scan.nextInt();
		int x=scan.nextInt();
		int y=scan.nextInt();
		int r=scan.nextInt();

		if(r<=x&&r<=y&&x+r<=W&&y+r<=H){
			System.out.println("Yes");
		}else{System.out.println("No");}
	}


}

Measured memory_bytes: 26280
#include <stdio.h>
#include <string.h>

#define M 1046527
#define NIL -1
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch=='A') return 1;
  else if(ch=='C') return 2;
  else if(ch=='G') return 3;
  else if(ch=='T') return 4;
  else return 0;
}

long long getkey(char str[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}

int h1(int key) {return key%M;}
int h2(int key) {return 1+(key%(M-1));}

int find(char str[]){
  long long key,i,h;
  key=getkey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=getkey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main()
{
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++) H[i][0]='\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
    if(com[0]=='i'){
      insert(str);
    }
    else {
      if(find(str)){
	printf("yes\n");
      }
      else printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 14916
#include<bits/stdc++.h>
using namespace std;
int a[100005][2];

int main(){
	int n,m,cnt1=0,cnt2=0;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
    	int b;
    	string str;
    	cin>>b>>str;
    	if(a[b][0]==0 && str=="AC" ){
    		cnt2+=a[b][1];
    		cnt1++;
    		a[b][0]=1;
		}
		else if(a[b][0]==0 && str=="WA"){
			a[b][1]++;
		}
	}
	printf("%d %d",cnt1,cnt2);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e8;
typedef long long ll;
ll mod = 998244353;
long long fast_exp(long long a, long long b)
{
    if(b == 0)
	   return 1;
    else
    {
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
    }
}
const ll N = 1e6;


int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	string s;
	int cnt = 0;
	cin>>s;
	int l = 0, r = s.size()-1;
	while(l<=r)
	{
		if(s[l]!=s[r])
			cnt++;
		l++;
		r--;
	}
	cout<<cnt<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  /////r~lまでの和が0　ー＞　累積和
  int n;
  cin>>n;
  vll a(n);
  rep(i,0,n) cin>>a[i];
  vll sum(n+1,0);
  sum[0]=0;
  rep(i,0,n) sum[i+1]=sum[i]+a[i];
  map<ll,ll> cnt;
  rep(i,0,n+1){
    cnt[sum[i]]++;
  }
  ll ans=0;
  for(auto v:cnt){
    ans+=v.second*(v.second-1)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 18744
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  string s;
  cin >> s;

  int n = s.length();
  int left = 0;
  int right = n-1;
  int ans = 0;
  while (left < right) {
    if (s[left] != s[right]) ans++;
    left++;
    right--;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
X, Y = map(int, input().split())
if X == 1:
    x = 300000
elif X == 2:
    x = 200000
elif X == 3:
    x = 100000
else:
    x = 0

if Y == 1:
    y = 300000
elif Y == 2:
    y = 200000
elif Y == 3:
    y = 100000
else:
    y = 0


if X == 1 and Y == 1:
    print(1000000)
else:
    print(x+y)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
        int a,b,c;
        cin>>a>>b>>c;
        int Min=0;
        int Mid=0;
        int Max=0;
        if(a<=b && b<=c){
            Min=a;
            Mid=b;
            Max=c;
        }
        else if(a<=c && c<=b){
            Min=a;
            Mid=c;
            Max=b;
        }
        else if(b<=a && a<=c){
            Min=b;
            Mid=a;
            Max=c;
        }
        else if(b<=c && c<=a){
            Min=b;
            Mid=c;
            Max=a;
        }
        else if(c<=a && a<=b){
            Min=c;
            Mid=a;
            Max=b;
        }
        else if(c<=b && b<=a){
            Min=c;
            Mid=b;
            Max=a;
        }
        cout<<Min<<" "<<Mid<<" "<<Max<<endl;
        return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define rp(i,l,m) for(int i=l; i<m; ++i)
#define Rp(i,l,m) for(int i=l; i<=m; i++)
#define rpD(i,l,m) for(int i=m; i>l; i--)
#define RpD(i,m,l) for(int i=m; i>=l; i--)
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define sz(a) int((a).size())
#define is insert
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = (int) 1e9 + 7;
const ld PI = acos((ld) -1);
inline ll gcd(ll a, ll b) {ll r; while (b) {r=a%b;a=b;b=r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p=MOD){ll r=1; for(;k;k>>=1){if(k&1)r=r*n%p;n=n*n%p;}return r;}
#define N 200005

int a[N], b[N], ans,n;

inline void Init(){
    cin >> n;
    rp(i,0,n) cin >> a[i];
    rp(i,0,n) cin >> b[i];

}
inline void solve(){
    rp(i,0,n) if(a[i]>b[i]) ans+=a[i]-b[i];
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    Init();
    solve();
  return 0;
}





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

int main() {
  int N, K, res=1;
  cin >> N >> K;
  
  rep(i, N) {
    if (res*2 < res+K) {res *= 2;}
    else {res += K;}
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long int gcm(long long int a,long long int b)
{
	if(b == 0)
	{
		return a;
	}
	return gcm(b,a%b);
}
long long int solve(long long int a,long long int b)
{
	return (a / gcm(a,b) * b);
}
int main()
{
	int n;
	long long int p;
	long long int t[101];
	cin >> n;
	for(int i=0;i < n;i++)
	{
		cin >> t[i];
	}
	p = 1;
	for(int i=0;i < n;i++)
	{
		p = solve(p,t[i]);
	}
	cout << p << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"APPROVED"<<endl ;
}
void no(){
  cout <<"DENIED"<<endl ;
}


//-------------------------------------------------
// メモ
/*






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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  bool f = true ;
  REP(i,n){
    int num ;
    cin >> num ;
    if(num%2==0){
      if(num%3!=0 && num%5!=0){
        f = false ;
      }
    }
  }
  if(f){
    yes() ;
  }
  else{
    no() ;
  }
    
  
  
  
  return 0 ;
}




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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	vector<char> k = { 'A','C','G','T' };
	int res = 0;
	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
		int s = 0;
		rep(j, 4) {
			if (S.at(i) == k[j]) { res++; s++; }
		}
		if (s == 0) res = 0;
		ans = max(ans, res);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
const ll mod = (ll)1e9 + 7;
const ll INF = (ll)2e18;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}

class ACantWaitForHoliday {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string S;
	    in >> S;
	    vector<string> temp = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	    int ans = 7;
	    rep(i, temp.size()) {
	        if (S == temp[i]) {
	            ans -= i;
	            break;
	        }
	    }
	    out << ans << endl;
	}
};


int main() {
	ACantWaitForHoliday solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
    ll n; cin >> n;
    ll a[3*n];
    for(ll i = 0; i < 3 * n; i++) cin >> a[i];
    sort(a, a+3*n);
    ll ans = 0;
    for(ll i = n; i < 3 * n; i+= 2) ans += a[i];
    cout << ans << endl;
}

Measured memory_bytes: 2560
/**
*	created: 26.09.2020 21:02:56
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rrep(i,n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define len(x) ll(x.size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
using ll = long long;
using P = pair<int,int>;
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;
template<typename T> inline bool chmax(T &a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T> inline bool chmin(T &a, T b) {if (b < a) {a = b; return 1;} return 0;}
inline void print(P a) {cout << a.first << " " << a.second << endl;}
template<typename T> T bpow(T a, ll n) {T r(1); while(n) {if (n & 1) r *= a; a *= a; n >>= 1;} return r;}
struct faster_io {faster_io() {cin.tie(0); ios_base::sync_with_stdio(false);}} faster_io_;

// UnionFind
struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n,-1) {}
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x,y);
        par[x] += par[y]; par[y] = x;
        return true;
    }
    bool issame(int x, int y) {return root(x) == root(y);}
    int size(int x) {return -par[root(x)];}
};

signed main() {
    int n, m; cin >> n >> m;
    UnionFind uf(n);
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        uf.merge(a,b);
    }
    set<int> st;
    rep(i,n) {
        st.insert(uf.root(i));
    }
    cout << st.size() - 1 << endl;
    return 0;
}

Measured memory_bytes: 7856
#include <iostream>
#include <vector>
using namespace std;
const int MAX_E = 5000;
const int MAX_V = 2500;
const int INF = 1000000000;

struct edge { int from, to, cost; };

edge es[MAX_E];

int d[MAX_V];
int n, m;

vector<bool> check(MAX_V);
vector<bool> check2(MAX_V);
vector<bool> ok(MAX_V);

vector< vector<int> > v(MAX_V);
vector< vector<int> > v2(MAX_V);

void dfs (int x) {
  if (check[x]) return;
  check[x] = true;
  for (int y : v[x]) {
    dfs(y);
  }
}

void rdfs (int x) {
  if (check2[x]) return;
  check2[x] = true;
  for (int y : v2[x]) {
    rdfs(y);
  }
}

int shortest_path(int s) {
  for (int i = 0; i < n; i ++) d[i] = INF;
  d[s] = 0;
  int n_loop = 0;
  while (true) {
    bool update = false;
    for (int i = 0; i < m; ++i) {
      edge e = es[i];
      if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost && ok[e.to] && ok[e.from]) {
        d[e.to] = d[e.from] + e.cost;
        update = true;
      }
    }
    n_loop++;
    if (n_loop > n) return -1;
    if (!update) return max(0, -d[n-1]);
  }
}

int main() {
  int p;
  cin >> n >> m >> p;
  for (int i = 0; i < m; ++i) {
    cin >> es[i].from >> es[i].to >> es[i].cost;
    es[i].from--;
    es[i].to--;
    es[i].cost = p - es[i].cost;
    v[es[i].from].push_back(es[i].to); 
    v2[es[i].to].push_back(es[i].from); 
  }
  dfs(0);
  rdfs(n-1);
  for (int i = 0; i < n; ++i) {
    d[i] = INF;
    ok[i] = check[i] && check2[i];
  }


  int ans = shortest_path(0);
  cout << ans << endl;

  return 0;
}

    
  



Measured memory_bytes: 640
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln             PIC X(30).
01 A              PIC 9(10).
01 B              PIC 9(10).
01 cnt            PIC 9(10).

PROCEDURE DIVISION.
  ACCEPT ln.
  INSPECT ln TALLYING cnt FOR ALL "7".
  IF cnt = ZERO
      DISPLAY "No"
  ELSE
      DISPLAY "Yes"
  END-IF.
  STOP RUN.


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


void solve(long long N){
    int cnt = 0;
    int num = 0;
    int digit;
    for(int i = 1; i <= (int)N; ++i){
        num = i;
        digit = 0;
        while(num != 0){
            num /= 10;
            digit++;
        }
        if(digit % 2 != 0) cnt++;
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	string s;
  	cin >> s;
  	long int ones = 0;

  	ones = count(s.begin(),s.end(),'1');
  	long int zeros = s.size()-ones;
  
  	cout << min(2*ones, 2*zeros)<<'\n';

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N(111111);
int main() {
	static bool f[N];
	static int cnt[N];
	int n, m;
	cin >> n >> m;
	f[1] = true;
	fill(cnt + 1, cnt + 1 + n, 1);
	for(int i(0); i < m; i++) {
		int x, y;
		cin >> x >> y;
		f[y] |= f[x];
		cnt[y] ++;
		cnt[x] --;
		if(cnt[x] == 0) {
			f[x] = false;
		}
	}
	int ans(0);
	for(int i(1); i <= n; i++) {
		ans += cnt[i] > 0 && f[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 768
# https://atcoder.jp/contests/abc061/tasks/abc061_c

n, k = map(int, input().split())

arr = []
for _ in range(n):
    a, b = map(int, input().split())
    arr.append((a, b))
arr.sort(key=lambda x: x[0])

for a, b in arr:
    k -= b
    if k <= 0:
        print(a)
        break



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

#define X first
#define Y second
#define MP make_pair
#define PB push_back
#define ll long long

using namespace std;

int main () {
	
	int n;
	cin>>n;
	for(int i=1; i<=n; i++){
		int z=i*1.08;
		if(z==n){
			cout<<i;
			return 0;
		}
	}
	cout<<":(";
	
	return 0;
}

Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())
s = x / a
rad = 0
if s >= a*b / 2:
    h = (a*b-s)*2/a
    rad = math.atan2(h, a)
else:
    w = s*2 / b
    rad = math.atan2(b, w)
deg = rad / (2*math.pi)*360
print('{:.10f}'.format(deg))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  ll A;
  long double B;
  cin >> A >> B;
  ll ans =  A*B;

  cout << ans << endl;
}


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

int main()
{
    long n;
    std::cin >> n;
    std::vector<long> a, b;
    for (int i = 0; i < n; i++) {
        long c;
        std::cin >> c;
        a.push_back(c);
        b.push_back(c);
    }
    std::sort(a.begin(), a.end());

    long cnt1 = a[n / 2 - 1];
    long cnt2 = a[n / 2];

    for (int i = 0; i < n; i++) {
        if (b[i] < cnt2) {
            std::cout << cnt2 << std::endl;
        } else {
            std::cout << cnt1 << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 5604
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    int n; cin >> n;
    vi v(n);
    int res = 0;
    rep (i, 0, n-1) {
        cin >> v[i];
        res ^= v[i];
    }

    rep (i, 0, n-1) {
        cout << (res ^ v[i]) << " ";
    }

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  string s,t;
  cin>>s>>t;
  ll m=s.length();
  ll n=t.length();
  ll l[m+1][n+1];
  for(ll i=0;i<=m;i++)
  {
    for(ll j=0;j<=n;j++)
    {
      if(i==0||j==0)
        l[i][j]=0;
      else if(s[i-1]==t[j-1])
        l[i][j]=1+l[i-1][j-1];
      else
        l[i][j]=max(l[i-1][j],l[i][j-1]);
    }
  }
  ll len=l[m][n];
  char lcs[len+1];
  lcs[len]='\0';
  ll i=m,j=n;
  while(i>0||j>0)
  {
    if(s[i-1]==t[j-1])
    {
      lcs[len-1]=s[i-1];
      i--;
      j--;
      len--;
    }
    else if(l[i-1][j]>l[i][j-1])
    {
      i--;
    }
    else
    {
      j--;
    }
  }
  cout<<lcs;
    return 0;
}

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

int main(){
    int ABCD[4];
    string S;
    cin >> S;
    ABCD[0] = S[0] - '0';
    ABCD[1] = S[1] - '0';
    ABCD[2] = S[2] - '0';
    ABCD[3] = S[3] - '0';

    for(int i=0;i<8;i++){
        int ans = ABCD[0];
        string opans = "";
        bool ops[3] = {i & 1, i & 2, i & 4};
        for(int j=0;j<3;j++){
            if(ops[j]){
                ans += ABCD[j+1];
                opans += "+";
            }
            else{
                ans -= ABCD[j+1];
                opans += "-";
            }
        }
        if(ans == 7){
            cout << ABCD[0] << opans[0] << ABCD[1] << opans[1] << ABCD[2] << opans[2] << ABCD[3] << "=" << 7 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [s]: string[] = tmp.shift().split(" ");
    const [t]: string[] = tmp.shift().split(" ");
    let result = 0;
    for (let i = 0, len = s.length; i < len; i++) {
      if (s.charAt(i) != t.charAt(i)) {
        result++;
      }
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 33092
#include<stdio.h>

int main()
{
	int i, j=-1, k=-1, a, b, x[7] = { 1,3,5,7,8,10,12 }, y[4] = { 4,6,9,11 };

	scanf("%d %d", &a, &b);
	
	for (i = 0; i < 7;i++) {
		if (a == x[i]) k = 0;
	}
	if (k != 0) {
		for (i = 0;i < 4;i++) {
			if (a == y[i])k = 1;
		}
		if (k != 1) {
			k = 2;
		}
	}

	for (i = 0;i < 7;i++) {
		if (b == x[i]) j = 0;
	}
	if (j != 0) {
		for (i = 0;i < 4;i++) {
			if (b == y[i])j = 1;
		}
		if (j != 1) {
			j = 2;
		}
	}

	if (j == k) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;

}

Measured memory_bytes: 128
#include<iostream>
#define INF 2147483647
using namespace std;

int A[100000];

void Update(int i, int x) {
	A[i] = x;
}

void Find(int x, int y) {
	int s, t, min = INF;
	if (x < y) { s = x; t = y; }
	else { s = y; t = x; }
	for (int i = s; i <= t; i++) {
		if (min > A[i]) min = A[i];
	}
	cout << min << endl;
}

int main() {
	int n, q, com, x, y;
	cin >> n >> q;
	for (int i = 0; i < n; i++) A[i] = INF;
	for (int j = 0; j < q; j++) {
		cin >> com >> x >> y;
		if (com == 0) {
			Update(x, y);
		}
		else if (com == 1) {
			Find(x, y);
		}
	}
}


Measured memory_bytes: 3484
function Main(s){
  s = s.split(" ").map(a=>+a);
  var n = s[0];
  var m = s[1] - 1;
  var d = s[2];
  var a = d ? 2 : 1;
  console.log(m * (n - d) * a / (n * n));
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
#! python3
def main():
    s = input()
    ans = ""
    r = len(s)
    for i in range(r):
        if s[i] == "0":
            ans += "0"
        elif s[i] == "1":
            ans += "1"
        else:
            ans = ans[:-1]

    print(ans)
    
main()

Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, a, b, c, d; cin >> n >> a >> b >> c >> d; --a; --b; --c; --d;
  string s; cin >> s;
  if (c < d) {
    while (b < d) {
      if (s[b + 1] == '.') {
        ++b;
        continue;
      } else if (s[b + 2] == '.') {
        b += 2;
        continue;
      }
      cout << "No\n";
      return 0;
    }
    while (a < c) {
      if (s[a + 1] == '.') {
        ++a;
        continue;
      } else if (s[a + 2] == '.') {
        a += 2;
        continue;
      }
      cout << "No\n";
      return 0;
    }
  } else {
    while (b < d) {
      if (b - 1 >= 0 && b + 1 < n && s[b - 1] == '.' && s[b + 1] == '.') break;
      if (s[b + 1] == '.') {
        ++b;
        continue;
      } else if (s[b + 2] == '.') {
        b += 2;
        continue;
      }
      cout << "No\n";
      return 0;
    }
    s[b] = '#';
    while (a < c) {
      if (s[a + 1] == '.') {
        ++a;
        continue;
      } else if (s[a + 2] == '.') {
        a += 2;
        continue;
      }
      cout << "No\n";
      return 0;
    }
    while (b < d) {
      if (s[b + 1] == '.') {
        ++b;
        continue;
      } else if (s[b + 2] == '.') {
        b += 2;
        continue;
      }
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
using namespace std;
int k,cnt,a[21];
bool bl;
vector <int> ans;
void dfs(int x,int n)
{
	if (bl) return;
	if (x==n+1)
	{
		cnt++;
		if (cnt==k)
		{
			for (int i=1;i<=n;i++)
			  ans.push_back(a[i]);
			bl=1;
		}
		return;
	}
	if (a[x-1]!=0)
	{
		a[x]=a[x-1]-1;
		dfs(x+1,n);
	}
	a[x]=a[x-1];
	dfs(x+1,n);
	if (a[x-1]!=9)
	{
		a[x]=a[x-1]+1;
		dfs(x+1,n);
	}
}
signed main()
{
	cnt=0;
	scanf("%d",&k);
	for (int i=1;i<=20;i++)
	{
		for (int j=1;j<=9;j++)
		{
			a[1]=j;
			dfs(2,i);
		}
		if (bl) break;
	}
	for (int i=0;i<(int)ans.size();i++)
	  printf("%d",ans[i]);
	printf("\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 100010;

int n, a[N << 1];

bool check(int x)
{
	int l = n, r = n;
	while (l > 1 && (a[l - 1] >= x) != (a[l] >= x)) --l;
	while (r < 2 * n - 1 && (a[r + 1] >= x) != (a[r] >= x)) ++r;
	if (n - l <= r - n) return a[l] >= x;
	return a[r] >= x;
}

int main()
{
	int l = 0x7fffffff, r = 0;
	
	scanf("%d", &n);
	
	for (int i = 1; i <= 2 * n - 1; ++i)
	{
		scanf("%d", a + i);
		l = min(l, a[i]);
		r = max(r, a[i]);
	}
	
	while (l < r)
	{
		int mid = (0ll + l + r + 1) >> 1;
		if (check(mid)) l = mid;
		else r = mid - 1;
	}
	
	cout << l;
	
	return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int n;
    cin>>n;
    int res=0;
    for (int i=1; i<=n; i++) {
	int x;
	cin>>x;
	if (i%2==1 && x%2==1) res++;
    }
    cout<<res<<endl;    
    return 0;
}


Measured memory_bytes: 3640
/*
* @Author: _dp95
* @Date:   2019-02-10 15:34:11
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

int a[ MAX ], b[ MAX ], c[ MAX ] ;
ll dp[ MAX ][ 3 ] ;

int main( ){
  timesaver ;
  int n ;
  cin >> n ;
  for( int i = 0 ; i < n ; i++ ){
    cin >> a[ i ] >> b[ i ] >> c[ i ] ;
  }
  dp[ 0 ][ 0 ] = a[ 0 ] ;
  dp[ 0 ][ 1 ] = b[ 0 ] ;
  dp[ 0 ][ 2 ] = c[ 0 ] ;
  for( int i = 1 ; i < n ; i++ ){
    dp[ i ][ 0 ] = a[ i ] + max( dp[ i - 1 ][ 1 ], dp[ i - 1 ][ 2 ] ) ;
    dp[ i ][ 1 ] = b[ i ] + max( dp[ i - 1 ][ 0 ], dp[ i - 1 ][ 2 ] ) ;
    dp[ i ][ 2 ] = c[ i ] + max( dp[ i - 1 ][ 0 ], dp[ i - 1 ][ 1 ] ) ;
  }
  cout << max( dp[ n - 1 ][ 0 ], max( dp[ n - 1 ][ 1 ] , dp[ n - 1 ][ 2 ] ) ) ;
  cout << nl ;
}

Measured memory_bytes: 12544
#include<bits/stdc++.h>
using namespace std;
int n, z, w, a[5000];

int main() {
    cin >> n >> z >> w;
    for(int i = 1; i <= n; i++) cin >> a[i];
    if (n == 1) cout << abs(a[1] - w) << endl;
    else cout << max(abs(a[n] - w), abs(a[n - 1] - a[n])) << endl;
}


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

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool same(int x, int y) { return root(x) == root(y); }

    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }

    int size(int x) { return -par[root(x)]; }
};

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

    UnionFind uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        uf.merge(a, b);
    }

    set<int> s;
    rep(i, n) s.insert(uf.root(i));

    cout << s.size() - 1 << endl;
    return 0;
}


Measured memory_bytes: 7640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll h,n,dp[20020];
	cin>>h>>n;
	vector<pair<ll,ll>>ab;
	for(ll i=0;i<=h;i++){
		dp[i]=INF;
	}
	dp[0]=0;
	for(ll i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		ab.push_back(make_pair(x,y));
	}
	sort(ab.begin(),ab.end());
	for(ll i=0;i<=h;i++){
		ll now=i;
		for(ll j=0;j<n;j++){
			ll next=ab[j].first;
			ll mp=ab[j].second;
			next=min(next+i,h);
			for(ll k=now;k<=next;k++){
				if(dp[k]>dp[i]+mp){
					dp[k]=dp[i]+mp;
				}
			}
			now=next;
		}
	}
	cout << dp[h];
	// your code goes here
	return 0;
}

Measured memory_bytes: 384
from collections import*
n,k,l=map(int,input().split());d=[-1]*n;t=[-1]*n
def f(l,x):
  if l[x]<0:return x
  else:l[x]=f(l,l[x]);return l[x]
def u(l,x,y):
  x,y=f(l,x),f(l,y)
  if x!=y:l[y]=x
for _ in range(k):a,b=map(int,input().split());u(d,a-1,b-1)
for _ in range(l):a,b=map(int,input().split());u(t,a-1,b-1)
p=[(f(d,i),f(t,i))for i in range(n)];c=Counter(p);print(*[c[p[i]]for i in range(n)])

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

int main(){
  int n; cin >> n;
  vector<double> a(n);
  for (auto && i : a) {
    double tmp;
    cin >> tmp;
    tmp = 1 / tmp;
    i = tmp;
  }
  double sum = 0;
  for (auto && i : a) {
    sum += i;
  }
  cout << fixed << setprecision(10) << 1 /sum << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  for (int i=0 ; i<W+2 ; i++){
    cout << "#";
  }
  cout << endl;
  for (int j=0; j<H ; j++){
    string pixel;
    cin >> pixel;
    cout << "#" << pixel << "#" << endl;
  }
  for (int k=0; k<W+2; k++){
    cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void swap(int a,int b)
{
    int tmp = a;
    a = b;
    b = tmp;
}

int gcd2(int a,int b)
{
    if (b > a){
        swap(a,b);
    }
    while (a%b != 0){
        int tmp = a;
        a = b;
        b = tmp%b;
    }
    return b;
}

int gcd3(int a,int b,int c)
{
    int n = gcd2(a,b);
    return gcd2(n,c);
}

int main()
{
    int k;
    scanf("%d",&k);
    int ans;
    ans = 0;
    for (int i = 1;i <= k;i++){
        for (int j = 1;j <= k;j++){
            for(int l = 1;l <= k;l++){
                ans += gcd3(i,j,l);
            }
        }
    }
    printf("%d\n",ans);
}



Measured memory_bytes: 1732
#include<stdio.h>
int main(){
	int x[100],j=0,i,k;
	while(i==0){
		j++;
		scanf("%d",&k);
		if(k==0){
			break;
		}
		x[j]=k;
		printf("Case %d: %d\n",j,x[j]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <math.h>

int isprime(int);

int main(){

  int i, n, input, primes = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &input);
    primes += isprime(input);
  }
  printf("%d\n", primes);

  return 0;
}

/*
  if(x == [prime number])
    return 1;
  else
    return 0;
*/

int isprime(int x){
  int sqrtx = sqrt(x);

  if(x == 2)
    return 1;
  if(x < 2 || x % 2 == 0)
    return 0;

  int i = 3;
  while( i <= sqrtx){
    if(x % i == 0)
      return 0;
    i += 2;
  }
  return 1;
}

Measured memory_bytes: 596
n,Y = map(int,input().split())
for z in range(n+1):
    for y in range(n-z+1):
        if 0<=n-z-y<=2000 and (n-z-y)*10000+y*5000+z*1000==Y:
            print(n-z-y,y,z)
            exit()
else:
    print(-1,-1,-1)

Measured memory_bytes: 3060
#include <stdio.h>
 
int main (void) {
    int d, n, cnt = 1;
    scanf("%d %d", &d, &n);

    for ( int i = 0; i < d; i++ ) {
        cnt *= 100;
    }

    if ( n < 100 ) {
        printf("%d", n*cnt);
    } else {
        printf("%d", 101*cnt);
    }

    return 0;
}

Measured memory_bytes: 128
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n;
	cin>>n;
	n=n%10;
	if(n==3)cout<<"bon";else
	if(n==0||n==1||n==6||n==8)cout<<"pon";else
	cout<<"hon";
	return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
int main(){
int h,m,s;
scanf("%d",&s);
m=(s-s%60)/60;
h=(m-m%60)/60;
s=s%60;
m=m%60;
printf("%d",h);
printf(":");
printf("%d",m);
printf(":");
printf("%d\n",s);
return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main(){
  char s[100];
  char R='R';
  char L = 'L';
  char U='U';
  char D='D';
  fgets(s,100,stdin);
  int i;
  for(i=0;s[i]!='\0';i++){
    if(i%2==0){
      if(s[i]==L){
        printf("No");
        return 0;
      }
    }else{
      if(s[i]==R){
        printf("No");
        return 0;
      }
    }
  }
  printf("Yes");
  return 0;
}


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

const ll N = 1e6 + 10;
const ll mod = 1e9 + 7;

map<int, int> tot;

int mi_p[N];

ll binpow(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}

ll inv(ll x) {
	return binpow(x, mod - 2);
}

void init() {
	for (int i = 2; i < N; i++) {
		if (mi_p[i]) continue;
		for (int j = i; j < N; j += i)
			mi_p[j] = i;
	}
}

void update_tot(ll x) {
	while (x != 1) {
		int p = mi_p[x];
		int cnt = 0;
		while (x % p == 0) x /= p, ++cnt;
		tot[p] = max(tot[p], cnt);
	}
}

int main() {
	init();
	int n; cin >> n;
	int a[n] = {};
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		update_tot(a[i]);
	}
	ll L = 1;
	for (auto pr : tot) {
		L = L * binpow(pr.first, pr.second) % mod;
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans = (ans + L * inv(a[i])) % mod;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 8016
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

    int n;
	long long ans=0;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	for(int i=0; i<n; i++){
		if(n%2==0){
			if(i+1==n-1-i){
				ans+=a[n-1-i]-a[i];
				break;
			}else {
				ans+=2*(a[n-1-i]-a[i]);
			}
		}else {
			if(i+2==n-1-i){
				ans+=max(2*a[i+2]-a[i+1]-a[i],a[i+2]+a[i+1]-a[i]*2);
				break;
			}else {
				ans+=2*(a[n-1-i]-a[i]);
			}
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
n=gets.to_i
a=gets.split.map(&:to_i)

min = 0
max = 0
bit = Array.new(9, 0)

n.times do |i|
  if a[i]/400 < 9
    bit[a[i]/400] += 1
  else
    bit[8]+=1
  end
  
end

8.times do |i|
  min+=1 if bit[i]>0
end

min = 1 if min == 0 && bit[8] > 0

max = [min + bit[8], n].min

puts "#{min} #{max}"


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    string s; cin >> s;
    i64 K; cin >> K;
    const i64 N = s.length();

    set<string> ss;
    REP(i, N) {
        string a = "";
        REP(j, K) {
            if (i + j >= N) break;
            a += s[i + j];
            ss.insert(a);
        }
    }

    i64 k = 1;
    for (auto it = ss.begin(); it != ss.end(); it++, k++) {
        if (k == K) {
            cout << *it << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1664
N,M = map(int,input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]

dxy = []
for y in range(M) :
    for x in range(M) :
        dxy.append((x,y))
flag = 0
for y in range(N) :
    for x in range(N) :
        if A[y][x] == B[0][0] and flag == 0 :
            counter = 0
            for dx,dy in dxy :
                nx = x+dx
                ny = y+dy
                if (0 <= nx <= N-1) and (0 <= ny <= N-1) and flag == 0 :
                    if A[ny][nx] == B[dy][dx] :
                        counter += 1
                if counter == M**2 :
                    flag = 1
if flag == 1 :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 3188
x, y = map(int, input().split())
ans = 0

if x == 1:
  ans += 300000
elif x == 2:
  ans += 200000
elif x == 3:
  ans += 100000

if y == 1:
  ans += 300000
elif y == 2:
  ans += 200000
elif y == 3:
  ans += 100000

if x == 1 and y == 1:
  ans += 400000
  
  
print(ans)

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    vector<int> a(1000,0);
    int ans=0;
    for(int i=0;i<1000;i++){
        int t[3];
        int v=i;
        for(int k=0;k<3;k++){
            t[k]=v%10;
            v=v/10;
        }
        char t1=t[2]+'0',t2=t[1]+'0',t3=t[0]+'0';
        bool flag1=false, flag2=false;
        for(int k=0;k<S.size();k++){
            if(S[k]==t1) flag1 = true; 
            if(!flag1) continue;
            else{
                for(int l=k+1;l<S.size();l++){
                    if(S[l]==t2) flag2 = true;
                    if(!flag2) continue;
                    else{
                        for(int m=l+1;m<S.size();m++){
                            if(S[m]==t3) {
                                ans++;
                                break;
                            }
                        }
                    }
                    if(flag2) break;
                }
                if(flag1) break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>

int binarySearch(int key, int *a, int left, int right) {
    if (right < left) return 0;
    int mid = (left + right) / 2;
    if (a[mid] == key) return 1;
    else if (a[mid] > key) return binarySearch(key, a, left, mid-1);
    else return binarySearch(key, a, mid+1, right);
}

int main(void) {
    int n, q, i, T;
    int ans = 0;
    scanf("%d", &n);
    int A[n+1];

    for (i = 1; i <= n; i++) scanf("%d", &A[i]);

    scanf("%d", &q);

    for (i = 0; i < q; i++) {
        scanf("%d", &T);
        ans += binarySearch(T, A, 1, n);
    }
    printf("%d\n", ans);
}


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

int main()
{
	
	string a[10000];
	int t[100000];
  	int i,n;
	  
	  scanf("%d",&n);
	  for(i=0;i<n;i++){
	  	cin>>a[i]>>t[i];
	  } 
	  string x;
	  
	  cin>>x;
	
	for(i=0;i<n;i++){
		if(x==a[i]){
			break;
		}
	}
	int ans=0;
	for(int tt=i+1;tt<n;tt++){
		ans=ans+t[tt];
	}
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 384