akhauriyash/Code-Regression huggingface dataset:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    n = int(input())
    s = input()
    w = s.count(".")
    b = n - w
    ans = min(w, b)
    b = 0
    for i in range(n):
        if s[i] == ".":
            w -= 1
        else:
            b += 1
        ans = min(ans, w + b)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9372
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		int n = sc.nextInt();
		double sum = 0;
		for(int i =0 ; i < n ; i++) {
			sum += 1.0/sc.nextDouble();
		}
		System.out.println(1/sum);
	}
}


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

# 遅延評価で加えてあげるだけ

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x
    
q = [(1,0)]
while q:
    x,parent = q.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        q.append((y,x))

answer = ' '.join(map(str,value[1:]))
print(answer)


Measured memory_bytes: 124236
import sys

import numpy as np

H,W = map(int,sys.stdin.buffer.readline().split())
purple = np.frombuffer(sys.stdin.buffer.read(),dtype='S1').reshape(H,-1)[:,:W].astype(str)

red = np.full((H,W),'.',dtype='U1')
blue = np.full((H,W),'.',dtype='U1')

red[:,::2] = '#'
red[-1] = '.'
red[0] = '#'
blue[:,1::2] = '#'
blue[-1] = '#'
blue[0] = '.'

is_purple = purple == '#'
red[is_purple] = '#'
blue[is_purple] = '#'

print('\n'.join(''.join(row) for row in red))
print()
print('\n'.join(''.join(row) for row in blue))

Measured memory_bytes: 18692
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

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

    if (a % 2 == 0 && a == b && b == c) {
        cout << -1 << "\n";
        return 0;
    }

    int ans = 0;
    while (true) {
        if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) break;
        int A = (b + c) / 2;
        int B = (a + c) / 2;
        int C = (a + b) / 2;
        a = A; b = B; c = C;
        ans++;
    }

    cout << ans << "\n";
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> pii;

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

	ll N;
	cin >> N;

	string march = "MARCH";

	vector<ll> v(5, 0);

	rep(i, N){
		string S;
		cin >> S;

		rep(j, 5){
			if(S[0] == march[j]) v[j]++;
		}
	}

	ll ans = 0;
	for(int i = 0; i < 5; i++){
		for(int j = i + 1; j < 5; j++){
			for(int k = j + 1; k < 5; k++){
				ans += v[i] * v[j] * v[k];
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n,i,j,a,r,l,f;
	scanf("%d\n", &n);
	
	for(i=0;i<n;i++) {
		f = 0;
		for(j=0,r=0,l=0;j<10;j++) {
			scanf("%d", &a);
			if(f) continue;
			if(r > a && l > a) {
				printf("NO\n");
				f = 1;
			} else if(r <= l) {
				if(l < a) {
					l = a;
				} else if(r < a) {
					r = a;
				}
			} else if(l < r) {
				if(r < a) {
					r = a;
				} else if(l < a) {
					l = a;
				}
			}
		}
		
		if(!f) printf("YES\n");
	}
	
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

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

    int n, k;
    cin >> n >> k;

    int h[n];
    for (int i = 0; i < n; i++)
        cin >> h[i];
    
    vector <int> dp(n, 0);
    for (int i = 1; i < n; i++) {
        int mn = INT_MAX;
        for (int j = i - 1; j >= max(0, i - k); j--)
            mn = min(mn, dp[j] + abs(h[i] - h[j]));
        dp[i] = mn;
    }

    cout << dp.back() << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>

using namespace std;

int main(){
  int a,b,c;
  cin >> a>> b>> c;
  int d=b/a;
  if (d>=c) cout << c << endl;
  else cout << d << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>

int main(){
  int i;
  int d;
  int n;
  int min=INT_MAX,max=INT_MIN;
  long sum=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&d);
    if(d<min){
      min=d;
    }
    if(d>max){
      max=d;
    }
    sum+=d;
  }

  printf("%d %d %ld\n",min,max,sum);
  
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ll long long
#define pb push_back
#define PII pair<int,int>
#define X first
#define Y second
#define MP make_pair
#define PI acos(-1.0)
#define eps 1e-8
const int maxn=3e5+10;
const int mod=998244353;
using namespace std;

int a,b,c;

int main()
{
    scanf("%d%d%d",&a,&b,&c);
    printf("%d %d %d",c,a,b);
    // system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<iostream>
#include<vector>
#define lson k<<1
#define rson k<<1|1

using namespace std;
typedef long long ll;
typedef double db;

const int INFI = 1000000000;
const int N = 505;

char Matrix[N][N];

int main()
{
    int n;
    while(scanf("%d",&n)+1)
    {
        for(int i=0; i<n; i++) scanf("%s",Matrix[i]);
        bool has(false);
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++) if(Matrix[i][j]=='#') has=true;
        }
        int res(INFI);
        for(int i=0; i<n; i++)
        {
            int x(0);
            bool inv(false);
            for(int j=0; j<n; j++) if(Matrix[i][j]=='.')
                {
                    bool ok(false);
                    for(int k=0; k<n; k++) if(Matrix[k][i]=='#')
                        {
                            ok=true;
                            break;
                        }
                    if(ok||inv)
                    {
                        ++x;
                    }
                    else if(has)
                    {
                        inv=true;
                        x+=2;
                    }
                    else
                    {
                        x=INFI;
                        break;
                    }
                }
            if(x>=INFI) continue;
            int y(n);
            for(int j=0; j<n; j++) if(Matrix[i][j]=='#')
                {
                    bool ok(true);
                    for(int k=0; k<n; k++) if(Matrix[k][j]=='.')
                        {
                            ok=false;
                            break;
                        }
                    if(ok) y--;
                }
            res = min(res,x+y);
        }
        printf("%d\n",res==INFI?-1:res);
    }
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,a[100010];
int main(){
	n=read();
	int i,maxn=0,minn=n;
	for(i=1;i<=n;i++){
		a[i]=read();
		maxn=max(maxn,a[i]);
		minn=min(minn,a[i]);
	}
//	cout<<maxn<<' '<<minn<<' '<<a[1]<<' '<<a[2]<<' '<<a[3]<<'\n';
	if(maxn-minn>=2){
		puts("No");return 0;
	}
	if(maxn-minn==1){
		int cnt=0;
		for(i=1;i<=n;i++) if(a[i]==minn) cnt++;
		if(cnt<maxn&&(n-cnt)>=(maxn-cnt)*2) puts("Yes");
		else puts("No");
	}
	else{
		if(maxn*2<=n||maxn==n-1) puts("Yes");
		else puts("No");
	}
}

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

using namespace std;

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

	vector<int> from1;
	set<int> toN;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;

		if (a == 1) {
			from1.emplace_back(b);
		} else if (b == n) {
			toN.insert(a);
		}
	}

	bool ok = false;
	for (auto via : from1) {
		if (toN.count(via) > 0) {
			ok = true;
			break;
		}
	}

	cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}


Measured memory_bytes: 5368
# -*- coding: utf-8 -*-
#ARC087C
import sys
import math

n=int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

numlist={}

for i in range(0,n):
	if(hoge[i] in numlist):
		numlist[hoge[i]]+=1
	else:
		numlist[hoge[i]]=1

total=0

for i in numlist:
	if(i in numlist):
		#print("{} {}".format(i,numlist[i]))
		if(i>numlist[i]):
			total+=numlist[i]
		else:
			total+=numlist[i]-i


#print(hoge)
#print(numlist)
print(total)


Measured memory_bytes: 24436
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int m = sc.nextInt(), n = sc.nextInt();
		int k = sc.nextInt();
		int imos[][][] = new int[3][m+1][n+1];
		for (int i = 1; i <= m; i++) {
			char[] chars = sc.next().toCharArray();
			for(int j = 1; j <= n; j++) {
				imos[0][i][j] = imos[0][i-1][j] + imos[0][i][j-1] - imos[0][i-1][j-1];
				imos[1][i][j] = imos[1][i-1][j] + imos[1][i][j-1] - imos[1][i-1][j-1];
				imos[2][i][j] = imos[2][i-1][j] + imos[2][i][j-1] - imos[2][i-1][j-1];
				if(chars[j-1]=='J') {
					imos[0][i][j]++;
				} else if(chars[j-1]=='O') {
					imos[1][i][j]++;
				} else {
					imos[2][i][j]++;
				}
			}
		}
		for(int i = 0; i < k; i++) {
			int sx = sc.nextInt(),sy = sc.nextInt(),gx = sc.nextInt(), gy = sc.nextInt();
			System.out.print(imos[0][gx][gy]-imos[0][sx-1][gy]-imos[0][gx][sy-1]+imos[0][sx-1][sy-1]);
			System.out.print(" ");
			System.out.print(imos[1][gx][gy]-imos[1][sx-1][gy]-imos[1][gx][sy-1]+imos[1][sx-1][sy-1]);
			System.out.print(" ");
			System.out.print(imos[2][gx][gy]-imos[2][sx-1][gy]-imos[2][gx][sy-1]+imos[2][sx-1][sy-1]);
			System.out.println();
		}
	}
}


Measured memory_bytes: 184044
using System;
using System.Collections.Generic;
using System.Linq;
namespace KCLC
{
    class Program
    {
        static void Main()
        {
            string[] Input = Console.ReadLine().Split();
            double Kyori = double.Parse(Input[0]);
            int Jikan = int.Parse(Input[1]);
            double Hayasa = double.Parse(Input[2]);
            if(Kyori / Hayasa <= Jikan) { Console.WriteLine("Yes"); }
            if(Kyori / Hayasa > Jikan) { Console.WriteLine("No"); }
        }
    }
}

Measured memory_bytes: 27476
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_B() {}


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H, W; cin >> H >> W;
    vs a(H); REP(i, H) cin >> a[i];
    
    cout << string(W+2, '#') << endl;
    REP(i, H) cout << "#" + a[i] + "#" << endl;
    cout << string(W+2, '#') << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  std::string S;
  std::cin >> S;
  std::cout << (std::unordered_set<char>(S.begin(), S.end()).size() > 1 ? "Yes" : "No") << std::endl;
  return 0;
}

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

Measured memory_bytes: 592
import java.util.*;
public class Main {
   public static void main(String[] args) {  
      Scanner sc = new Scanner(System.in);
      
      HashMap<String, Integer> h = new HashMap<String, Integer>();
      
      h.put("SUN", 7);
      h.put("MON", 6);
      h.put("TUE", 5);
      h.put("WED", 4);
      h.put("THU", 3);
      h.put("FRI", 2);
      h.put("SAT", 1);
      
      System.out.println(h.get(sc.nextLine()));
   }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first 
#define se second
#define pi pair<ll,ll> 
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main(){ 
  #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s1,s2;
  cin>>s1>>s2;
  int n=s1.size();
  for(int i=0;i<n;i++){
  	if(s1[i]!=s2[i]){
  		cout<<"No"<<endl;
  		return 0;
  	}
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int A, B;
    string S;
    cin >> A >> B >> S;
    int l_cnt = 0, r_cnt = 0;
    
    bool flag = true;
    for(int i = 0; i < S.length(); i++){
        if(flag && S[i] != '-'){
            l_cnt++;
        }
        else if(flag && S[i] == '-'){
            flag = false;
        }
        else if((!flag) && S[i] != '-'){
            r_cnt++;
        }
    }
    
    if(l_cnt == A && r_cnt == B){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    int L, R, d, ans = 0;
    cin >> L >> R >> d;
    FOR(i, L, R + 1){
        if(i % d == 0) ans++;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,n) for(int i=0;i<n;++i)
#define repn(i,n) for(int i=1;i<=n;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll linf=1e18;
const int inf=1001001001;
const ll mod=1000000007; // 998244353 = (119<<23)+1
// head
ld n;
int k;
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>n>>k;
		ld prob=1.0/n;
		ld ans=0;
		repn(j,n) {
			ld i=(ld)j;
			ld count=0;
			while(i<k) {
				i*=2.0;
				count++;
			}
			ans+=prob*powl(0.5,count);
//			cout<<i<<' '<<count<<' '<<ans<<'\n';;
		}
		cout<<setprecision(20)<<ans;
		return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

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

	int X; cin >> X;

	if (X < 600) cout << 8;
	else if (X < 800) cout << 7;
	else if (X < 1000) cout << 6;
	else if (X < 1200) cout << 5;
	else if (X < 1400) cout << 4;
	else if (X < 1600) cout << 3;
	else if (X < 1800) cout << 2;
	else if (X < 2000) cout << 1;

	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#define MAX 1000000
#define N 10100
using namespace std;

void eratos(int, bool*);

int main(){
  bool prime[MAX+1];
  int size;
  eratos(N,prime);
  int count=0;
  int data[1250];
  for(int i=0, j=0;i<N;i++){
    if(prime[i]){
      data[j]=i;
      j++;
    }
  }

  while(1){
    int n;
    cin >> n;
    if(n==0) break;
    int ans1, ans2;
    for(int i=1;i<1250;i++){
      if(data[i]>n) break;
      if((data[i]-data[i-1])==2){
	ans1=data[i-1];
	ans2=data[i];
      }
    }
    cout << ans1 << ' ' << ans2 << endl;
  }
  return 0;
}

void eratos(int n, bool prime[]){
  for(int i=0;i<=n;i++) prime[i]=false;
  for(int i=3;i<=n;i+=2) prime[i]=true;
  prime[2]=true;
  int limit=(int)sqrt((double)n)+1;
  for(int i=3;i<=limit;i+=2){
    if(!prime[i]) continue;
    for(int j=i+i;j<=n;j+=i)
      prime[j]=false;
  }
}

Measured memory_bytes: 884
#include<cstdio>
#include<stdlib.h>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int maxn =1e6+5;
typedef long long ll;
const int INF= 0x3f3f3f3f;
const int mod=10007;

char s1[102];
int s2[1020];
int head,tail;

int main()
{
    while(scanf("%s",s1)!=EOF)
    {
    tail=501;
    memset(s2,-1,sizeof(s2));
    for(int i=0;i<strlen(s1);i++)
    {
        if(s1[i]=='0')
        {
            s2[tail]=0;
            tail++;
        }
        else if(s1[i]=='1')
        {
            s2[tail]=1;
            tail++;
        }
        else if(s1[i]=='B')
        {
            for(int j=1010;j>=0;j--)
                if(s2[j]>=0)
                {
                    s2[j]=-1;
                    tail=j;
                    break;
                }

        }
    }
    for(int i=0;i<=1010;i++)
    {
        if(s2[i]!=-1)  printf("%d",s2[i]);
    }
    //printf("\0");
    }
    return 0;
}


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

int main() {
  int n,x,y=0;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<n;i++){
    x=a[i];
    for(int j=i;j<n;j++){
      if(x<a[j]){
        a[i]=a[j];
        a[j]=x;
        x=a[i];
      }
    }
  }
  for(int i=0;i<n;i++){
    if(i%2==0) y+=a[i];
    else y-=a[i];
  }
  cout<<y<<endl;
}

Measured memory_bytes: 384
/****************************
** In the name of Allah    **
** Author: Farhad          **
** From  : IIT,JU          **
*****************************/
#include<bits/stdc++.h>
using namespace std;
int main ()
{
  char ss[5][5];
  for(int i=0;i<3;i++)
{
       for(int j=0;j<3;j++)
{
cin>>ss[i][j];
    
}

}
printf("%c%c%c\n",ss[0][0],ss[1][1],ss[2][2]);
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long long a, long long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long long a, long long b){
	return a / gcd(a,b) * b;
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int n;
ll a[112345];
ll cnt;

int main(){
	cin >> n;
	
	REP(i,n) cin >> a[i];
	
	sort(a,a+n);
	
	REP(i,n){
		if (a[i] != a[i+1]) continue;
		
		cnt++;
		i++;
	}
	
	cout << n-(2*cnt) << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;
  if (N == M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN 400005
#define MOD 998244353
#define LL long long int
LL ans,res,C[MAXN],fac[MAXN],revfac[MAXN];
int n,m,k;
LL qpow(LL a,int b)
{
    LL tmp=1;
    while(b)
    {
        if(b&1)
        tmp=tmp*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return tmp%MOD;
}
void facrev()
{
    C[0]=1;
    C[1]=(n-1);
    fac[1]=1;
    revfac[0]=1;
    for(int i=2;i<=n;i++)
    {
        fac[i]=fac[i-1]*i%MOD;
        C[i]=C[i-1]*(n-i)%MOD;
    }
    revfac[n]=qpow(fac[n],MOD-2);
    for(int i=n-1;i>=1;i--)
    {
        revfac[i]=revfac[i+1]*(i+1)%MOD;
        C[i]=C[i]*revfac[i]%MOD;
    }
}
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    facrev();
    int p=n-k;
    res=m;
    for(int i=1;i<=p-1;i++)
    {
        res=res*(m-1)%MOD;
    }
    ans=res*C[p-1]%MOD;
    for(int j=p+1;j<=n;j++)
    {
        res=res*(m-1)%MOD;
        ans=(ans+res*C[j-1]%MOD)%MOD;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 8392
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <bitset>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int dp[1010][(1 << 12) + 100];

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> goods(m);
    vector<int> price(m);
    int b,c;
    int pat;

    rep(i,1010){
        rep(j,(1<<12)+100){
            dp[i][j] = 1e9;
        }
    }

    rep(i,1010){
        dp[i][0] = 0;
    }

    rep(i,m){
        cin >> price[i] >> b;
        pat = 0;
        rep(j,b){
            cin >> c;
            c--;
            pat = pat | (1 << c);
        }
        goods[i] = pat;
    }

    rep(i,m){
        rep(j,(1 << n)){
            dp[i+1][j | goods[i]] = min(dp[i+1][j | goods[i]], dp[i][j] + price[i]); 
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
        }
    }

    if(dp[m][(1<<n)-1] != 1e9){
        cout << dp[m][(1<<n)-1] << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s;
    cin>>s;
    int len=s.length();
    len--;
    if(len%2)
        len--;
    while(len>=0)
    {
        int mid=len/2,f=0;
        for(int i=0;i<mid;i++){
            if(s[i]!=s[i+mid])
                f=1;
        }
        if(f)
            len-=2;
        else
            break;

    }
    cout<<len<<endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
#define MOD 1000000007
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

  ll S,W; cin>>S>>W;

  if (W>=S) cout<<"unsafe"<<endl;
  else cout<<"safe"<<endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
      cin >> vec[i];
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int AliceSum, BobSum;
  AliceSum=0;
  BobSum=0;
  
  for (int i = 0; i < N; i+=2) { 
    AliceSum += vec.at(i);
  }
  for (int i = 1; i < N; i+=2) { 
    BobSum += vec.at(i);
  }
  cout << AliceSum-BobSum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  string a;
  cin>>a;
  int b=a.size();
  rep(i,b)
    cout<<'x';
  cout<<' '<<endl;
  return 0;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define P pair<int,int> 
signed main(){
    int n,m;cin>>n>>m;
    vector<int> a(n);rep(i,n)cin>>a[i];
    sort(all(a));
    vector<P> b(m);rep(i,m)cin>>b[i].first>>b[i].second;
    sort(all(b),[](auto p,auto q)->bool{return p.second>q.second;});

    int s=0,t=0;
    while(s<n&&t<m){
        if(a[s]<b[t].second){
            a[s]=b[t].second;
            s++;b[t].first--;
        }else break;
        if(b[t].first==0)t++;
    }
    ll ans=0;
    rep(i,n)ans+=a[i];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1408
Q, H, S, D = list(map(int, input().split()))
N = int(input())

ans1 = 4 * Q * N
ans2 = 2 * H * N
ans3 = S * N

if N < 2:
    ans4 = float('INF')
elif N % 2 == 0:
    ans4 = (N // 2) * D
else:
    t = (N // 2) * D
    ans4 = t + min(4 * Q, 2 * H, 1 * S)

# print(ans1, ans2, ans3, ans4)
ans = min(ans1, ans2, ans3, ans4)
print(ans)

Measured memory_bytes: 3064
N = int(input())
xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append((x,y,h))
    if h > 0:
        ids = i
        
for cx in range(101):
    for cy in range(101):

        dct = 1
        h = xyh[ids][2] + abs(xyh[ids][0]-cx) + abs(xyh[ids][1]-cy)
        
        for i in range(N):
            if xyh[i][2] != max(h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy),0):
                dct = 0
                break

        if dct:
            print(cx,cy,h)
            break

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> P;
const ll INF = 1e18;
#define foreach(ix,a) for(auto& (ix) : (a)) 
vector<vector<P>> edge;
vi ans;
int max_c= 0;
void dfs(ll i,ll j,ll k){    
    int c = 0;
    for(P x:edge[i]){
        int v= x.first,y=x.second;
        if(v==j)continue;
        if(k==c)c++;
        max_c=max(max_c,c);
        ans[y]=c;
        dfs(v,i,c);
        c++;
    }
}
int main(){
    int n;
    cin>>n;
    edge.resize(n);
    ans.resize(n);
    rep(i,n)ans[i]=0;
    rep(i,n-1){
        ll u,v;
        cin>>u>>v;
        u--;v--;
        edge[u].push_back({v,i});
        edge[v].push_back({u,i});
    }
    dfs(0,-1,-1);
    cout<<max_c+1<<endl;
    rep(i,n-1){
        cout<<ans[i]+1<<endl;
    }

}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

	string s;
	cin>>s;
	int wynik=700;
	for(int i=0;i<3;i++)
	{
		if(s[i]=='o')wynik+=100;
	}
	cout<<wynik;
}

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

using namespace std;

#define INF 0x3f3f3f3f
#define gc getchar()

typedef long long ll;
int read()
{
	char c=gc;int u=0,f=1;
	while(c!='-' && (c<'0' || '9'<c))c=gc;
	if(c=='-'){
		f=-1;
		c=gc;
	}
	while('0'<=c && c<='9'){
		u=u*10+c-'0';
		c=gc;
	}
	return u*f;
}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline void swap(int &a,int &b){int t=a;a=b;b=t;}

ll a[100010],b[100010];
ll ans=0;

int main()
{
	int n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		b[i]=read();
	}
	for(int i=n;i>=1;i--){
		a[i]+=ans;
		if(a[i]%b[i])ans+=b[i]-(a[i]%b[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1<<18;
using ll = long long;
using pll = pair<ll, ll>;
int h[200001];
struct LiChao{
	struct Node{
		int l=0,r=0;
		pll line = pll(0, (ll)1e18);
	} node[2*SIZE];
	int cnt;
	inline ll f(pll line, int x){
		return line.first*x + line.second;
	}
	void update(int nn, int ns, int ne, pll newLine){
		auto &cur = node[nn];
		pll l1 = cur.line, l2 = newLine;
		if(f(l1, ns) > f(l2, ns)) swap(l1, l2);
		if(f(l1, ne) <= f(l2, ne)){
			cur.line = l1;
			return;
		}
		int m = ns+ne>>1;
		if(f(l1, m) <= f(l2, m)){
			cur.line = l1;
			if(!cur.r) cur.r = ++cnt, node[cnt].line = l1;
			update(cur.r, m+1, ne, l2);
		}
		else{
			cur.line = l2;
			if(!cur.l) cur.l = ++cnt, node[cnt].line = l2;
			update(cur.l, ns, m, l1);
		}
	}
	ll query(int nn, int ns, int ne, int x){
		auto &cur = node[nn];
		if(ns==ne) return f(cur.line, x);
		int m = ns+ne>>1;
		if(m<x) return min(f(cur.line, x), cur.r?query(cur.r, m+1, ne, x):(ll)1e18);
		return min(f(cur.line, x), cur.l?query(cur.l, ns, m ,x):(ll)1e18);
	}
} L;
int N;
ll dp[200001], C;
int main(){
	scanf("%d%lld",&N,&C);
	for(int i=1; i<=N; ++i) scanf("%d",h+i);
	L.update(0, 0, 1e6, pll(-2ll*h[1], 1ll*h[1]*h[1]));
	for(int i=2; i<=N; ++i){
		dp[i] = 1ll*h[i]*h[i]+C+L.query(0, 0, 1e6, h[i]);
		L.update(0, 0, 1e6, pll(-2ll*h[i], 1ll*h[i]*h[i]+dp[i]));
	}
	printf("%lld",dp[N]);
	return 0;
}


Measured memory_bytes: 14848
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;
typedef vector<vector<lint>> mat;

int m, nmin, nmax, p[100010];

int main(){
    while(true){
        cin >> m >> nmin >> nmax;
        if(m == 0) return 0;
        rep(i, m) cin >> p[i];
        int dmax = 0;
        int num = 0;
        For(i, nmin-1, nmax){
            if(p[i] - p[i+1] >= dmax){
                dmax = p[i] - p[i+1];
                num = i + 1;
            }
        }
        cout << num << endl;
    } 
}


Measured memory_bytes: 3084
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;



void dfs(int i, int cnt, string *C){
}

int main(){
    int n, k;
    while(cin>>n>>k, n|k){
        vector<string> C(n);
        REP(j, n) cin >> C[j] ;
        set<string> strs;
        for(int mask=0; mask< (1 << n); mask++){
            int total_1=0;
            for(int i=0; i<n; i++)
                if(mask >> i & 1) total_1++;
            if(total_1 != k) continue;
            vector<string> cards;
            for(int i=0; i<n; i++)
                if(mask >> i & 1) cards.push_back(C[i]);
            sort(ALL(cards));
            do{
                string tmp;
                for( auto num : cards)
                    tmp+=num;
                if(strs.find(tmp)==strs.end())
                    strs.insert(tmp);
            }while(next_permutation(ALL(cards)));
        }
        cout << strs.size() << endl;
    }
    return 0;
}


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

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;}

ll f(ll x, int c, int d)
{
	ll res = x;
	res -= x/c;
	res -= x/d;
	res += x/lcm(c,d);
	return res;
}

int main() {
	ll a, b;
	int c, d;
	cin >> a >> b >> c >> d;
	ll ans = f(b,c,d) - f(a-1,c,d);
	cout << ans << endl;
	return 0;
}


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

int main()
{
   int a,b,c,d,i=0,j=0;
  
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  while(a>0)
  {
    c=c-b;
    if(c<=0)
    {
      break;
    }
    a=a-d;
  }
  
 if(a<=0)
 {
   printf("No");
 }
  else if(c<=0)
  {
    printf("Yes");
  }
  
  
  return 0;
    
}

Measured memory_bytes: 1732
#include <stdio.h>
int main(){
  int a, i,n;
  int b = 0;
  int c = 1;
    
  scanf("%d",&n); 
  for(i=0;i<n+1;i++){ 
    a=b+c;
    b=c;
    c=a;
  }
  printf("%d\n",b);
   
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;

char atcg(char x){
  if(x=='A') return 'T';
  if(x=='T') return 'A';
  if(x=='C') return 'G';
  if(x=='G') return 'C';
  else return '0';
}

int main() {
  char x;
  cin >> x;
  
  cout << atcg(x);
}

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

int main(){
  int n,i,b=0;
  cin >> n;
  vector<int> v(n),c(n);
  for(i=0;i<n;i++){
    cin >> v.at(i);
  }
  for(i=0;i<n;i++){
    cin >> c.at(i);
  }
  for(i=0;i<n;i++){
    b += max(v.at(i)-c.at(i),0);
  }
  cout << b << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<functional>
#include<set>
using namespace std;
#define int long long
#define REP(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
char ans[100][100];
int guard[100][100];
int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
void disp() {
	REP(i, 100) {
		REP(j, 100)cout << ans[i][j];
		cout << endl;
	}
}
signed main() {
	int a, b; cin >> a >> b;
	cout << 100 << ' ' << 100 << endl;

	REP(i, 100)
		REP(j, 100)ans[i][j] = '.';
	int A = 1, B = 0;
	for (int i = 0; i < 100; i += 2) {
		for (int j = 0; j < 100; j += 2) {
			if (A == a)goto F;
			ans[i + 1][j] = '#';
			ans[i][j + 1] = '#';
			ans[i + 1][j + 1] = '#';
			A++;
			if (!B)B++;
		}
	}
F:; 
	for (int i = 30; i < 99; i++) {
		for (int j = 1; j < 99; j++) {
			if (B == b)goto G;
			if ((i + j) % 3 == 0) {
				ans[i][j] = '#';
				B++;
			}
		}
	}
G:;
	disp();
}

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    vector<ll> t;
    ll count=0;
    for(int i=0;i<n;i++){
        ll k;
        cin>>k;
        count+=k;
        t.pb(k);
    }
    ll m;
    cin>>m;
    for(ll i=0;i<m;i++){
        ll p,x;
        cin>>p>>x;
        p-=1;
        cout<<count-t[p]+x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	ll N;
	vector<ll> in(5);
	cin >> N;
	for(int i = 0; i < 5; i ++){
		cin >> in[i];
	}
	sort(all(in));
	ll ans = 4;
	if(N%in[0] == 0)ans += N / in[0];
	else ans += N / in[0] + 1;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int H,W;

		do{
			H=scan.nextInt();
			W=scan.nextInt();
			if(H==0 && W==0){
				break;
			}
			for(int i=1;i<=H;i++){
				for(int j=1;j<=W;j++){
					if((i+j)%2==0){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}while(!(H==0 && W==0));
	}
}


Measured memory_bytes: 38092
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
#include <iostream>  
using namespace __gnu_pbds;  
using namespace std;
#define ll long long
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update>  ordered_set;
using namespace std;
 
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (long long i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define fillinf(ar, n) fr(i,0,(n)) ar[i] = INF
#define debug(x) cout<<#x<<": "<<x<<endl
#define arr1d(a,n) cout << #a << " : "; fr(_,1,n) cout << a[_] << ' '; cout << endl;
#define arr1d0(a,n) cout << #a << " : "; rep(_,n) cout << a[_] << ' '; cout << endl;
#define arr2d(a,n,m) cout << #a << " :" << endl; fr(_,1,n) {fr(__,1,m) cout << a[_][__] << ' '; cout << endl;}
#define arr2d0(a,n,m) cout << #a << " :" << endl; rep(_,n) {rep(__,m) cout << a[_][__] << ' '; cout << endl;}


#define ull unsigned long long
#define ld long double
#define ui unsigned int
#define all(ar) ar.begin(), ar.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define y0 yyyyyy0
auto clk=clock();
#define y1 yyyyyy1
#define setb __builtin_popcount
#define BIT(n) (1<<(n))
#define SQR(x) ((x) * (x))
#define CUBE(x) ((x) * (x) * (x))
#define LSOne(S) (S) & (-S)
inline bool EQ(double a, double b) {return fabs(a - b) < 1e-9;}
 
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;


 
inline int two(int n) {return 1 << n;}
inline int isOnBit(int n, int b) {return (n >> b) & 1;}
inline void onBit(int & n, int b) {n |= two(b);}
inline void offBit(int & n, int b) {n &= ~two(b);}
inline int lastBit(int n) {return n & (-n);}
inline int cntBit(int n) {int res = 0; while(n && ++res) n -= n &(-n); return res;}
 
#define INP "test.inp"
#define OUT "test.out"
 
#define PI 3.1415926535897932385
#define INF 10000000000000000ll
#define EPS 1e-7
#define MAXN 100000
#define MOD 998244353
#define dec decr
#define endl '\n'
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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


    int n;
    cin>>n;
    double ans=0;
    double temp;
    rep(i,n){
        cin>>temp;
        ans+=(double)(1/temp);
    }
    ans=1/ans;
    cout<<ans;
    
    return 0;
}   

Measured memory_bytes: 256
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<string>
#include<sstream>
#include<math.h>
using namespace std;
//char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int main(){
//	while(1){
		long long   n;cin>>n;
		long long a=1;
		for(long long  i=1;i<=n;i++){a=(a*i)%1000000007;}
		//double b=remainder(a,1000000007);
		cout<<a<<endl;
	
	
	}//mainwhile

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

int main()
{
	string s,t;
	cin>>s>>t;
	int cnt=0;
	for(int i=0;i<(int)s.size();i++)
	{
		if(s[i]!=t[i])cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3916
#include<stdio.h>
int main(){
    int x,t,n;
    int ans;
    
    scanf("%d %d %d",&n,&x,&t);
    
    if(n % x != 0){
        ans = n/x;
        ans++;
    }else{
        ans = n/x;
    }
    ans *= t;
    
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1708
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str=input.readLine();
	char a[]=str.toCharArray();
	for(int i=0;i<a.length-4;i++)
	    {
		if(a[i]=='a' && a[i+1]=='p' && a[i+2]=='p' && a[i+3]=='l' && a[i+4]=='e')
		    {
			a[i]='p';
			a[i+1]='e';
			a[i+2]='a';
			a[i+3]='c';
			a[i+4]='h';
		    }
		else if(a[i]=='p' && a[i+1]=='e' && a[i+2]=='a' && a[i+3]=='c' && a[i+4]=='h')
		    {
			a[i]='a';
			a[i+1]='p';
			a[i+2]='p';
			a[i+3]='l';
			a[i+4]='e';
		    }
		
	    }
	    for(int i=0;i<a.length;i++)
		    {
			System.out.print(a[i]);
		    }
	    System.out.println();
    }
}

Measured memory_bytes: 16876
#include <iostream>
#include <cmath>
#include <iomanip>
using std::cout;
using std::cin;
using std::endl;

int main()
{
    long double a, b, x;
    cin >> a >> b >> x;
    const long double pi = acos(-1);
    long double rad;

    if (x < a * a * b / 2.0)
    {
        rad = atan(x * 2.0 / (a * b * b));
        rad = (pi / 2.0 - rad);
    }
    else
    {
        rad = atan(2 * (a * a * b - x) / (a * a * a));
    }

    cout << std::setprecision(10) << rad * 180.0 / pi << endl;

    return 0;
}

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

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

    multiset<string> s;
    rep(i, n){
        string str;
        cin >> str;
        s.insert(str);
    }

    for(string str : s){
        cout << str;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
   int t;
          t=1;
          while(t--)
          {
            ll a,b,c;
            cin>>a>>b>>c;
            if(a+b == c || a+c == b || b+c == a)
              cout<<"Yes";
            else
              cout<<"No";
          }
  return 0;
}


Measured memory_bytes: 3580
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

from collections import Counter
def main():
    n=II()
    aa=LI()
    cnt=Counter(aa)
    ans="YES"
    for v in cnt.values():
        if v>1:ans="NO"
    print(ans)

main()

Measured memory_bytes: 33332
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int a[n],s=0,c=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    
    for(int i=0;i<n;i++)
    {
        if(4*m*a[i]>=s)
        c++;
        if(c==m)
        break;
        
    }
    
    if(c<m)
    cout<<"No";
    else
    cout<<"Yes";
    
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
double dp[3005][3005],a[3005],ans=0.0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	dp[0][0]=1;
	for(int i=1;i<=n;i++)for(int j=0;j<=i;j++)
		dp[i][j]=dp[i-1][j]*(1-a[i])+dp[i-1][j-1]*a[i];
	for(int i=n/2+1;i<=n;i++)ans+=dp[n][i];
	cout<<fixed<<setprecision(9)<<ans;
	return 0;
}

Measured memory_bytes: 49960
from itertools import permutations
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
pi = 0
qi = 0
cnt = 0
for p in permutations(range(1,1+N)):
    cnt += 1
    #print(p)
    if p == P:
        pi = cnt
    if p == Q:
        qi = cnt
        
print(abs(qi-pi))


Measured memory_bytes: 39280
def main():
    N = int(input())
    A = list(map(int, input().split()))
    breakcount = 0
    cnt = 1
    for i in range(N):
        if A[i] != cnt:
            breakcount += 1
        else:
            cnt += 1
    if cnt == 1:
        print(-1)
        return
    print(breakcount)

if __name__ == "__main__":
    main()


Measured memory_bytes: 32376