akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int H, W;
int fld[1010][1010], sum[1001000], A[1001000], B[1001000], app[1001000], l[1001000], r[1001000];
bool flag;

signed main()
{
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        int a;
        cin >> a;
        A[a]++;
        app[a]++;
        l[a]++;
        if(A[a] > 1)flag = true;
        for(int j = 0; j < W; j++){
            fld[i][j] = a;
        }
    }
    for(int i = 0; i < W; i++){
        int a;
        cin >> a;
        B[a]++;
        app[a]++;
        r[a]++;
        if(B[a] > 1)flag = true;
        for(int j = 0; j < H; j++){
            fld[j][i] = min(fld[j][i], a);
            sum[fld[j][i]]++;
        }
    }
    if(flag){
        printf("0\n");
        return 0;
    }
    int ans = 1;
    /*for(int i = H * W; i > 0; i--){
        printf("sum[%lld] : %lld A:%lld B:%lld app : %lld\n", i, sum[i], A[i], B[i], app[i]);
    }*/
    for(int i = H * W - 1; i > 0; i--){
        sum[i] += sum[i + 1];
        A[i] += A[i + 1];
        B[i] += B[i + 1];
    }
    for(int i = H * W; i > 0; i--){
        //printf("sum[%lld] : %lld A:%lld B:%lld app : %lld\n", i, sum[i], A[i], B[i], app[i]);
        if(app[i] == 1){
            if(l[i] == 1){
                ans = ans * B[i] % mod;
            }
            else {
                ans = ans * A[i] % mod;
            }
        }
        else if(app[i] == 0){
            ans = ans * (sum[i] - (H * W - i)) % mod;
        }
        if(ans < 0){
            ans = 0;
        }
    }
    cout << ans << endl;




    return 0;
}
/*
3 3
9 8 6
9 8 4


*/




Measured memory_bytes: 38144
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		sc.close();

		if (A > B) {
			int tmp = A;
			A = B;
			B = tmp;
		}

		int ans;
		if (A == 1) {
			if (B == 2) {
				ans = 3;
			} else {
				ans = 2;
			}
		} else {
			ans = 1;
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 23124
def main():
    n, m = map(int, input().split())
    cs = []
    for _ in range(m):
        tmpl = list(map(int, input().split()))
        tmpl.pop(0)
        cs.append(set(tmpl))
    p = list(map(int, input().split()))

    r = 0
    for bit in range(1 << n):
        each_p = set()
        for i in range(n):
            mask = 1 << i
            if bit & mask:
                each_p.add(i+1)
        check = []
        for i2 in range(m):
            check.append(len(each_p.intersection(cs[i2])) % 2 == p[i2])
        r += all(check)
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)

int main (){
	long NN, KK;
	cin >> NN >> KK;
	long int full=0,half=0;	
	Rep(i,1,NN+1){
		if(i%KK==0) {full++;}
		if(i%KK == KK/2 && KK%2 == 0) {half++;}
	}
	if(KK%2==1) {half=0;}
	cout << full*full*full + half*half*half << endl;

	return 0;	
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    N = len(S)

    for w in range(N // 2 - 1, 0, -1):
        ok = True
        for i in range(w):
            if S[i] != S[i + w]:
                ok = False
                break
        if ok:
            print(2 * w)
            return

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61952
N, A, B, C, D = map(int, input().split())
S = input()
# import re
import sys
# print(S[min(A,B):max(C,D)-1], S[min(A,B):max(C,D)-1].count("##"))
# print(S[B:D-1], S[B:D-1].count("..."))
# print(S[A:C-1], S[A:C-1].count("..."))

if S[A:max(C,D)-1].count("##"):
    print("No")
    sys.exit()
if C > D:
    if not S[B-2:D+1].count("..."):
        # if not S[D-2] == "." and S[D] == ".":
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 3572
///Bismillahir Rahmanir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=2019;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

map<int,int>cnt;

 main()

{
    fast
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    int sum=0;
    int sz=s.size();
    int ten=1;
    cnt[0]++;
    for(int i=0;i<sz;i++)
    {
        int val=(ten*(s[i]-'0'))%mod;
        sum=(sum+val)%mod;
        cnt[sum]++;
      //  cout<<sum<<" ";
        ten=(ten*10)%mod;
    }
   // cout<<endl;
    int ses=0;
    for(auto x:cnt)
    {
        int p=x.si;
        int ans=(p*(p-1))/2;
        ses+=ans;
    }
    cout<<ses<<endl;
    return 0;
}


Measured memory_bytes: 3796
def main():
    from math import gcd
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    adb = dict()
    ans = 0
    mod = 10**9+7
    for a, b in ab:
        if a == b == 0:
            ans += 1
            continue
        if b != 0:
            g = gcd(a, b)
            a = a//g
            b = b//g
            if b < 0:
                a *= -1
                b *= -1
            if a == 0:
                b = 1
            adb[(a, b)] = adb.get((a, b), 0)+1
        else:
            adb[None] = adb.get(None, 0)+1
    ans2 = 1
    for i, j in adb.items():
        if i is None:
            k = (0, 1)
        elif i == (0, 1):
            k = None
        else:
            if i[0] < 0:
                k = (i[1], -i[0])
            else:
                k = (-i[1], i[0])
        if k not in adb:
            ans2 = ans2*pow(2, j, mod) % mod
        else:
            if i is None:
                continue
            if i[0] >= 0:
                ans2 = ans2*(pow(2, j, mod)+pow(2, adb[k], mod)-1) % mod
    ans2 = (ans2-1) % mod
    print((ans+ans2) % mod)


main()


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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
  cin >>a.at(i);
  }
  int ans=0;
  for(int j=0;j<100;j++){
    int count=0; 
      for(int i=0;i<n;i++){
          if(a.at(i)%2==0){
 		  a.at(i)=a.at(i)/2;
    	  count++;
          }
      }
    if(count<n){break;}
    if(count==n){ans++;}
  }
  
  cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int w[30];
	int n, n2;
	int a[30], b[30];
	int i, j;
	
	scanf("%d", &n);
	scanf("%d", &n2);
	
	for (i = 0; i < n2; i++){
		scanf("%d,%d", &a[i], &b[i]);
		a[i]--;
		b[i]--;
	}
	
	for (i = 0; i < n; i++){
		w[i] = i;
	}
	for (i = 0; i < n; i++){
		for (j = 0; j < n2; j++){
			if (w[i] == a[j]){
				w[i] = b[j];
			}
			else if (w[i] == b[j]){
				w[i] = a[j];
			}
		}
	}
	for (i = 0; i < n; i++){
		for (j = 0; j < n; j++){
			if (w[j] == i){
				printf("%d\n", j + 1);
			}
		}
	}
	
	return (0);
}

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

int main() {
int n,res=0,count=0;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
    cin>>a[i];
}
for(int i=0;i<n;i++){
    if(a[i]%2==0){
     count++;
}
}
for(int i=0;i<n;i++){
    if(a[i]%2==0){
        if(a[i]%3==0 || a[i]%5==0){
            res++;
        }
        
    }
}
if(res==count){
    cout<<"APPROVED"<<endl;
}
else
cout<<"DENIED"<<endl;

return 0;
}

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

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

    int x = atoi(n.c_str());
    int f_x = 0;
    for(int i=0;i<n.size();i++){
        f_x += n[i]-'0';
    }

    if(x%f_x == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;

bool ans = false;
bool rec(int num,vector<int> lst,ll sum){
    if(sum == num) return ans = true;
    if(lst.size() == 0) return false;
    int la = lst[lst.size()-1];
    lst.pop_back();
    if(!ans){
        rec(num,lst,sum+la);
        rec(num,lst,sum);
    }
    return ans;
}


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n;i++){
        cin >> h[i];
    }
    cin >> q;
    vector<int> lst(q);
    for(int i = 0; i < q;i++){
        cin >> lst[i];
    }
    reverse(ALL(h));
    for(int i = 0; i < q;i++){
        if(rec(lst[i],h,0)) cout << "yes" << endl;
        else cout << "no" << endl;
        ans = false;
    }
    

    return 0;
}


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

using namespace std;

template<typename T>
class DoublyLinkedList {
private:
    struct Node {
    public:
        T val;
        Node *prev;
        Node *next;
    };

    Node *dummy;

public:
    DoublyLinkedList() {
        dummy = new Node();
        dummy->prev = dummy;
        dummy->next = dummy;
    }

    void insert_head(T x) {
        Node *temp = dummy->next;
        dummy->next = new Node();
        dummy->next->val = x;
        dummy->next->prev = dummy;
        dummy->next->next = temp;
        temp->prev = dummy->next;
        return;
    }

    Node *search_node(T x) {
        Node *node = dummy->next;
        while (node != dummy && node->val != x) node = node->next;
        return node;
    }

    void delete_node(Node *node) {
        if (node != dummy) {
            node->prev->next = node->next;
            node->next->prev = node->prev;
            delete node;
        }

        return;
    }

    void delete_key(T x) {
        delete_node(search_node(x));
        return;
    }

    void delete_first() {
        delete_node(dummy->next);
        return;
    }

    void delete_last() {
        delete_node(dummy->prev);
        return;
    }

    void print() {
        Node *node = dummy->next;
        while (node != dummy) {
            cout << node->val << (node->next == dummy ? "\n" : " ");
            node = node->next;
        }

        return;
    }
};

int main() {
    ios::sync_with_stdio(false);
    uint32_t n;
    cin >> n;

    DoublyLinkedList<uint32_t> l;
    string cmd;
    uint32_t key;
    while (n--) {
        cin >> cmd;

        if (cmd == "insert") {
            cin >> key;
            l.insert_head(key);
        } else if (cmd == "delete") {
            cin >> key;
            l.delete_key(key);
        } else if (cmd == "deleteFirst") {
            l.delete_first();
        } else if (cmd == "deleteLast") {
            l.delete_last();
        }
    }

    l.print();

    return 0;
}

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

int solve(vector<int> v, vector<int> P)
{
    int ret = 0;
    while (v != P)
    {
        next_permutation(v.begin(), v.end());
        ret++;
    }
    return ret;
}
 
int main()
{
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    for (int i = 0; i < N; i++) cin >> P[i];
    for (int i = 0; i < N; i++) cin >> Q[i];
    vector<int> v(N);
    for (int i = 0; i < N; i++) v[i] = i + 1;
    cout << abs(solve(v, P) - solve(v, Q)) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n;
int a[100001],dp[100001][2][4];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int res=0;
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<=2;k++){
				if(j!=(a[i]+k)%2){
					dp[i+1][(a[i]+k)%2][k]=max(dp[i+1][(a[i]+k)%2][k],dp[i][j][k]+1);
					res=max(res,dp[i+1][(a[i]+k)%2][k]);
				}else{
					dp[i+1][(a[i]+k+1)%2][k+1]=max(dp[i+1][(a[i]+k+1)%2][k+1],dp[i][j][k]+1);
					if(k+1<3)res=max(res,dp[i+1][(a[i]+k+1)%2][k+1]);
				}
			}
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 4552
#include<stdio.h>
int main()
{
    long long int x,z,cnt=0,P=100,sum=0;
    scanf("%lld",&x);
    while(sum!=x)
    {
        sum = P+(P*.01);
        P = sum;
        cnt++;
        if(sum>=x)break;
    }
    printf("%lld\n",cnt);
    return 0;

}


Measured memory_bytes: 1732
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))

A = [input().rstrip() for _ in range(N)]
B = [input().rstrip() for _ in range(M)]

for h in range(N-M+1):
    for w in range(N-M+1):
        cutA = [ A[h+i][w:w+M] for i in range(M)]
        if cutA == B:
            print('Yes')
            exit()
        else:
            continue
        
print('No')


Measured memory_bytes: 9364
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <boost/range/algorithm.hpp>
#include <boost/integer/common_factor_rt.hpp>

using namespace std;

int r;
int main() {

    while (cin >> r) {
        cout << 3 * r * r << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		String s = scan.next();
		StringBuilder sb = new StringBuilder();
		for (char si : s.toCharArray()) {
			switch (si) {
			case 'B':
				if (sb.length() != 0) {
					sb.deleteCharAt(sb.length() - 1);
				}
				break;
			default:
				sb.append(si);
				break;
			}
		}
		System.out.println(sb.toString());
	}

}

Measured memory_bytes: 19796
#include <stdio.h>

typedef struct List {
	struct List *next;
	int id, parity;
} list;

int main()
{
	int i, N, u[100001], v[100001], w[100001];
	scanf("%d", &N);
	for (i = 1; i <= N - 1; i++) scanf("%d %d %d", &(u[i]), &(v[i]), &(w[i]));
	
	list *inc[100001] = {}, edge[200001];
	for (i = 1; i <= N - 1; i++) {
		edge[(i-1)*2].id = u[i];
		edge[(i-1)*2+1].id = v[i];
		edge[(i-1)*2].parity = w[i] % 2;
		edge[(i-1)*2+1].parity = w[i] % 2;
		edge[(i-1)*2].next = inc[v[i]];
		edge[(i-1)*2+1].next = inc[u[i]];
		inc[v[i]] = &(edge[(i-1)*2]);
		inc[u[i]] = &(edge[(i-1)*2+1]);
	}
	
	list *p, *head, *tail, vertex[100001] = {};
	vertex[1].id = 1;
	vertex[1].parity = 0;
	vertex[1].next = NULL;
	for (head = &(vertex[1]), tail = &(vertex[1]); head != NULL; head = head->next) {
		for (p = inc[head->id]; p != NULL; p = p->next) {
			if (vertex[p->id].id == 0) {
				vertex[p->id].id = p->id;
				vertex[p->id].parity = head->parity ^ p->parity;
				tail->next = &(vertex[p->id]);
				tail = tail->next;
			}
		}
	}
	
	for (i = 1; i <= N; i++) printf("%d\n", vertex[i].parity);
	fflush(stdout);
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double t = sc.nextInt();
		double a = sc.nextInt();
		double min = 1000_000_000;
		int min_index = 0;
		
		for(int i = 1; i <= n; i++) {
			double x = sc.nextInt();
			x = t - x*0.006;
			if(min > Math.abs(a - x)) {
				min = Math.abs(a - x);
				min_index = i;
			}
		}
		
		System.out.println(min_index);
		sc.close();

	}
}


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

ll INF = 1ll << 60;
string s1, s2;
ll dp[1010][1010];

int main(int argc, char **argv)
{
	cin >> s1 >> s2;

	for (ll i = 0; i < 1010; ++i) for (ll j = 0; j < 1010; ++j) dp[i][j] = INF;
	dp[0][0] = 0;
	for (ll i = 0; i <= s1.size(); ++i) dp[i][0] = i;
	for (ll i = 0; i <= s2.size(); ++i) dp[0][i] = i;
	
	for (ll i = 0; i < s1.size(); ++i)
	{
		for (ll j = 0; j < s2.size(); ++j)
		{
			dp[i+1][j+1] = min({dp[i+1][j+1], dp[i+1][j]+1, dp[i][j+1]+1});
			if (s1[i] == s2[j]) dp[i+1][j+1] = min({dp[i+1][j+1], dp[i][j]});
			else dp[i+1][j+1] = min({dp[i+1][j+1], dp[i][j]+1});
		}
	}
	std::cout << dp[s1.size()][s2.size()] << std::endl;
}



Measured memory_bytes: 11164
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

ll ext_gcd(ll a, ll b, ll&x, ll&y){
  if(b==0){
    x=1;y=0;return a;
  }
  ll q=a/b;
  ll g=ext_gcd(b,a-q*b,x,y);
  ll z=x-q*y;
  x=y;y=z;
  return g;
}

// aは割る言、mがmod
ll invmod(ll a, ll m){
  ll x,y;
  ext_gcd(a,m,x,y);
  x%=m;
  if(x<0)x+=m;
  return x;
}

ll mod_comb(ll n, ll r, ll mod){
  ll ans = 1;
  FOR(i,0,r){
    ans = ans*(n-i)%mod;
    ans = ans*invmod(i+1,mod)%mod;
  }
  return ans%mod;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    n -= k;
    ll MOD = 1e9+7;
    FOR(i,1,k+1){
      ll x = mod_comb(n+1,i,MOD);
      ll y = mod_comb(k-1,i-1,MOD);
//      cout<<x<<" "<<y<<endl;
      cout<<x*y%MOD<<endl;
    }
}


Measured memory_bytes: 256
///বিসমিল্লাহির_রহমানির_রহীম
#include<bits/stdc++.h>
#define     pie                          acos(-1.0)
#define     N                            2000015
#define     eps                          1e-9
#define     ff                           first
#define     ss                           second
#define     nl                           '\n'
#define     mod                          1000000007
#define     sp                           ' '
#define     CLR(a)                       memset(a,0,sizeof(a))
#define     SET(a)                       memset(a,-1,sizeof(a))
#define     all(x)                       x.begin(),x.end()
#define     allr(x)                      x.rbegin(),x.rend()
#define     sz(x)                        (int)(x).size()
#define     Fast_Read                    ios_base::sync_with_stdio(false); cin.tie(nullptr);  cout.tie(nullptr);
#define     Precision(x)                 cout.setf(ios::fixed); cout.precision(x);
#define     bug                          cout<<"debug"<<nl;
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%lld",&aaa);return aaa;}
inline double dxt(){double aaa;scanf("%lf",&aaa);return aaa;}
#ifdef obaydullah
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************
void solve(){
    int n=nxt();
    double ans=0.0;
    for(int i=0;i<n;i++){
        double in=dxt();
        ans+=(1.0/in);
    }
    cout<<(1.0)/ans<<nl;
}
int main(){
    //Fast_Read
    Precision(10)
    #ifdef obaydullah
        double start_time = clock();
        ///freopen ("output.txt","w",stdout);
        ///freopen ("input.txt","r",stdin);
    #endif
    int tc=1;
    ///cin>>tc;
    while(tc--){
      solve();
    }
    #ifdef obaydullah
        double end_time = clock();
        cerr<<"Time = "<<fixed<<setprecision(10)<<(end_time - start_time) / CLOCKS_PER_SEC<<'\n';
    #endif

    return 0;
}


Measured memory_bytes: 256
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
Q = [int(input()) for _ in range(N)]

for q in Q:
    for i in range(3):
        for j in range(3):
            if A[i][j] == q:
                A[i][j] = 0

if A[0][0] == A[1][1] == A[2][2] == 0:
    print('Yes')
    exit()

if A[0][2] == A[1][1] == A[2][0] == 0:
    print('Yes')
    exit()

for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == 0:
        print('Yes')
        exit()

    if A[0][i] == A[1][i] == A[2][i] == 0:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 9152
#include <iostream>
#include <queue>
#include <string>

using namespace std;

void ope(queue<int>& que, int& A) {
    if (que.front() == A) {
        que.front() = 1 - que.front();
    } else {
        que.push(que.front());
        que.pop();
        A = 1 - A;
    }
}

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

    queue<int> que;
    for (char c : S) que.push(c - 'A');
    int A = 0;  // 今どっちの文字がAか
    int q;
    for (q = 0; q < min(N * 2, K); ++q) ope(que, A);

    // Nが偶数ならBABA...BAをループ
    // Nが奇数ならABAB...BA <-> BBAB...BAをループ
    if (q < K && N % 2 == 1 && (K - q) % 2 == 1) ope(que, A);

    while (!que.empty()) {
        cout << (que.front() == A ? 'A' : 'B');
        que.pop();
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1540
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
    int n,a[1000];
    while(1){
        cin>>n;
        if(n==0)break;
    
    for(int i=0;i<n;i++)
    cin>>a[i];
    int s=0;
     for(int i=0;i<n;i++)
    s +=a[i];
    double v=1.0*s/n;
    double b=0.0;
    for(int i=0;i<n;i++){
    b+=(v-a[i])*(v-a[i]);
    }
    printf("%lf\n",sqrt(b/n));
    
}
return 0;
}


Measured memory_bytes: 3208
S = input()

if int(S[0:2])<=12 and int(S[0:2])!=0:
    if int(S[2:4])<=12 and int(S[2:4])!=0:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if int(S[2:4])<=12 and int(S[2:4])!=0:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int a,b,c,f=0,t=0;
	cin>>a>>b;
	set<int>s[100];
	r(i,b){
		cin>>c>>f;
		s[c].insert(t);
		s[f].insert(t++);
	}
	r(i,a)cout<<s[i+1].size()<<endl;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define N 2016
lint mo=1000000007;
lint dp[4100][4100];
int a[252521],b[252521];
vector<lint> zyo,rz;
lint extgcd(lint a, lint b, lint &x, lint &y) {
  lint g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
lint invMod(lint a, lint m) {
  lint x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0;
}
int main()
{
	int n;lint out=0;
	memset(dp,0,sizeof(dp));
	scanf("%d",&n);
	rep(i,n){
		scanf("%d %d",&a[i],&b[i]);
		//dp[N+a[i]][N+b[i]]++;
		dp[N-a[i]][N-b[i]]++;
	}
	rep(i,N*2+10) rep(j,N*2+10){
		//if(dp[i][j]>=mo) dp[i][j]-=mo;
		dp[i][j]%=mo;
		dp[i+1][j]+=dp[i][j];dp[i][j+1]+=dp[i][j];
	}
	
	zyo.pb(1);rep(i,8200) zyo.pb((zyo[i]*(i+1))%mo);
	rep(i,zyo.size()) rz.pb(invMod(zyo[i],mo));
	rep(i,n){
		out+=dp[N+a[i]][N+b[i]];
		out-=(zyo[a[i]*2+b[i]*2]*rz[a[i]*2]%mo)*rz[b[i]*2]%mo;
		out%=mo;if(out<0) out+=mo;
	}
	//cout<<out<<endl;
	out*=invMod(2,mo);out%=mo;if(out<0) out+=mo;out%=mo;
	cout<<out<<endl;
}


Measured memory_bytes: 133504
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Thu May 10 21:06:51 2018
//
package main

import (
	"fmt"
)

var N, K int
var arr []int64

func max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func main() {
	fmt.Scan(&N, &K)

	arr = make([]int64, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	acc := make([]int64, N+1)
	acc2 := make([]int64, N+1)
	for i := range arr {
		acc[i+1] = acc[i] + arr[i]
		acc2[i+1] = acc2[i] + max(0, arr[i])
	}

	ans := int64(0)
	for i := 1; i+K-1 < len(acc); i++ {
		val := max(0, acc[i+K-1]-acc[i-1])
		if i > 0 {
			val += acc2[i-1] - acc2[0]
		}
		val += acc2[len(acc2)-1] - acc2[i+K-1]
		ans = max(ans, val)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include <iostream>

using namespace std;
static const int MAX=100;
static const int INF=1<<21;

int p[MAX]; //????°???????????????????????????¶??????
int d[MAX]; //??????????¨??????????????????????????????????????????????
int M[MAX][MAX]; //u???v????????????
bool visited[MAX]; //??????????¢??????\

int prim(int n)
{
    //init
    for(int i=0;i<n;i++)
    {
        p[i]=-1;
        visited[i]=false;
        d[i]=INF; //????§???????????????????d?????????????????§
    }

    d[0]=0; //?¬¬0?????????d?????´??°
    while(true)
    {
        //??????d???????°????????????\??????
        int min=INF;
        int min_point=-1;
        for(int i=0;i<n;i++)
        {
            if(d[i]<min&&visited[i]==false)
            {
                min_point=i;
                min=d[i];
            }
        }
        if(min==INF) break;
        visited[min_point]=true;
        //??´??°???????????°?????\????????????????????????d???
        for(int i=0;i<n;i++)
        {
            if(M[min_point][i]!=INF&&visited[i]==false)
                if(d[i]>M[min_point][i])
                {
                    d[i] = M[min_point][i]; //??????d????????§????°±????????´??°
                    p[i]=min_point; //??????
                }
        }
    }
    int sum=0;
    for(int i=0;i<n;i++)
        if(p[i]!=-1) //??????????°?????????????????????¶
           sum+=M[i][p[i]];
    return sum;
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>M[i][j];
            M[i][j]=(M[i][j]==-1?INF:M[i][j]);
        }
    }
    cout<<prim(n)<<endl;
}

Measured memory_bytes: 3092
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[8][9];
int dx[]={1,1,1,0,0,-1,-1,-1};
int dy[]={1,0,-1,1,-1,1,0,-1};
int main(){
	for(int i=0;i<8;i++)scanf("%s",str[i]);
	bool ok=false;
	do{
		ok=false;
		int t=0;
		int row=0;
		int col=0;
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				if(str[i][j]=='.'){
					int m=0;
					for(int k=0;k<8;k++){
						int n=0;
						int R=i+dx[k];
						int C=j+dy[k];
						while(0<=R&&R<8&&0<=C&&C<8){
							if(str[R][C]=='x')n++;
							if(str[R][C]=='o'){
								m+=n;
								break;
							}
							if(str[R][C]=='.')break;
							R+=dx[k];
							C+=dy[k];
						}
					}
					if(m>t){
						t=m;
						row=i;
						col=j;
					}
				}
			}
		}
		if(t){
			str[row][col]='o';
			ok=true;
			for(int k=0;k<8;k++){
				bool B=false;
				int R=row+dx[k];
				int C=col+dy[k];
				while(0<=R&&R<8&&0<=C&&C<8){
					if(str[R][C]=='o'){
						B=true;
						break;
					}
					if(str[R][C]=='.')break;
					R+=dx[k];
					C+=dy[k];
				}
				if(!B)continue;
				R=row+dx[k];
				C=col+dy[k];
				while(str[R][C]=='x'){
					str[R][C]='o';
					R+=dx[k];
					C+=dy[k];
				}
			}
//			printf("%d %d %d o\n",row,col,t);
//	for(int i=0;i<8;i++)printf("%s\n",str[i]);
		}
		t=0;
		row=0;
		col=0;
		for(int i=7;i>=0;i--){
			for(int j=7;j>=0;j--){
				if(str[i][j]=='.'){
					int m=0;
					for(int k=0;k<8;k++){
						int n=0;
						int R=i+dx[k];
						int C=j+dy[k];
						while(0<=R&&R<8&&0<=C&&C<8){
							if(str[R][C]=='o')n++;
							if(str[R][C]=='x'){
								m+=n;
								break;
							}
							if(str[R][C]=='.')break;
							R+=dx[k];
							C+=dy[k];
						}
					}
					if(m>t){
						t=m;
						row=i;
						col=j;
					}
				}
			}
		}
		if(t){
			str[row][col]='x';
			ok=true;
			for(int k=0;k<8;k++){
				bool B=false;
				int R=row+dx[k];
				int C=col+dy[k];
				while(0<=R&&R<8&&0<=C&&C<8){
					if(str[R][C]=='x'){
						B=true;
						break;
					}
					if(str[R][C]=='.')break;
					R+=dx[k];
					C+=dy[k];
				}
				if(!B)continue;
				R=row+dx[k];
				C=col+dy[k];
				while(str[R][C]=='o'){
					str[R][C]='x';
					R+=dx[k];
					C+=dy[k];
				}
			}
//			printf("%d %d %d x\n",row,col,t);
//	for(int i=0;i<8;i++)printf("%s\n",str[i]);
		}
	}while(ok);
	for(int i=0;i<8;i++)printf("%s\n",str[i]);
}

Measured memory_bytes: 948
sx, sy, tx, ty = gets.split.map(&:to_i)
up    = "U" * (ty - sy)
right = "R" * (tx - sx)
down  = "D" * (ty - sy)
left  = "L" * (tx - sx)
a  = up + right
a += down + left
a += "LU#{up}#{right}RD"
a += "RD#{down}#{left}LU"
puts a


Measured memory_bytes: 1788
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<min(a,b)+min(c,d)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int N, M, MX, PT, i, j;
    char temp[11], s[100][11], t[100][11];
    scanf("%d", &N);
    for(i = 0; i < N; i++){
        scanf("%s", s[i]);
    }
    scanf("%d", &M);
    for(i = 0; i < M; i++){
        scanf("%s", t[i]);
    }
    
    MX = 0;
    for(i = 0; i < N; i++){
        PT = 0;
        strcpy(temp, s[i]);
        for(j = 0; j < N; j++){
            if(strcmp(temp, s[j]) == 0) PT++;
        }
        for(j = 0; j < M; j++){
            if(strcmp(temp, t[j]) == 0) PT--;
        }
        if(PT > MX) MX = PT;
    }

    printf("%d\n", MX);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k,d,c;
    cin >> n >> k;
    d=n-k;
    if(d<0)
        d=0-d;
    if(d<n)
    {
        c=n%k;
        d=c-k;
        if(d<0)
            d=0-d;
        if(d>=c)
            cout << c << endl;
        else
            cout << d << endl;
    }
    else
    {
        cout << n << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
x=[0 for i in range(n)]
y=[]
s=0
for i in range(n):
  x[a[i]-1]+=1
    
for i in range(n):
  if x[i]:
    y.append(x[i])
y.sort()
z=len(y)
i=0
while(z>k):
  s+=y[i]
  z-=1
  i+=1
print(s)

Measured memory_bytes: 32196
#include <bits/stdc++.h>
using namespace std;
const int mod = 1'000'000'007, maxn = 70000, maxk = 101;
int mul(long long a, long long b){
	return a * b % mod;
}
vector<pair<int,int> > opt;
int f[maxk][maxn];
int main(){
	int n, k; cin >> n >> k;
	set<tuple<int,int,int>> can;
	vector<int> split_at;
	for(int i = 1; i <= n; ){
		int lo = i + 1, hi = n, ans = i;
		int desire = n / i;
		while(lo <= hi){
			int mid = (lo+hi)>>1;
			if(n / mid == desire) ans = mid, lo = mid + 1;
			else hi = mid - 1;
		}
		can.insert(make_tuple(i, ans, desire));
		split_at.push_back(desire);
		i = ans + 1;
	}
	for(int v : split_at){
		auto it = can.lower_bound(make_tuple(v + 1, -1, -1));
		if(it != can.begin()){
			it--;
			int x, y, z; tie(x, y, z) = *it;
			if(y != v){
				can.erase(it);
				can.insert(make_tuple(x, v, z));
				can.insert(make_tuple(v + 1, y, z));
			}	
		}
	}
	vector<tuple<int,int,int> > conv;
	for(auto e : can) conv.push_back(e);
	for(int i = 0; i < conv.size(); i++){
		int x, y, z; tie(x, y, z) = conv[i];
		int pt = lower_bound(conv.begin(), conv.end(), make_tuple(z + 1, -1, -1)) - conv.begin(); pt--;
		if(get<1>(conv[pt]) != z){
			cout << get<1>(conv[pt]) << " " << pt << " " << z << endl;
		}
		assert(y - x + 1 >= 1);
		assert(get<1>(conv[pt]) == z);
		opt.push_back({y - x + 1, pt});
	}
	int len = opt.size();
	for(int i = 0; i < len; i++) f[0][i] = 1;
	for(int i = 1; i <= k; i++){
		for(int j = 0; j < len; j++){
			if(j) f[i][j] = f[i][j - 1];
			f[i][j] += mul(opt[j].first, f[i - 1][opt[j].second]);
			if(f[i][j] >= mod) f[i][j] -= mod;
		}
	}	
	cout << f[k][len - 1] << endl;
	return 0;
}


Measured memory_bytes: 33524
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<int,int>
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second

int main()
{   fastio ;
    int n,i,k,j ;
    cin>>n>>k ;
    int a[n] ;
    for (i = 0; i < n; ++i)
    {
    	cin>>a[i] ;
    }
    int dp[n] ;
    for (i = 0; i < n; ++i)
    {
    	dp[i]=INT_MAX ;
    }
    dp[0]=0 ;
    dp[1]=abs(a[1]-a[0]) ;
    for (i = 2; i < n; ++i)
    {   for (j = 1; j <=k ; ++j)
        {   if(i-j<0) break ;
            else dp[i]=min(dp[i],abs(a[i]-a[i-j])+dp[i-j]) ;  
        }
    	
    }
    cout<<dp[n-1]<<"\n" ;
    return 0;
}    

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=0;
    ll m=0;
    cin>>n>>m;
    if(n==1||m==1)
    {
    	cout<<1<<"\n";
    	return 0;
    }
    if((n*m)%2==0)
    {
    	cout<<(n*m)/2<<"\n";
    }
    else
    {
    	cout<<((n*m)/2)+1<<"\n";
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi					3.14159265359
ll INF=1e18+10;
ll MOD=1000000007;

int main()
{
    int n;cin>>n;
    ll a[n];rep(i,0,n)cin>>a[i];
    ll ans=0;
    rep(i,0,n)
    {
        rep(j,0,i)
        ans+=(a[i]*a[j]);
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <bits/stl_numeric.h>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


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

    int w[N],v[N];
    REP(i,N)
    {
        cin >> w[i] >> v[i];
    }

    ll dp[N+1][W+1] = {};
    //dp[i][j]: dp[i-1][j-w[i-1]] + v[i-1]
    
    REP(i,N+1)
    {
        REP(j,3)
        {
            dp[i][j] = 0;
        }
    }

    for(int i = 1; i <= N; ++i)
    {
        for(int j = 0; j <= W; ++j)
        {
            if(j < w[i-1])
            {
                dp[i][j] = dp[i-1][j];
            }
            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
            }
        }
    }

#if DEBUG
    for(int i = 0; i <= N; ++i)
    {
        cout << dp[i][W] << endl;
    }
#endif

    ll res = 0;
    res = dp[N][W];

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 79104
s1 = input()
s2 = input()
list_s1 = list(s1)
list_s2 = list(s2)
len_s1 = len(s1)
len_s2 = len(s2)
change_count_min = len_s2
for i in range(len_s1 - len_s2 + 1):
    change_count = len_s2
    for j in range(len_s2):
        if list_s1[j+i] == list_s2[j]:
            change_count -= 1
    if change_count < change_count_min:
        change_count_min = change_count
print(change_count_min)

Measured memory_bytes: 8948
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){ 
   ll a,b;
   cin>>a>>b;
   vector<int> tou(1000);
   ll sum=0;
   tou[0]=0;
   for(int i=1;i<=999;i++){
      sum+=i;
      tou[i]=sum;
   }
   for(ll x=1;x<=sum;x++){
      if(tou[b-a]-x==b){
         cout<<x;
         break;
      }
   }

   
   return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] x = new int[n];
	int[] y = new int[n];
	for (int i=0; i<n; i++) {
	    x[i] = sc.nextInt();
	    y[i] = sc.nextInt();
	}
	double sum = 0;
	for (int i=0; i<n; i++) {
	    for (int j=i+1; j<n; j++) {
		sum += Math.sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
	    }
	}
	if (n%2 == 0) {
	    System.out.print(sum / (n/2));
	} else {
	    System.out.print(sum / (n/2 + 0.5));
	}
    }
}


Measured memory_bytes: 35780
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Objects;

public class Main {
	
public static void main(String[] args) {
	InputStream inputStream = System.in;
	OutputStream outputStream = System.out;
	FastInput in = new FastInput(inputStream);
	PrintWriter out = new PrintWriter(outputStream);
	ABC178E solver = new ABC178E();
	solver.solve(1, in, out);
	out.close();
}

static class ABC178E {

	public void solve(int testNum, FastInput in, PrintWriter out) {
		
		int n = in.nextInt();
	
		int []x = new int [n];
		int []y = new int [n];
		
		for(int i = 0 ; i < n ;i++) {
			x[i] = in.nextInt();
			y[i] = in.nextInt();
		}
		
		int []x1 = new int [n];
		int []y1 = new int [n];
		
		
		for(int i = 0 ; i < n ; i++) {
			x1[i] = x[i] + y[i];
			y1[i] = x[i] - y[i];
		}
		
		Arrays.sort(x1);
		Arrays.sort(y1);
		
		
		int ans = Math.max(x1[n-1] - x1[0], y1[n-1] - y1[0]);
		out.println(ans);
		
			
		}
	}
static class FastInput{
	private final BufferedReader in;
	private String[] buff;
	private int index = 0;
	
	public FastInput(InputStream is) {
		in = new BufferedReader(new InputStreamReader(is));
	}
	String nextLine() {
		try {
			return in.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	String next() {
		while (buff == null || index >= buff.length) {
			buff = nextLine().split(" ");
			index = 0;
		}
		return buff[index++];
	}
	int nextInt() {
		return Integer.parseInt(next());
	}
	
	long nextLong() {
		return Long.parseLong(next());
	}
	
	Double nextDouble() {
		return Double.parseDouble(next());
	}
	
	BigInteger nextBigInteger() {
		return new BigInteger(next());
	}
	
	BigDecimal nextBigDecimal() {
		return new BigDecimal(next());
	}
	
	public int[] nextIntArray(final int n) {
		final int[] res = new int [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextInt();
		}
		return res;
	}
	
	public long[] nextLongArray(final int n) {
		final long[] res= new long [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextLong();
		}
		return res;
	}
	
	public double[] nextDoubleArray(final int n ) {
		final double[] res = new double [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextDouble();
		}
		return res;
	}
	
	
	public int[][] nextInt2DArray(final int n , final int m){
		int [][]res = new int [n][m];
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j < m ;j++) {
				res[i][j] = nextInt();
			}
		}
		return res;
	}
	public long[][] nextLong2DArray(final int n , final int m){
		long [][]res = new long [n][m];
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j < m ;j++) {
				res[i][j] = nextLong();
			}
		}
		return res;
	}
	
	public char[][] nextChar2DArray(final int n){
		char [][]res = new char [n][];
		
		for(int i = 0 ; i < n ;i++) {
			String s = next();
			res[i] = s.toCharArray();
		}
		
		return res;
	}
}

}


Measured memory_bytes: 59524
#include <stdio.h>
int main(void){
    // Your code here!
    int N, count = 1;
    char s[100001];
    scanf("%d", &N);
    scanf("%s", s);
    
    for(int i = 1; i < N; i++)
    {
        if(s[i] != s[i-1])
            count++;
    }
    
    printf("%d\n", count);
}


Measured memory_bytes: 256
a = gets.chomp
b = gets.chomp
c = gets.chomp
d = gets.chomp
e = gets.chomp
sum = 0
array = [a,b,c,d,e]
s = []
flag = false
array.each do |i|
  if i[-1].to_i != 0
    sum += i.to_i + 10 - i[-1].to_i 
    flag = false
  else
    sum += i.to_i 
    flag = true
  end
end 
min = 10
array.each do |i|
  min = i[-1].to_i if min > i[-1].to_i && i[-1].to_i != 0
end
min = 0 if array.all?{|i| i[-1].to_i == 0 }
puts flag ? sum - min : sum - 10 + min

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

string toUpper(string s){
    string t = s;
    for (int i = 0; i < s.size(); i++){
        t[i] = toupper(s[i]);
    }
    return t;
}

int main(){
    string target, source;

    cin >> target;
    target = toUpper(target);

    int cnt = 0;

    while(1){
        cin >> source;
        if( source == "END_OF_TEXT") break;
        source = toUpper(source);
        if( target == source ) cnt++;

    }

    cout << cnt << endl;

}



Measured memory_bytes: 3192
N, D = [int(i) for i in input().split()]
X=[]
ans=0
for j in range(N):
    X.append([int(i) for i in input().split()])

for i in range(N):
    for j in range(i+1,N):
        y=X[i]
        z=X[j]
        tmp=0
        for k in range(D):
            tmp += (y[k]-z[k])**2
        tmp2 = tmp ** 0.5
        if tmp2.is_integer():
            ans+=1   
         
print(ans)

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

const int MAX_N = 10010;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> Array;
typedef vector<Array> Graph;
typedef pair<double, double> pdd;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

const int CODE_MAX = 362880;
const int SIZE = 9;
int visited[CODE_MAX];

int factorial(int n){
    if(n==1) return 1;
    return n*factorial(n-1);
};

struct Board{
    int num[SIZE];
    void print(){
        for(int i=0;i<SIZE;i++) cout << num[i] << " ";
        cout << endl;
    }
};

int encode(Board &b){
    int res = 0;
    int temp_b[SIZE];
    for(int i=0;i<SIZE;i++) temp_b[i] = b.num[i];
    for(int i=0;i<SIZE-1;i++){
        res += factorial(SIZE-1-i)*temp_b[i];
        for(int j=i+1;j<SIZE-1;j++){
            if(temp_b[i]<temp_b[j]) temp_b[j]--;
        }
    }
   return res;
}

Board decode(int encoded){
    Board b;
    int tmp[SIZE];
    for(int i=0;i<SIZE-1;i++){
        int fact = factorial(SIZE-1-i);
        tmp[i] = encoded/fact;
        encoded %= fact;
    }
    tmp[SIZE-1] = 0;
    int tmp2[SIZE];
    bool check[SIZE];
    for(int i=0;i<SIZE;i++){
        tmp2[i] = i;
        check[i] = false;
    }
    for(int i=0;i<SIZE;i++){
        int j=0;
        while(tmp[i]!=tmp2[j] || check[j]) j++;
        b.num[i] = j;
        check[j] = true;
        while(j<SIZE){
            tmp2[j]--;
            j++;
        }
    }

    return b;
}

int get_adjacent(int now, int i){
    // "i" represents the direction of zero movement.0 up, 1 down, 2 left, 3 right
    Board b = decode(now);
    int zero=0;
    while(b.num[zero]!=0) zero++;
    if(i==0){
        if(zero<3) return -1;
        swap(b.num[zero], b.num[zero-3]);
    }
    if(i==1){
        if(zero>5) return -1;
        swap(b.num[zero], b.num[zero+3]);
    }
    if(i==2){
        if(zero%3<1) return -1;
        swap(b.num[zero], b.num[zero-1]);
    }
    if(i==3){
        if(zero%3>1) return -1;
        swap(b.num[zero], b.num[zero+1]);
    }
    return encode(b);
}

int main(){
    Board b;
    for (int i=0;i<SIZE;i++){
        cin >> b.num[i];
    }
    for(int i=0;i<CODE_MAX;i++){
        visited[i] = -1;
    }

    const int start = encode(b);
    const int goal = 46233;
    queue<int> que;
    que.push(start);
    visited[start] = 0;
    while(visited[goal]==-1){
        int now = que.front();
        que.pop();
        for(int i=0;i<4;i++){
            int adj = get_adjacent(now, i);
            if(adj==-1 || visited[adj]!=-1) continue;
            visited[adj] = visited[now]+1;
            que.push(adj);
        }
    }
    cout << visited[goal] << endl;
    return 0;
}

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

using Lint=long long;
const int LEN=60;
const int mod=1e9+7;

int main()
{
   int N; cin>>N;
   vector<Lint> a(N);
   for(int i=0;i<N;i++) cin>>a[i];

   int ans=0;
   vector<vector<int>> cnt(LEN,vector<int>(2));
   for(int i=0;i<N;i++){
      for(int j=0;j<LEN;j++){
         int b=a[i]>>j&1;
         ans+=(1LL<<j)%mod*cnt[j][b^1]%mod;
         ans%=mod;
         cnt[j][b]++;
      }
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;

int main(){
    string S;
    cin >> S;
    ll out = 0;
    ll N = S.size();

    for (int bit = 0; bit < (1 << (N-1)); bit++){
      ll tmp = 0;
      for (int i = 0; i < N - 1; i++){
        tmp *= 10;
        tmp += S[i] - '0';
        if(bit & (1<<i)){
          out += tmp;
          tmp = 0;
        }
      }
      tmp *= 10;
      tmp += S.back() - '0';
      out += tmp;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3548
def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = []
    R = []

    for i in range(n1):
        L.append(A[left+i])
    for i in range(n2):
        R.append(A[mid+i])

    L.append(10**9)
    R.append(10**9)

    i = 0
    j = 0

    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            j = j + 1
    return right - left

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right)//2
        return mergeSort(A, left, mid) + mergeSort(A, mid, right) + merge(A, left, mid, right)
    else:
        return 0

n = int(input())
X = list(map(int, input().split()))
x = mergeSort(X, 0, n)

print(" ".join(map(str, X)))
print(x)


Measured memory_bytes: 66720