akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MAX_N 1001
#define rank dfasfds
using namespace std;
int par[MAX_N],rank[MAX_N];

void init(int n){for(int i=0;i<n;i++)par[i]=i,rank[i]=0;}

int find(int x){
  if(par[x]==x)return x;
  return par[x]=find(par[x]);
}

void unite(int x,int y){
  x=find(x),y=find(y);
  if(x==y)return;
  if(rank[x]<rank[y])par[x]=y;
  else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}
bool same(int x,int y){return find(x)==find(y);}

struct edge{
  int a,b,c;
  bool operator < (edge t) const{return c<t.c;}
};

int n,m;
edge e[10001];
int solve(){
  int cnt=0,used[1001];
  init(n+1);
  for(int i=0;i<m;i++){
    if(same(e[i].a,e[i].b)) continue;
    unite(e[i].a,e[i].b);
    used[cnt++]=e[i].c;
  }
  return cnt==n-1? used[(n-1)/2]:1e9;
}

int main(){
  while(1){
  cin>>n>>m;
  if(!n&&!m)return 0;
  for(int i=0;i<m;i++)cin>>e[i].a>>e[i].b>>e[i].c;
  sort(e,e+m);
  cout<<solve()<<endl;
  }

  return 0;
}

Measured memory_bytes: 3256
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> // Common file
    #include <ext/pb_ds/tree_policy.hpp>
    #include <functional> // for less

    using namespace std;
    #define md 1000000007
    #define itn int
    #define pb push_back
    #define mp make_pair
    // #define ull unsigned long long int
    #define ll long long 
    // #define int ll
    #define ppi pair<int, int>
    #define ppl pair<ll, ll>
    #define vi vector<int>
    #define all(x) x.begin(), x.end()
    #define ff first
    #define lb lower_bound
    #define ub upper_bound
    #define ss second
    #define inf 1e9
    #define enld '\n'
    #define cuot cout
    #define trace1(x) cerr << #x << ": " << x << endl
    #define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
    #define trace3(x, y, z)                                                        \
      cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": "    \
           << z << endl
    #define trace4(a, b, c, d)                                                     \
      cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": "   \
           << c << " | " << #d << ": " << d << endl
    #define trace5(a, b, c, d, e)                                                  \
      cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": "   \
           << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
    #define trace6(a, b, c, d, e, f)                                               \
      cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": "   \
           << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | "   \
           << #f << ": " << f << endl
    #define trace(v)                                                               \
      for (auto it = v.begin(); it != v.end(); it++)                               \
        cerr << *it << " ";                                                        \
      cerr << endl;
    #define linf 1e18
    #define reset(x) memset(x, 0, sizeof(x))
    #define rep(i, a, b) for (int i = a; i < b; i++)

    using namespace __gnu_pbds;

    typedef tree<int, null_type, less<int>, rb_tree_tag,
                 tree_order_statistics_node_update>
        oset;

    void fastio() {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
    }
    
   
    void solve()
    {  
        int n;cin>>n;
        int mx=0;
        int ans=0;
        rep(i,0,n){
            int t;cin>>t;
            if(t>=mx)ans++;
            mx=max(mx,t);
        }
        cout<<ans<<endl;
    }


    signed main() {
      fastio();
      int t;
      t = 1;
      // cin >> t;
      for (int i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": ";
        solve();
      }
      return 0;
    }


Measured memory_bytes: 256
while True:
	m, f, r = map(int, input().split())
	if m == -1 and f == -1 and r == -1:
		break
	if m == -1 or f == -1:
		print("F")
	elif m + f >= 80:
		print("A")
	elif m + f >= 65:
		print("B");
	elif m + f >= 50:
		print("C")
	elif m + f >= 30:
		if r >= 50:
			print("C")
		else:
			print("D")
	else:
		print("F")



Measured memory_bytes: 5596
import java.util.*;

class Main{
  static int H,W,i,j,HH,HHH;
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (true) {
      H = sc.nextInt();
      W = sc.nextInt();
      int i = 1;
      HH = H;
      HHH = HH+1;
      if (H == 0 && W == 0) {
        break;
        }
      if (i==1) {
        for (j=0; j<W; j++) {
            System.out.print("#");
            }
            System.out.println("");
            i++;
      }
      while (i >1 && i<=H-1) {
        System.out.print("#");
        for (j=0; j<W-2; j++) {
          System.out.print(".");
        }
        System.out.print("#");
        System.out.println("");
        i++;
        }
        for (j=0; j<W; j++) {
          System.out.print("#");
          }
          System.out.println("");
          System.out.println("");
      }
  }
}



Measured memory_bytes: 32416
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
    int a,b;
    cin>>a>>b;
    string s = to_string(a) + to_string(b);
    int ab = stoi(s);
    int ans = 0;
    REP(i, 1, 10001){
        if(i*i==ab) ans = 1;
    }

    if (ans==1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main() {
    long long K, N;
    cin >> K >> N;
    vector <long long> A(N+2);
    A.at(0)=0;
    A.at(N+1)=K;
    for (long long i=1; i<=N; i++) cin >> A.at(i);
    long long ans = A.at(N)-A.at(1);
    for (long long i=1; i<=N; i++) {
        long long sei = K-A.at(i)+A.at(i-1);
        long long han = A.at(i)+K-A.at(i+1);
        ans = min(ans, min(sei, han));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = [0]*m
x = [0]*m
for i in range(m):
    p[i],x[i] = map(int,input().split())

for i in range(m):
    s=[]
    for j in range(n):
        s.append(t[j])
    s[p[i]-1] = x[i]
    print(sum(s))


Measured memory_bytes: 39024
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define LL long long
#define LP pair<LL, LL>
const LL inf = 1e17;
struct segtree {
	int n = 1;
	vector<LP> node;//cost, place
	void init(int N) {
		node.clear();
		while (N > n) n *= 2;
		node.resize(n * 2, { inf, inf });
	}

	void update(int k, LL x, int a) {

		k += n - 1;
		node[k] = { x, a };
		while (k > 0) {
			k = (k - 1) / 2;
			int l = k * 2 + 1;
			int r = k * 2 + 2;
			if (node[l].first < node[r].first) node[k] = node[l];
			else node[k] = node[r];
		}
	}

	LP mini(int a, int b, int k = 0, int l = 0, int r = -1) {

		if (r < 0) r = n;
		if (b <= l || r <= a) return { inf, inf };
		if (a <= l && r <= b) return node[k];
		LP ln = mini(a, b, k * 2 + 1, l, (l + r) / 2);
		LP rn = mini(a, b, k * 2 + 2, (l + r) / 2, r);
		if (ln.first < rn.first) return ln;
		else return rn;
	}
};

struct edge {
	LL to;
	LL cost;
	bool operator<(const edge &e1) const {
		return e1.cost < cost;
	}
};

int N;
int idx[200010];
LL D;
bool used[200010];
vector<LL> A;
vector<LP> B;
vector<edge> G[200010];

LL prim() {
	priority_queue<edge> pq;
	pq.push(edge{ 0, 0 });
	LL total = 0;
	while (!pq.empty()) {
		edge e = pq.top();
		pq.pop();
		if (!used[e.to]) {
			used[e.to] = true;
			total += e.cost;
			for (auto u : G[e.to]) {
				if (!used[u.to]) pq.push(u);
			}
		}
	}
	return total;
}

void build() {
	segtree seg;
	seg.init(N);

	for (int i = 0; i < N; i++) {
		seg.update(idx[i], A[i] + D * (N - i - 1), idx[i]);
		if (i != 0) {
			LP lp = seg.mini(0, idx[i]);
			if (lp.first == inf) continue;

			lp.first -= D * (N - i - 1) - A[i];
			G[B[lp.second].second].push_back(edge{ i, lp.first });
			G[i].push_back(edge{ B[lp.second].second, lp.first });
		}
	}

	seg.init(N);
	for (int i = N - 1; i >= 0; i--) {
		seg.update(idx[i], A[i] + D * i, idx[i]);
		if (i != N - 1) {
			LP lp = seg.mini(0, idx[i]);
			if (lp.first == inf) continue;

			lp.first -= D * i - A[i];
			G[B[lp.second].second].push_back(edge{ i, lp.first });
			G[i].push_back(edge{ B[lp.second].second, lp.first });
		}
	}
}

void init() {
	cin >> N >> D;
	for (int i = 0; i < N; i++) {
		LP tmp;
		cin >> tmp.first;
		tmp.second = i;
		A.push_back(tmp.first);
		B.push_back(tmp);
	}
	sort(B.begin(), B.end());

	for (int i = 0; i < N; i++) {
		idx[B[i].second] = i;
	}
}

int main() {
	init();
	build();
	cout << prim() << endl;
	return 0;
}

Measured memory_bytes: 44380
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
        String[] line = new String[num];
        line = s.split("");
		//System.out.println(line.length);
        String former = line[0];
        int check = 0;
        int count = 1;
        int count2 = 0;
        int index = 0;
        int sum = 0;
        int max = 0;
        int temp = 0;
        List<Integer> counter = new ArrayList<Integer>();
        List<Integer> counter2 = new ArrayList<Integer>();
        if(line[0].equals("0")) check = 1;
        if(line.length == 1) {
            counter.add(count);
            counter2.add(count);
        }
        for(int i=1; i<num; i++){
          if(line[i].equals(former)){
            count++;
          }
          else{
            check++;
            count++;
            if(line[i].equals("0")) former = "0";
            else former = "1";
          }
          if(check == 2) count2++;
          if(check == 3){
            counter.add(count-1);
            counter2.add(count-1-temp);
            count = count2+1;
            temp = count2;
            count2 = 0;
            check = 1;
          }
          if(i+1 >= num) {
            counter.add(count);
            counter2.add(count-temp);
            break;
          }
        }
        temp = 0;
        //System.out.println("size="+counter.size());
        while(true){
          //if(index+k > counter2.size()) break;
          temp = index;
          //System.out.println("index="+index+", value="+counter.get(index));
          sum += counter.get(index);
          index++;
          for(int j=1; j<k; j++){
             if(index >= counter2.size()) break;
             //System.out.println("index="+index+", value="+counter2.get(index));
             sum += counter2.get(index);
             index++;
          }
          //sum -= k-1;
          if(max < sum) max = sum;
          sum = 0;
          index = temp + 1;
          if(index+k > counter2.size()) break;
        }
        //if(max == 0) max = counter.get(0);
        System.out.println(max);
	}
}


Measured memory_bytes: 35432
s=input()
n=len(s)
a=str()
b=str()
k='keyence'
l='ecneyek'
j=0
for i in range(n):
  if a+s[i] in k:
    a+=s[i]
    j=i+1
  else:
    break
for i in range(7-j):
  if b+s[n-i-1] in l:
    b+=s[n-i-1]
  else:
    break
if a+b[::-1]==k:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3064
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	long long N, M; cin >> N >> M;
	for (int i = (M+N-1)/N; i >= 1; i--) {
		if (M%i == 0&&N*i<=M) {
			cout << i << endl; return 0;
		}
	}
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B;
    cin >> A >> B;
    if(A>8||B>8) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    string s;
    cin >> s;

    vector<string> weather = {"Sunny", "Cloudy", "Rainy"};
    cout << weather[(distance(weather.begin(), find(all(weather), s)) + 1) % 3] << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 12, 2020 07:48:40 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from collections import defaultdict
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  S = [input()[:-1] for _ in range(N)]

  M = int(input())
  T = [input()[:-1] for _ in range(M)]

  smap = defaultdict(int)
  tmap = defaultdict(int)
  for i in range(N):
    smap[S[i]] += 1
  for i in range(M):
    tmap[T[i]] += 1

  max_ = 0
  for key in smap.keys():
    max_ = max(max_, smap[key]-tmap[key])

  print(max_)


if(__name__ == '__main__'):
  main()


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

using namespace std;

long long z[0x3f3f3f];
int n,m;
int main(){
	bool flag=0;
cin>>n;
for(int i=0;i<n;i++){cin>>m;z[i]=m;
}
sort(z,z+n);
for(int i=0;i<n-1;i++){if(z[i]==z[i+1])flag=1;
}
if(flag==1)cout<<"NO";
else cout<<"YES";
return 0;
} 

Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{   
    int A,B;
  
    scanf("%d%d",&A,&B);
  
    if((A==1)&&(B==2)) printf("3\n");
    else if((A==2)&&(B==1)) printf("3\n");
    else if((A==3)&&(B==1)) printf("2\n");
    else if((A==1)&&(B==3)) printf("2\n");
    else printf("1\n");
   
    return 0;
}
  

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int q, st = 0;
  cin >> s >> q;
  vector<char> v(q * 2 + s.size());
  for(int i = q; i < q + s.size(); i++) v[i] = s[i - q];
  int b = q, e = q + s.size() - 1;
  for(int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if(t == 1)
      st = ++st & 1;
    else {
      int f;
      char c;
      cin >> f >> c;
      if(st ^ f % 2)
        v[--b] = c;
      else
        v[++e] = c;
    }
  }
  if(st)
    for(int i = e; i >= b; i--) cout << v[i];
  else
    for(int i = b; i <= e; i++) cout << v[i];
  cout << '\n';
}

Measured memory_bytes: 1232
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		int N = keyboard.nextInt();
		int K = keyboard.nextInt();
		int[] H = new int[N];
		for(int n=0; n<N; n++) {
			H[n] = keyboard.nextInt();
		}
		Arrays.parallelSort(H);
		
		int ans = 1000000001;
		for(int k=0; k+K-1<N;k++) {
			if(H[k+K-1]-H[k]<ans) {
				ans = H[k+K-1]-H[k];
			}
		}
		
		System.out.println(ans);
		keyboard.close();
	}
}


Measured memory_bytes: 59796
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		 Scanner sc=new Scanner(System.in);
		 int i=sc.nextInt();
		 int j=sc.nextInt();
		 int min=9999;
		 int arr[]=new int[j];
		 List<Integer> li1=new ArrayList<Integer>();
		 int flag=0;
		 if(j==0)
		 {
			 System.out.println(i);
			 return;
		 }
		 for(int k=0;k<j;k++)
		 {
			 arr[k]=sc.nextInt();
			 li1.add(arr[k]);
		 }
		 if(!li1.contains(i))
		 {
			 System.out.println(i);
			 return;
		 }
		
		 for(int k=0;k<=j;k++)
		 {
			if((li1.contains(i+k))&&(li1.contains(i-k)))
			 { 
				 continue;
			 }
           
			 if(!li1.contains(i-k))
			 {
				 flag=1;
				
				 System.out.println(i-k);
                 break;
				 
			 }
			 if(!li1.contains(i+k))
			 {
				 flag=1;
				 System.out.println(i+k);
                 break;
				 
			 }
			 
			 
			 
			 
			 
		 }
		 
		 
	}

}


Measured memory_bytes: 35964
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
#define int long long
const int inf = 999999999999999999;
typedef long long ll;
typedef long double ld;
struct A {
	int v, w;
};
A a[100];
int dp[10001];
signed main() {
	int n, w, ans = 0;
	cin >> n >> w;
	for (int i = 0; i < n; i++)
		cin >> a[i].v >> a[i].w;
	fill(dp, dp + 10001, -1);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
		for (int j = 10000; j >=0; j--)
			if (dp[j] != -1&&j+a[i].w<=10000)
				dp[j + a[i].w] = max(dp[j + a[i].w], dp[j] + a[i].v);
	for (int i = 0; i <= w; i++)
		ans = max(ans, dp[i]);
	cout << ans << endl;
	getchar(); getchar();
}

Measured memory_bytes: 3180
#include<iostream>
#include<algorithm>
using namespace std;
int arr[100000+5];
//筒排法
//只能对每个数进行三种操作：+1，-1，或不做处理
//思路：记录每一种可能的数出现的次数，循环遍历到10000找出最大的数即为答案 
int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		int x;
		scanf("%d",&x);
		x = x + 1;
		arr[x]++;
		arr[x - 1]++;
		arr[x + 1]++;
	}
	int max = arr[1];
	for(int i = 2;i <= 100000;i++){
		if(arr[i] >= max)
			max = arr[i];
	}
	printf("%d\n",max);
	return 0;	
} 

Measured memory_bytes: 4084
#include<iostream>
#include<vector>
using namespace std;
#define int long long int
int count=0;
int answer=0;
void function(vector<int> &v,int initial,int final,int prev,int m,int arr[][4],int q)
{
	if(initial>final)
	{
		count++;
		int here=0;
		int j;
		for(j=0;j<q;j++)
		{
			int a=arr[j][0]-1;
			int b=arr[j][1]-1;
			int c=arr[j][2];
			int d=arr[j][3];
			if(v[b]-v[a]==c)
			{
				here+=d;
			}
		}
		answer=max(answer,here);
	}
	else
	{
		int j;
		for(j=prev;j<=m;j++)
		{
			v.push_back(j);
			function(v,initial+1,final,j,m,arr,q);
			v.pop_back();
		}
	}
}
int32_t main()
{
	int x;
	cin>>x;
	int s=0;
	int count=100;
	while(count<x)
	{
		s++;
		int in=count/100;
		count+=in;
	}
	cout<<s<<endl;
}


Measured memory_bytes: 3644
def solve():
    N = int(input())
    A = []
    for _ in range(N):
        A.append(input())

    A.sort()
    count = 1
    if N != 1:
        for i in range(1, N):
            if A[i - 1] != A[i]:
                count += 1
    print(count)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 24036
#include <bits/stdc++.h>
#define ll int64_t
#define ar array
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (n); ++i) 
using namespace std;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), cnt(1e6+5);
    forn(i,n){
        cin>>a[i];
        cnt[a[i]]++;
    }
    int ans=0;
    forn(i,n){
        cnt[a[i]]--;
        bool fl=false;
        for(int j=1;j*j<=a[i];++j){
            if(a[i]%j==0){
                fl|=(cnt[j]!=0);
                fl|=(cnt[a[i]/j]!=0);
            }
        }
        ans+=(!fl?1:0);
        cnt[a[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 7952
#include<stdio.h>

int main(){

    int W,H,x,y,r;
    
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

    if( x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H){

        printf("Yes\n");

   }else{
      
        printf("No\n");

}

return 0 ;

}
 
 


Measured memory_bytes: 2100
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
const int MAX_N = 100;
struct Station {
	double x, y, z, r;
};

int n;
Station stations[MAX_N + 1];
bool used[MAX_N];

double getdist(int A, int B) {
	const Station& a = stations[A];
	const Station& b = stations[B];
	double dx = a.x - b.x, dy = a.y - b.y, dz = a.z - b.z;
	double d = sqrt(dx * dx + dy * dy + dz * dz);
	return max(d - (a.r + b.r), 0.);
}

double prim() {
	typedef pair<double, int> Node;
	
	double result = 0;
	priority_queue<Node, vector<Node>, greater<Node> > que;
	fill(used, used + n, false);
	que.push(make_pair(0., 0));
	while (!que.empty()) {
		Node current = que.top();
		que.pop();
		double dist = current.first;
		int pos = current.second;
		if (used[pos]) continue;
		used[pos] = true;
		result += dist;
		for (int i = 0; i < n; i++) {
			if (i == pos || used[i]) continue;
			que.push(make_pair(getdist(pos, i), i));
		}
	}
	return result;
}

int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> stations[i].x >> stations[i].y >> stations[i].z >> stations[i].r;
		}
		printf("%.3lf\n", prim());
	}
	return 0;
}

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

int main() {
  int n,i,j,l;
  double s[10020];
  double a2,m,a;
  
  while(1) {
    m=0;
    a2 = 0;
    scanf("%d" , &n);
    if(n == 0) {
      break;
    }

    for(i=0;i<n;i++) {
      scanf("%lf", &s[i]);
	m=m+s[i];
	//printf("m[%d] = %lf\n",i ,m);
    }
    m=m/n;

    for(i=0; i<n; i++) {
      a2 =a2+(s[i]-m)*(s[i]-m);
    }
    a2 = a2/n;

    printf("%.11lf\n",sqrt(a2));

  }

  return 0;

}

Measured memory_bytes: 672
import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val a = ArrayList<List<Int>>()

    if (N % 2 == 0) {
        for (i in 1 .. N / 2) {
            a.add(listOf(i, N + 1 - i))
        }
    } else {
        a.add(listOf(N))
        for (i in 1 .. N / 2) {
            a.add(listOf(i, N - i))
        }
    }

    val edges = ArrayList<List<Int>>()
    for (i in a.indices) {
        for (j in i + 1 until a.size) {
            for (k in a[i]) for (l in a[j]) {
                edges.add(listOf(k, l))
            }
        }
    }
    println(edges.size)
    for (e in edges) {
        println(e.joinToString(" "))
    }
}


Measured memory_bytes: 41304
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max({a*c, a*d, b*c, b*d}) << "\n";
    return 0;
}

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

int main(void)
{
    int h, w;
    cin >> h >> w;

    vector<string> board(h);

    for (int i = 0; i < h; i++){
        cin >> board.at(i);
    }
    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (board.at(i).at(j) == '#'){
                row.at(i) = true;
                col.at(j) = true;
            }
        }
    }
    int cnt;
    for (int i = 0; i < h; i++){
        cnt = 0;
        if(row.at(i)){
            for (int j = 0; j < w; j++){
                if (col.at(j)){
                    cout << board.at(i).at(j);
                    cnt++;
                }
            }
        }
    if(cnt!=0)
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
pow = 0
ans = 0
for i in range(N):
    ans += A[i] if pow >= A[i] else pow
    A[i] = 0 if pow >= A[i] else A[i] - pow
    ans += A[i] if A[i] <= B[i] else B[i]
    pow = B[i] - A[i] if B[i] >= A[i] else 0
ans += A[N] if pow >= A[N] else pow
print(ans)

Measured memory_bytes: 19156
#include<bits/stdc++.h>
 
using namespace std;
 
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS )
#define dle(a, b) (equals(a, b) || a < b )

static const double PI = acos(-1);

class Point{
public:
  double x, y;
  Point ( double x = 0, double y = 0): x(x), y(y){}
  Point operator + ( Point p ){ return Point(x + p.x, y + p.y); }
  Point operator - ( Point p ){ return Point(x - p.x, y - p.y); }
  Point operator * ( double a ){ return Point(x*a, y*a); }
  Point operator / ( double a ){ return Point(x/a, y/a); }
  double abs() { return sqrt(norm());}
  double norm() { return x*x + y*y; }
  bool operator < ( const Point &p ) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == ( const Point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;


class Segment{
    public:
    Point p1, p2;
    Segment(Point s = Point(), Point t = Point()): p1(s), p2(t){}
};
typedef Segment Line;

double norm( Vector a ){ return a.x*a.x + a.y*a.y; }
double abs( Vector a ){ return sqrt(norm(a)); }
double getDistance( Vector a, Vector b ){ return abs(a - b); }
double dot( Vector a, Vector b ){ return a.x*b.x + a.y*b.y; }
double cross( Vector a, Vector b ){ return a.x*b.y - a.y*b.x; }

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
 
int ccw( Point p0, Point p1, Point p2 ){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if ( cross(a, b) > EPS ) return COUNTER_CLOCKWISE;
    if ( cross(a, b) < -EPS ) return CLOCKWISE;
    if ( dot(a, b) < -EPS ) return ONLINE_BACK;
    if ( norm(a) < norm(b) ) return ONLINE_FRONT;
    return ON_SEGMENT;
}
 
Point getCrossPointLL(Line l1,Line l2){
  Point p1=l1.p1,p2=l1.p2;
  Point q1=l2.p1,q2=l2.p2;
  Point res;
  res= p1+(p2-p1)*( cross(q2-q1,q1-p1)/cross(q2-q1,p2-p1) );
  return res;
}

double calcArea(vector<Point> &po){
  int size=po.size();
  if(size<3)return 0.0;
  double res=0.0;
  for(int i=1;i+1<size;i++){
    res+=fabs(cross(po[i]-po[0],po[i+1]-po[0]));
  }
  return res*0.5;
}

#define MAX_N 200
int n;
vector<Point> t;
Line li;

void solve(){
  vector<Point> u;
  int A[MAX_N];

  for(int i=0;i<n;i++)A[i]=ccw(li.p1,li.p2,t[i]);

  for(int i=0;i<n;i++){
    if(A[i]!=CLOCKWISE)u.push_back(t[i]);
    int j=(i+1)%n;
    if(A[i]==COUNTER_CLOCKWISE
       &&A[j]==CLOCKWISE)
      u.push_back( getCrossPointLL(Line(t[i],t[j]),li));
    else if(A[j]==COUNTER_CLOCKWISE
       &&A[i]==CLOCKWISE)
      u.push_back( getCrossPointLL(Line(t[i],t[j]),li));
  }

  printf("%.8f\n",calcArea(u));
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    Point p;
    cin>>p.x>>p.y;
    t.push_back(p);
  }
  int Tc;
  cin>>Tc;
  while(Tc--){
    cin>>li.p1.x>>li.p1.y>>li.p2.x>>li.p2.y;
    solve();
  }
  return 0;
}

Measured memory_bytes: 1264
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var S = ReadLine();
            WriteLine(Regex.Match(S, "^[A]?KIH[A]?B[A]?R[A]?$").Success?"YES":"NO");
        }
    }
}

Measured memory_bytes: 21644
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double db;
typedef vector<ll> VI;
typedef vector<pair<ll,ll> > VII;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
//
#define M 1000000007
#define INF (ll)0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define itr iterator
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}

void error_out() { cerr << endl; }
template <typename Head, typename... Tail>
void error_out(Head H, Tail... T) {
  cerr << " " << H;
  error_out(T...);
}
void time_elapsed(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}
#ifndef ONLINE_JUDGE
#define error(...) cerr << "[" << #__VA_ARGS__ << "]:", error_out(__VA_ARGS__)
#define fioe() fileioe()
#define time() time_elapsed()
#else
#define error(...) 1
#define fioe() 1
#define time() 1
#endif
//!
const int maxr1=102;
const int maxr2=100002;
ll dp[maxr1][maxr2];
ll knapsnak(ll arr[][2],ll size,ll ind,ll weight){
	if(ind==size){
		if(weight>=0){
			return 0;
		}
		return -INF;
	}
	if(weight<0){
		return -INF;
	}
	ll &ans=dp[ind][weight];
	if(ans!=-1){
		return ans;
	}
	ans=INF;
	ll ans1=knapsnak(arr,size,ind+1,weight);
	ll ans2=knapsnak(arr,size,ind+1,weight-arr[ind][0])+arr[ind][1];
	ans=max(ans1,ans2);
	return ans;
}
//
int main()
{
	GO
	//fioe();
	ll n,w;
	cin>>n>>w;
	ll arr[n+2][2];
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<n;i++){
		cin>>arr[i][0]>>arr[i][1];
	}
	cout<<knapsnak(arr,n,0,w)<<endl;
	time();
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  ll h = 0;
  ll ans = 0;
  rep(i,n) {
    if(a[i] < h) ans += h - a[i];
    h = max(h,a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5180
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int h, w;
char board[110][110];
string dir = "v^><";
signed main() {
    while(cin >> h >> w, h || w) {
        rep(i,0,h) rep(j,0,w) cin >> board[i][j];
        bool used[110][110] = {}, loop = false;
        int x = 0, y = 0;
        while(1) {
            if(board[x][y] == '.') break;
            if(used[x][y]) {loop = true; break;}
            used[x][y] = true;
            int t = dir.find(board[x][y]);
            x += dx[t], y += dy[t];
        }
        if(loop) cout << "LOOP" << endl;
        else printf("%lld %lld\n", y, x);
    }
    return 0;
}

Measured memory_bytes: 3224
//#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
//#include<math.h>
//#include<complex>
#include<algorithm>
using namespace std;

#define LL long long
LL n,ten[33];int len=0;
int main()
{
	scanf("%lld",&n);
	ten[len=0]=1; for (;ten[len]<=n;ten[len+1]=ten[len]*10,len++);
	int ans=0;
	for (int i=0;i<len;i++) ans+=n/ten[i]%10;
	int now=ans-1;
	for (int i=1;i<len;i++) {now=now+9-n/ten[i-1]%10; if (n/ten[i]%10>0) ans=max(ans,now);}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int A =sc.nextInt();
    int B =sc.nextInt();
    int C =sc.nextInt();
    int D =sc.nextInt();
    while(A*C>0){
      C=C-B;
      if(C<=0){System.out.println("Yes");System.exit(0);}
      A =A-D;
      if(A<=0){System.out.println("No");System.exit(0);}
    }
  }
}

Measured memory_bytes: 35916
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,K; cin >> N >> K;
    int ans = 1;
    for(int i = 0; i < N; i++)
    {
        if(2*ans >= ans + K)
        {
            ans += K;
        }
        else
        {
            ans *= 2;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N, T;
  cin >> N >> T;
  int ans = 10000;
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if (t <= T) {
      ans = min(ans, c);
    }
  }
  if (ans == 10000) {
    cout << "TLE" << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  string s,t;

  cin >> s >> t;

  int max=-1;
  int c;
  for(int i=0;i<=s.length()-t.length();i++) {
    c=0;
    for(int j=0;j<t.length();j++) {
      if(s[i+j]==t[j]){c++;}
    }
    if(max<c) max=c;
    // cout<<c<<endl;
  }

  cout <<t.length()-max<< endl;

  return 0;
}


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

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

 int n,m;
 cin >> n >> m;

 if(n&1){
 	for(int i=1; i<=m; i++){
 		cout << i << " " << n+1-i << "\n";
 	}
 }

 else {
 	int k = n/2;
 	int temp = 0;
 	if(k&1){
 		for(int i=1; i<=(k-1)/2; i++){
 			if(temp >= m) {break;}
 			cout << i << " " << 2*k - i << "\n";
 			temp++;
 		}
 		for(int i=(k+1)/2; i<=k-1; i++){
 			if(temp >= m) {break;}
 			cout << i << " " << 2*k-1-i << "\n";
 			temp++;
 		}
 	} else {
 		for(int i=1; i<k/2; i++){
 			if(temp >= m) {break;}
 			cout << i << " " << 2*k - i << "\n";
 			temp++;
 		}
 		for(int i=k/2; i<=k-1; i++){
 			if(temp >= m) {break;}
 			cout << i << " " << 2*k-1-i << "\n";
 			temp++;
 		}
 	}
 }


}


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

using namespace std;
int main(){
    string s,t;cin>>s>>t;                                                                                                if(s.length() < 1 || s.length() > 10 ){                                                                                  cout << "No" << endl;                                                                                                return 0;                                                                                                        }
    if(s.length()+1 != t.length()){
        cout<< "No" << endl;                                                                                                 return 0;                                                                                                        }
    for(int i = 0; i < t.length() - 1;i++){                                                                                  if(s[i] != t[i]) {                                                                                                       cout << "No"<<endl;                                                                                                  return 0;
        }
        if(!(islower(s[i]))){
            cout << "No" << endl;                                                                                                return 0;                                                                                                        }
    }
    if(!(islower(t[t.length()-1]))){                                                                                         cout << "No" <<endl;                                                                                                 return 0;
    }                                                                                                                    cout << "Yes" << endl;
    return 0;
} 

Measured memory_bytes: 3628
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))

#ifdef ONLINE_JUDGE
#define link renamelink
#define next renamenext
#define prev renameprev
#endif

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef long double ld;

inline void EnableFileIO(const string& fileName, bool local = 0) {
  if (fileName.empty()) return;
  if (local) {
    freopen((fileName + ".in").c_str(), "r", stdin);
    freopen((fileName + ".out").c_str(), "w", stdout);
    return;
  }
#ifdef ONLINE_JUDGE
  freopen((fileName + ".in").c_str(), "r", stdin);
  freopen((fileName + ".out").c_str(), "w", stdout);
#endif
}

const int INF = (1 << 30) - 1;
const LL LINF = (1LL << 61) - 1;
const double EPS = 1e-10, PI = acos(-1);
const int N = 2e5 + 100;

int n, q;
int b[N], pre[N];
pii s[N];
int val[N * 2], f[N * 2];

void mod(int p, int v) {
  p += n;
  val[p] = min(val[p], v);
  for (; p; p >>= 1) val[p >> 1] = min(val[p], val[p ^ 1]);
}
int ask(int l, int r) {
  int res = INF;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res = min(res, val[l++]);
    if (r & 1) res = min(res, val[--r]);
  }
  return res;
}
int main() {
  // srand((int)time(0));
  // printf("Hello, world!\n");
  // EnableFileIO("");

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    pre[i] = (i ? pre[i - 1] : 0) + 1 - b[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> s[i].first >> s[i].second;
    --s[i].first, --s[i].second;
  }
  sort(s, s + q);
  fill(val, val + N * 2, INF);
  fill(f, f + N * 2, INF);
  // cerr << f[N * 2 - 1] << endl;

  for (int i = 0, j = 0; i < n; i++) {
    f[i] = min(f[i], (i ? f[i - 1] : 0) + b[i]);
    for (; j < q; j++) {
      if (s[j].first != i) break;
      int k = s[j].second;
      int v =
          min(pre[k] + (i ? f[i - 1] - pre[i - 1] : 0), ask(i, k + 1) + pre[k]);
      f[k] = min(f[k], v);
      mod(k, v - pre[k]);
    }
  }
  cout << f[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <string.h>
int main(void)
{
	int a[101];
	int n;
	int i,j;
	int temp,temp2;
	int x=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		
		scanf("%d",&a[i]);
		
	}
	for(i=0;i<n;i++){
		temp=i;
		for(j=i;j<n;j++){
			if(a[j]<a[temp]){
			temp=j;
			
			}
			}
			temp2=a[temp];
			a[temp]=a[i];
			a[i]=temp2;
			if(temp!=i){
				x++;
			}
		}
	
	for(i=0;i<n;i++){
		if(i==n-1){
			printf("%d\n",a[i]);
		}else{
		printf("%d ",a[i]);
		}
	}
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 2104
while True:
    N,M = map(int,input().split())
    if N == M == 0: break
    logs = []
    for i in range(M):
        t,s,d = map(int,input().split())
        s,d = s-1,d-1
        logs.append((t,s,d))
    infected = [0 for i in range(N)]
    infected[0] = 1
    for t,s,d in sorted(logs):
        if infected[s]:
            infected[d] = 1
    print(sum(infected))

Measured memory_bytes: 9504
#include <bits/stdc++.h>
// #include <limits>
//auto std::numeric_limits<float>::infinity() { return __builtin_huge_valf(); }
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)

int main()
{
    //A
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB")
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main() {


	int n, k;
	vector<int>p;
	double sum = 0;
	double max = 0;
	int input;
	vector<double>kitai;

	cin >> n >> k;



	for (int i = 0; i < n; i++) {

		cin >> input;
		p.push_back(input);
	}

	for (int i = 0; i < n; i++) {
		kitai.push_back( 1 + 0.50*(p[i] - 1));
	}
	for (int i = 0; i < k; i++) {
		sum += kitai[i];
	}
	max = sum;


	for (int i = k; i < n; i++) {
		sum = sum + kitai[i] - kitai[i - k];

		if (sum > max) max = sum;

	}

	printf("%.12f", max);





	return 0;

}

Measured memory_bytes: 3188
D = int(input())
c = [int(x) for x in input().split()]
s = []
for i in range(D):
    s.append([int(x) for x in input().split()])
kotae = 0
nissuu = [0] * 26
key = ""
for k in range(26):
  nissuu = [0] * 26
  ans = 0  
  for i in range(D):
    t = (i+k) % 26 + 1
    for j in range(26):
        if j == t-1:
            nissuu[j] = 0
        else:
            nissuu[j] += 1
        ans -= c[j]*nissuu[j]
    ans += s[i][t-1]
    if kotae <= ans:
        kotae = ans
        key = k
for i in range(D):
    print((i+key) % 26 + 1)


Measured memory_bytes: 9508
s = input()
l = len(s)
dp = [0 for i in range(2019)]
dp[0] = 1
r = 0
for i in range(1, l + 1):
    r += int(s[-i]) * pow(10, i - 1, 2019)
    r %= 2019
    dp[r] += 1
    
print(sum([(i * (i - 1)) // 2 for i in dp]))

Measured memory_bytes: 9248
// https://atcoder.jp/contests/abc139/tasks/abc139_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, h: [i64; n]
    };

    let mut dp = vec![0; n];
    let mut ans = 0;
    for i in (0..n-1).rev() {
        if h[i] >= h[i+1] {
            dp[i] = dp[i+1] + 1;
            ans = max(ans, dp[i]);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
N=int(input())
D={}
for i in range(2,int(N**0.5)+1):
    n=N
    #print(i,n)
    while n%i==0 and n!=i:
        n//=i
    #print(i,n)
    if n==i or n%i==1:
        D[i]=1
        #print("ANS",i,n)
#print(D)
N1=N-1
for i in range(1,int(N1**0.5)+1):
    if N1%i==0:
        D[i]=1
        D[N1//i]=1
#print(D)
print(len(D))
        


Measured memory_bytes: 40172
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
ll dp[3000][3000]={};
signed main(){
  init_io();
  ll n,m;
  cin >> n >> m;
  vector<ll> s(n),t(m);
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  for(int i=0;i<m;i++){
    cin >> t[i];
  }
  for(int i=0;i<=n;i++){
    dp[i][0]=1;
  }
  for(int i=0;i<=m;i++){
    dp[0][i]=1;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      dp[i+1][j+1] = dp[i+1][j]+dp[i][j+1];
      if(s[i]!=t[j]){
        dp[i+1][j+1] -= dp[i][j];
      }
      dp[i+1][j+1]%= MOD;
    }
  }
  ll v = dp[n][m];
  while(v<0) v+= MOD;
  v%= MOD;
  cout << v << endl;
}


Measured memory_bytes: 47104
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  string s;
  cin >> s;
  if (s[s.size() - 1] == 's') {
    s.append("es");
  } else {
    s.push_back('s');
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3056
# coding: utf-8
import sys
from itertools import accumulate

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
Acum = list(accumulate(A))
slice1 = 0; slice3 = 2
answer = 10 ** 15
for i in range(1, N-2):
    # iが2つめの部分列の右端のindex
    slice2 = i
    if slice3 <= slice2:
        slice3 = slice2 + 1
    p = Acum[slice1]; q = Acum[slice2] - p
    r = Acum[slice3] - Acum[slice2]; s = Acum[-1] - Acum[slice3]
    while slice1 < i-1:
        p2 = Acum[slice1+1]
        q2 = Acum[slice2] - p2
        if abs(p2-q2) < abs(p-q):
            slice1 += 1
            p = p2; q = q2
        else:
            break
    while slice3 < N-2:
        r2 = Acum[slice3+1] - Acum[slice2]
        s2 = Acum[-1] - Acum[slice3+1]
        if abs(r2-s2) < abs(r-s):
            slice3 += 1
            r = r2; s = s2
        else:
            break
    ma = max(p, q, r, s); mi = min(p, q, r, s)
    temp = ma - mi
    if temp < answer:
        answer = temp
    
print(answer)
# 47

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

struct Point {double x,y;};

void koch(int n, struct Point a, struct Point b){
  if(n==0) return;
  struct Point s, t, u;
  double th = M_PI*60.0/180.0;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1, a, s);
  printf("%.8f %.8f\n", s.x,s.y);
  koch(n-1, s, u);
  printf("%.8f %.8f\n", u.x,u.y);
  koch(n-1, u, t);
  printf("%.8f %.8f\n", t.x,t.y);
  koch(n-1, t, b);
}

int main(){
  struct Point a,b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n", a.x,a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x,b.y);

  return 0;
}



Measured memory_bytes: 2056
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 10000)

func readLine() string {
	buf := make([]byte, 0, 10000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	readLine()
	ins := strings.Split(readLine(), " ")

	n := len(ins)
	var p []int
	for _, v := range ins {
		pi, _ := strconv.Atoi(v)
		p = append(p, pi)
	}

	var count int
	for i := 1; i < n-1; i++ {
		if (p[i-1] < p[i] && p[i] < p[i+1]) || (p[i+1] < p[i] && p[i] < p[i-1]) {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 640