akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int n;
    string s;
    cin >> n >> s;

    vector<bool> cnt(1000, false);
    for (int i = 0; i < 1000; ++i) {
        char tmp[3];
        tmp[0] = i / 100 + '0';
        tmp[1] = i /10 % 10 + '0';
        tmp[2] = i % 10 + '0';
        //cout << tmp[0] << tmp[1] << tmp[2] << endl;
        int x = 0, y = n, z = n;
        for (int j = 0; j < n; ++j) {
            if(tmp[0] == s[j] && x == 0){
                x++; y = j;
            }
            if(tmp[1] == s[j] && x == 1 && y < j){
                x++; z = j;
            }
            if(tmp[2] == s[j] && x == 2 && z < j){
                x++;
            }
        }
        if(x == 3){
            cnt[i] = true;
        }
    }

    ll ans = 0;
    rep(i, 1000){
        ans += cnt[i];
    }

    cout << ans << endl;

    return 0;
}


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

using lint = long long;

int main() {
    int n;
    cin >> n;
    vector<lint> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (int i = 1; i < n; i++) {
        a[i] += a[i - 1];
    }

    map<lint, lint> num;
    for (int i = 0; i < n; i++) {
        num[a[i]]++;
    }

    lint ans = num[0];
    for (auto it = num.begin(); it != num.end(); it++) {
        if (it->second > 0) {
            ans += it->second * (it->second - 1) / 2;
        }
    }

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

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define bash push_back
#define alles(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;

int n,k,h[100005],dp[100005];



int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  cin >> n >> k;
  iFOR(i,1,n+1) cin >> h[i];

  iFOR(i,2,n+1){
    dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
    iFOR(j,2,min(i,k+1)){
      dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
    }
  }
  cout <<dp[n] fin;
  return 0;
}



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

using namespace std;

void hawawa()
{
	int n, m;
	cin >> n >> m;
	vector<pair<int, int> > a(m);
	for (auto&& i : a) {
		cin >> i.first >> i.second;
	}
	sort(begin(a), end(a), [](pair<int, int> x, pair<int, int> y) {return x.second < y.second; });

	int ans = 0, pos = 0;
	for (auto&& i : a) {
		if (pos < i.first) {
			ans++;
			pos = i.second - 1;
		}
	}
	cout << ans << "\n";
}

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


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

type Pair struct {
	Key   int
	Value int
}

// sort.Sort(ByKey(pairs))
type ByKey []Pair

func (s ByKey) Len() int {
	return len(s)
}

func (s ByKey) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s ByKey) Less(i, j int) bool {
	return s[i].Key < s[j].Key
}

// sort.Sort(ByValue(pairs))
type ByValue []Pair

func (s ByValue) Len() int {
	return len(s)
}

func (s ByValue) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s ByValue) Less(i, j int) bool {
	return s[i].Value > s[j].Value
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func main() {
	n := nextInt()

	kvs := make([]Pair, 0, n)

	for i := 1; i <= n; i++ {
		v := nextInt()
		kvs = append(kvs, Pair{Key: i, Value: v})
	}

	sort.Sort(ByValue(kvs))

	for i := 1; i <= n; i++ {
		for _, item := range kvs {
			if item.Key != i {
				fmt.Println(item.Value)
				break
			}
		}
	}
}


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

using namespace std;

int main()
{
    long long a,b,x;
    while(cin>>a>>b>>x)
    {
        long long ans=(b/x)-(a/x);
        if(a%x==0)
        ans++;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int abc[3], i, j, buf;
  scanf("%d %d %d",abc,abc+1,abc+2);
  
  for(i=1;i<3;i++){
    for(j=0;j<3-i;j++){
      if(abc[j] > abc[j+1]){
	buf = abc[j];
	abc[j] = abc[j+1];
	abc[j+1] = buf;
      }
      else{
      }
    }
  }
  printf("%d %d %d\n",abc[0],abc[1],abc[2]);
  
  return 0;
}

Measured memory_bytes: 596
import java.util.*;
import java.math.*;
import java.io.*;
public class Main
 {
	public static void main (String[] args)
	 {
	 Scanner s=new Scanner(System.in);
	 String c=s.next();
	 int count=0;
	 int n=c.length();
	 for(int i=0,j=n-1;i<n;i++,j--)
	 {if(c.charAt(i)!=c.charAt(j))
	 count++;}
	 System.out.println(count/2);
}}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
#define lli long long int
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
ll f[1000005];
ll powinlcm[1000005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n,i;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<1000005;i++)
        f[i]=i;
    ll j;
    for(i=2;i<1000005;i++)
    {
        if(f[i]==i)
        {
            for(j=2*i;j<1000005;j+=i)
                f[j]=i;
        }
    }
    for(i=0;i<n;i++)
    {
        ll x=a[i];
        while(x!=1)
        {
            ll y=f[x];
            ll c=0;
            while((x%y)==0)
            {
                x/=y;
                c++;
            }
            powinlcm[y]=max(powinlcm[y],c);
        }
    }
    ll lcm=1;
    for(i=2;i<1000005;i++)
    {
        lcm=(lcm*power(i,powinlcm[i],hell))%hell;
    }
    trace(lcm);
    ll ans=0;
    for(i=0;i<n;i++)
    {
        ans=(ans+(lcm*power(a[i],hell-2,hell))%hell)%hell;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 15744
import java.util.Scanner;

public class Main {

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

		int num500 = stdin.nextInt();
		int num100 = stdin.nextInt();
		int num50 = stdin.nextInt();
		int value = stdin.nextInt();

		int count = 0;
		for (int i = 0; i <= num500; i++) {
			int sum500 = 500 * i;
			if (sum500 > value) {
				break;
			}

			for (int j = 0; j <= num100; j++) {
				int sum100 = sum500 + 100 * j;
				if (sum100 > value) {
					break;
				}

				int value50 = value - sum100;
				if (((value50 % 50) == 0) && ((value50 / 50) <= num50)) {
					count++;
				}
			}
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 21972
n = int(input())
arr = list(map(int,input().split()))
arr.sort()

cnt = {}
kouho = []
erat = [True for i in range(10**6+1)]

for i in range(n):
    if arr[i] not in cnt:
        cnt[arr[i]] = 1
    else:
        cnt[arr[i]] += 1
    if erat[arr[i]]:
        kouho.append(arr[i])
        tp = arr[i]
        while True:
            erat[tp] = False
            tp += arr[i]
            if tp > 10**6:
                break
# print(kouho)
ans = 0
for k in kouho:
    if cnt[k] == 1:
        ans += 1


print(ans)


Measured memory_bytes: 43916
n = int(input())
ns = []
max_profit = -1000000000
min_value = 1000000000
for i in range(n):
    num = int(input())
    if i > 0:
        max_profit = max(max_profit, num-min_value)
    min_value = min(num, min_value)
print(max_profit)
    


Measured memory_bytes: 5616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = null;
        try {
            s = new Scanner(System.in);
            String line = s.nextLine();
            System.out.println(powBy3(Integer.parseInt(line)));
        } finally {
            if (s != null) {
                s.close();
            }
        }
    }

    private static int powBy3(int i) {
        return i * i * i;
    }
}

Measured memory_bytes: 17128
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  int n;
  cin >> n;
  vi data(n);
  rep(i,n) cin >> data[i];
  int sum = 0;
  rep(i,n) sum += data[i];
  int ans = inf;
  rep(i,n-1) {
    int sum1 = 0;
    repa(j,0,i+1) sum1 += data[j];
    ans = min(ans,abs((sum-sum1)-sum1));
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    int h,w;
    scanf("%d %d",&h,&w);
    char s[h][w + 1];
    for(int i = 0; i < h; i++){
        scanf("%s",s[i]);
    }

    int count;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '.'){
                count = 0;
                if(i - 1 >= 0 && j - 1 >= 0){
                    if(s[i - 1][j - 1] == '#'){
                        count++;
                    }
                }
                if(i - 1 >= 0){
                    if(s[i - 1][j] == '#'){
                        count++;
                    }
                }
                if(i - 1 >= 0 && j + 1 < w){
                    if(s[i - 1][j + 1] == '#'){
                        count++;
                    }
                }
                if(j - 1 >= 0){
                    if(s[i][j - 1] == '#'){
                        count++;
                    }
                }
                if(j + 1 < w){
                    if(s[i][j + 1] == '#'){
                        count++;
                    }
                }
                if(i + 1 < h && j - 1 >= 0){
                    if(s[i + 1][j - 1] == '#'){
                        count++;
                    }
                }
                if(i + 1 < h){
                    if(s[i + 1][j] == '#'){
                        count++;
                    }
                }
                if(i + 1 < h && j + 1 < w){
                    if(s[i + 1][j + 1] == '#'){
                        count++;
                    }
                }

                s[i][j] = '0' + count;
            }
        }
    }

    for(int i = 0; i < h; i++){
        printf("%s\n",s[i]);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e9;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
vector<pairs> p;


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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}
// ------------------------------------

int main(){
    ll n, a, b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    ll flag=0;
    ll sum=0;
    for(ll i=0;i<n;++i){
        if(sum >= a+b){
            cout<<"No"<<endl;
        }else if(s[i]=='a'){
            sum++;
            cout<<"Yes"<<endl;
        }else if(s[i]=='b'){
            if(flag < b){
                sum++;
                flag++;
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else{
            cout<<"No"<<endl;
        }
    }
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,a,b,c,d;cin>>n>>a>>b>>c>>d;
  bool ans=false;
  for(int i=0;i<n;i++){
    if(c*(n-i-1)-d*i<=b-a&&b-a<=(-c*i+(n-i-1)*d)){
      ans=true;
    }
  }
  YES(ans);
  return 0;
}


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

int search(int i, vector<vector<int>>& fri, vector<bool>& check);

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<vector<int>> fri(N + 1, vector<int>(0));
  for (int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    fri.at(a).push_back(b);
    fri.at(b).push_back(a);
  }
  
  int ans = 0;
  vector<bool> check(N + 1, false);
  for (int i = 1; i <= N; i++){
    if (check.at(i) == true){
      continue;
    }
    else{
      int num;
      check.at(i) = true;
      num = search(i, fri, check);
      ans = max(ans, num);
    }
  }
  
  cout << ans << endl;
}
  
int search(int i, vector<vector<int>>& fri, vector<bool>& check){
  int depth = 1;
  for (int j = 0; j < (int)(fri.at(i).size()); j++){
    if (check.at(fri.at(i).at(j)) == true){
      continue;
    }
    else{
      check.at(fri.at(i).at(j)) = true;
      depth += search(fri.at(i).at(j), fri, check);
    }
  }
  return depth;
}

Measured memory_bytes: 29792
#include <stdio.h>

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  
  if(a>b){
  	printf("a > b\n");
  }else if(a<b){
     printf("a < b\n");
  }else{
     printf("a == b\n");
  }
  return 0;
} 


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

constexpr int MAXI = 1000006;
int dp[MAXI][2];

int main(){
  string S;
  cin >> S;
  int N = S.size();
  dp[0][1] = 1;
  REP(i, N){
    int x = S[i] - '0';
    dp[i+1][0] = min(dp[i][0]+x, dp[i][1]+10-x);
    dp[i+1][1] = min(dp[i][0]+x+1, dp[i][1]+10-x-1);
  }
  cout << dp[N][0] << endl;
  return 0;
}


Measured memory_bytes: 9220
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
if(a==1 && b==2) printf("3");
else  if(a==1 && b==3) printf("2");
else if(a==2 && b==1) printf("3");
 else if(a==2 && b==3) printf("1");
else  if(a==3 && b==1) printf("2");
else if(a==3 && b==2) printf("1");
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int A;
long double B;

void solve() {
}

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

    cin >> A >> B;
    cout << (int)(A * B) << endl;

    solve();
    return 0;
}


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

int main()
{
    int num[3][3];
    int n,m;
    int a1,a2,a3,b1,b2,b3;
    for(n=0;n<3;n++){
        for(m=0;m<3;m++){
            scanf("%d",&num[n][m]);
        }
    }
    for(a1=0;a1<=100;a1++){
        b1=num[0][0]-a1;
        a2=num[1][0]-b1;
        a3=num[2][0]-b1;
        b2=num[0][1]-a1;
        b3=num[0][2]-a1;
        if((a2+b2==num[1][1])&&(b3+a3==num[2][2])&&(a3+b2==num[2][1])&&(a2+b3==num[1][2])){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

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

    int res = 0;
    int x = 0;
    REP(i, n) {
        if (s[i] == 'I') {
            x++;
        } else {
            x--;
        }
        res = max(res, x);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	vector<int>arr(n);
	for(int i=0; i<n; i++)
	 cin>>arr[i];
	sort(arr.rbegin(),arr.rend());
	ll sum=arr[0];
	ll var=n-2;
	int i=1;
	while(var)
	{
		if(var==1){
		 sum+=arr[i];
		 i++;
		 var--;
	    }
	    else
	    {
	    	sum+=2*arr[i];
	    	i++;
	    	var-=2;
		}
	}
	cout<<sum;
	
}

Measured memory_bytes: 4024
import java.io.*

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val (h, w) = nextIntList()
    val cost = intAry2(10, 10)
    for (i in 0..9){
        val list = nextIntList()
        for (j in 0..9){
            cost[i][j] = list[j]
        }
    }
    for (k in 0..9){
        for (i in 0..9){
            for (j in 0..9){
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])
            }
        }
    }


    var ans = 0
    repeat(h){
        val list = nextIntList()
        for (i in 0 until w){
            if(list[i] == -1 || list[i] == 1) continue
            ans += cost[list[i]][1]
        }
    }

    println(ans)


}

fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(vararg values: Int) = if (values.isEmpty()) -INF else values.max()!!
fun max(vararg values: Long) = if (values.isEmpty()) -LINF else values.max()!!
fun min(vararg values: Int) = if (values.isEmpty()) INF else values.min()!!
fun min(vararg values: Long) = if (values.isEmpty()) LINF else values.min()!!
fun swap(a: String, b: String) = Pair<String, String>(b, a)
fun swap(a: Int, b: Int) = Pair<Int, Int>(b, a)
fun swap(a: Long, b: Long) = Pair<Long, Long>(b, a)
fun swap(a: Double, b: Double) = Pair<Double, Double>(b, a)



Measured memory_bytes: 41540
#include <bits/stdc++.h>
#define gc getchar()
#define pc(x) putchar(x)
template<typename T> void scan(T &x){x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;


int main(){
    
    int a, b;
    scan(a, b);
    if(a > 9 || b > 9){
        return 0*puts("-1");
    }
    print(a*b);
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#ABC142C
import sys
#sys.setrecursionlimit(100000)

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

b=[]
for i in range(n):
	b.append(str(0))
#print(b)

for i in range(n):
	b[a[i]-1]=i+1
#print(b)
#print(count)

print(*b)

Measured memory_bytes: 24072
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> T lcm(T a, T b){return a / gcd(a,b) * b;}


int main() {
  ll n,x; cin >>n >>x;
  ll res = n;
  ll a = x, b = n-x;
  // 長さがx,n-xの平行四辺形になる
  while (true){
    if (a < b) swap(a,b);
    res += a/b * 2 * b;
    a = a%b;
    if (a == 0){
      res -= b; break;
    }
  }
  cout <<res <<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}


template<typename T> class BIT {
private:
	int n;
	vector<T> bit;
public:
	// 0_indexed で i 番目の要素に x を加える
	void add(int i, T x){
		i++;
		while(i < n){
			bit[i] += x, i += i & -i;
		}
	}
	// 0_indexed で [0,i] の要素の和(両閉区間！！)
	T sum(int i){
		i++;
		T s = 0;
		while(i > 0){
			s += bit[i], i -= i & -i;
		}
		return s;
	}
	BIT(){}
	//初期値がすべて0の場合
	BIT(int sz) : n(sz+1), bit(n, 0){}
	BIT(vector<T>& v) : n((int)v.size()+1), bit(n, 0){
		for(int i = 0; i < n-1; i++){
			add(i,v[i]);
		}
	}
	void print(){
		for(int i = 0; i < n-1; i++){
			cout<<sum(i)-sum(i-1)<< " ";
		}
		cout<<endl;
	}
	//-1スタート
	void print_sum(){
		for(int i = 0; i < n; i++){
			cout<<sum(i-1)<<" ";
		}
		cout<<endl;
	}
};

ll n;
ll m;
vector<int> a;

bool up(int x){
    vector<int> b(n+1);
    rep(i,n){
        if(a[i]>=x){
            b[i+1] = 1;
        }else{
            b[i+1] = -1;
        }
    }
    for(int i=1;i<=n;i++){
        b[i] += b[i-1];
    }
    rep(i,n+1){
        b[i] += n;
    }
    BIT<ll> bit(2*n+2);
    rep(i,n+1){
        bit.add(b[i],1);
    }
    ll tmp = 0;
    rep(i,n+1){
        tmp += bit.sum(2*n+1) - bit.sum(b[i]-1)-1;
        bit.add(b[i],-1);
    }
    // cerr << x << " " << tmp << endl;
    return (tmp >=m&&tmp!=0);
}
int main(){
    cin >> n; 
    a.resize(n);
    rep(i,n){
        cin >> a[i];
    }   
    m = n*(n+1)/2;
    m = m/2;
    int ok = 1;
    int ng = 1000000001;
    while(ng-ok>1){
        int mid = (ok+ng)/2;
        if(up(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}

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

using namespace std;

int n, a, b, c, d;

int main()
{
    scanf("%d%d%d%d%d", &a, &b, &c, &d, &n);
    if (d < min(min(a * 8, b * 4), c * 2))
    {
        if (n % 2)
            {
                long long ans = 1LL * (n / 2) * d + min(1LL * c, min(4LL * a, 2LL * b));
                printf("%lld\n", ans);
            }
        else
            printf("%lld", 1LL * (n / 2) * d);
    }else
        printf("%lld\n", min(min(4LL * a, 2LL * b), 1LL * c) * n);

    return 0;
}


Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int n,sum = 0;
int main() {
    cin >> n;
    vector<int> s(n);
    for (int i = 0;i < n;i++) {
        cin >> s[i];
        sum += s[i];
    }

    if (sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }
    sort(s.begin(), s.end());
    for (int i = 0;i < n;i++) {
        if (s[i] % 10 != 0) {
            cout << sum - s[i] << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;

int main()
{
    int q, x;
    char com[20];
    list<int> v;
    scanf("%d", &q);
    for(int i=0; i<q; i++)
    {
        scanf("%s", com);
        if(com[0] == 'i')
        {
            scanf("%d", &x);
            v.push_front(x);
        }
        else if(com[6]=='F')
        {
            v.pop_front();
        }
        else if(com[6]=='L')
        {
            v.pop_back();
        }
        else if(com[0]=='d')
        {
            scanf("%d", &x);
            for(list<int>::iterator it = v.begin(); it != v.end(); it++)
            {
                if(*it == x)
                {
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i=0;
    for(list<int>::iterator it = v.begin(); it != v.end(); it++)
    {
        if(i++)    printf(" ");
        printf("%d", *it);
    }
    printf("\n");
    return 0;
}

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

// 二分探索ライブラリを書いたので
// 0-indexed

int N, Q;
string S;
vector<char> t, d;

// ゴーレムが左に落ちるならtrue
bool is_fallen_left(ll id) {
    for (int i = 0; i < Q; ++i) {
        if (t[i] == S[id]) {
            if (d[i] == 'L') id--;
            else id++;
        }
        if (id < 0) return true;
        if (id >= N) return false;
    }
    return false;
}

// ゴーレムが右に落ちるならtrue
bool is_fallen_right(ll id) {
    for (int i = 0; i < Q; ++i) {
        if (t[i] == S[id]) {
            if (d[i] == 'L') id--;
            else id++;
        }
        if (id < 0) return false;
        if (id >= N) return true;
    }
    return false;
}

// 開区間と判定関数を引数にして条件を満たす境界値を返す
ll BiSearch(ll ok, ll ng, function<bool(ll)> C){
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (C(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    cin >> N >> Q >> S;
    t.resize(Q); d.reserve(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> t[i] >> d[i];
    }

    ll lb = BiSearch(-1, N, is_fallen_left);
    ll rb = BiSearch(N, -1, is_fallen_right);
    ll ans = rb - lb - 1;
    if (ans < 0) ans = 0;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 900
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n : u32 = read();
    let ln:Vec<Vec<i32>> = read_vec2(n);
    let mut ans = 0;
    for i in 0..n {
        ans += ln[i as usize][1] - ln[i as usize][0] + 1; 
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int main(void)
{
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int dx = x2 - x1, dy = y2 - y1;

  int x3 = x2 - dy, y3 = y2 + dx;
  int x4 = x1 - dy, y4 = y1 + dx;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define pb push_back
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fs(s) for(ll i=0;s[i]!='\0';i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define gcd(a,b) __gcd(a,b)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define c1(x) __builtin_popcountll(x)
#define setprs(x) cout << fixed << setprecision(x);
#define endl '\n'
const ll mod=1e9 + 7;
const ll sz=1e5 + 100;
const double PI =3.14159265;
ll power(ll a, ll b, ll m = mod){if(b==0)return 1;else if(b==1)return a%m;else{ll t=power(a,b>>1,m);t=((t%m)*(t%m))%m;if(b&1)return ((t%m)*(a%m))%m;else return t%m;}}
 
//--------------------------------------------------------

void solve()
{
    int n, k;
    int h[sz];
    cin >> n >> k;
    f(i,0,n)cin >> h[i];
    int cost[sz]={0};
    cost[n-1] = 0;
    fr(i,n-2, n-k-1){
        cost[i] = abs(h[n-1] - h[i]);
    }
    fr(i,n-3, 0){
        int mi = mod;
        f(j,1,k+1){
            if(i+j < n){
                mi = min(mi, abs(h[i+j] - h[i]) + cost[i+j]);
            }
        }
        cost[i] = mi;
    }
    cout << cost[0];
} 
 
int32_t main()
{
    fastio
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 4420
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	if (x/d >= k) print(x - (k * d));
	else if ((k - (x / d)) % 2 == 0)print(x % d);
	else print(d - (x % d));
}

Measured memory_bytes: 3544
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		if((W - x - r >= 0) && (H - y - r >= 0) && (x >= r) && (y >= r)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26324
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N, M = Scanner.map_int()
    A = sum(Scanner.map_int())
    print(max(-1, N - A))


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


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

int main(){
	int a, b, c, d[3], aux;
	cin>>a;
	cin>>b;
	cin>>c;
	d[0]=a+b;
	d[1]=b+c;
	d[2]=a+c;
	for(int i=0; i<2;i++){
 		for (int j=0; j<2; j++){
 			if(d[j]>d[j+1]){
 				aux=d[j];
 				d[j]=d[j+1];
 				d[j+1]=aux;
 			}
 		}
 	}
 	cout<<d[0]<<endl;
}

Measured memory_bytes: 3440
#include <stdio.h>
#include <stdlib.h>
 
void yosinaga_sayuri(int n) {
    int a;
    if (scanf("%d", &a) != 1) exit(1);
    if (n > 1) {
        yosinaga_sayuri(n - 1);
        putchar(' ');
    }
    printf("%d", a);
}
 
int main(void) {
    int n;
    if (scanf("%d", &n) != 1) return 1;
    yosinaga_sayuri(n);
    putchar('\n');
    return 0;
}


Measured memory_bytes: 2040
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<math.h>
using namespace std;
int main(){
  int n;
  std::cin >> n;
  string a,b;
  std::cin >> a>>b;

  for (int i = 0; i < n; i++) {
    std::cout << a[i];
    std::cout << b[i];
  }
  std::cout << "" << '\n';





  return 0;
}


Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;

fn main() {
    let stdin = io::stdin();
    for (i, line) in stdin.lock().lines().enumerate() {
        let uline = line.unwrap();
        if i % 2 == 0 {
            let n: usize = uline.parse().unwrap_or(0);
            if n == 0 {
                break;
            }
        } else {
            let vec: Vec<&str> = uline.split_whitespace().collect();
            let din: Vec<f64> = vec.iter().map(|&x| x.parse().unwrap_or(0.0)).collect();
            match std_deviation(&din) {
                Some(v) => println!("{}", v),
                None => println!("Error"),
            }
        }
    }
}


fn mean(data: &[f64]) -> Option<f64> { 
    let sum = data.iter().sum::<f64>() as f64; 
    let count = data.len(); 
    match count {
        positive if positive > 0 => Some(sum / count as f64), 
        _ => None, 
    }
}

fn std_deviation(data: &[f64]) -> Option<f64> { 
    match (mean(data), data.len()) { 
        (Some(data_mean), count) if count > 0 => { 
            let variance = data.iter().map(|value| { 
                let diff = data_mean - (*value as f64); 
                
                diff * diff 
            }).sum::<f64>()  / count as f64; 
            Some(variance.sqrt()) }, 
        _ => None 
    } 
}

//fn main() {
//    let scan = std::io::stdin();
//    loop {
//        let mut line = String::new();
//        let _ = scan.read_line(&mut line);
//        let n: usize = line.parse().unwrap_or(0);
//        if n == 0 {
//            break;
//        }
//        let mut line2 = String::new();
//        let _ = scan.read_line(&mut line2);
//        let vec: Vec<&str> = line2.split_whitespace().collect();
//        let din: Vec<f64> = vec.iter().map(|&x| x.parse().unwrap_or(0.0)).collect();
//        for e in din {
//            println!("{}", e);
//        }
//    }
//}



Measured memory_bytes: 5088
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)

	sum := 0
	for i := 0; i < n; i++ {
		sum += a[i]
	}

	ans := 1 << 60
	x := 0
	for i := 0; i < n-1; i++ {
		x += a[i]
		sum -= a[i]
		ans = min(ans, abs(sum-x))
	}
	fmt.Fprintln(wr, ans)
}


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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	ll n, m;
	cin >> n >> m;
	ll q = (n*(n-1))/2;
	ll p = (m*(m-1))/2;
	cout << p + q;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int[,] card = new int[4, 13];
			for (int i = 0; i < n; i++)
			{
				string s = Console.ReadLine();
				string[] sar = s.Split(' ');
				int number = int.Parse(sar[1]);
				switch (sar[0])
				{
					case "S":
						card[0, number - 1] = 1;
						break;
					case "H":
						card[1, number - 1] = 1;
						break;
					case "C":
						card[2, number - 1] = 1;
						break;
					case "D":
						card[3, number - 1] = 1;
						break;
					default:
						Console.WriteLine("invalid type input");
						break;
				}
			}

			for (int i = 0; i < 4; i++)
			{
				for (int j = 0; j < 13; j++)
				{
					switch (i)
					{
						case 0:
							if (card[i, j] == 0) { Console.WriteLine("S {0}", j+1); }
							break;
						case 1:
							if (card[i, j] == 0) { Console.WriteLine("H {0}", j+1);}
							break;
						case 2:
							if (card[i, j] == 0) { Console.WriteLine("C {0}", j+1); }
							break;
						case 3:
							if (card[i, j] == 0) { Console.WriteLine("D {0}", j+1); }
							break;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 9092
import numpy as np
from collections import Counter
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

int1 = lambda x: int(x) - 1
N, K, L = map(int, input().split())
roads = np.array([tuple(map(int1, input().split())) for _ in range(K)]).T
railways = np.array([tuple(map(int1, input().split())) for _ in range(L)]).T


def connected(G, M):
    matr = csr_matrix((np.ones(M, dtype=int), G), shape=(N, N))
    _, labels = connected_components(matr)
    return labels


roads_connection = connected(roads, K).tolist()
railways_connection = connected(railways, L).tolist()

ct = Counter((roads_connection[i], railways_connection[i]) for i in range(N))
ans = [ct[(roads_connection[i], railways_connection[i])] for i in range(N)]
print(*ans)

Measured memory_bytes: 82648
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    vector<string> s(3);
    rep(i, 3) cin >> s[i];
    rep(i, 3) cout << s[i][i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
'use strict';

function Main(input) {
    const tmp = input.split("\n")[0].split(" ");
    const one = tmp[0] * tmp[1];
    const two = tmp[2] * tmp[3];

    if (one < two) {
        console.log(two);
    } else {
        console.log(one);
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372