akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n,m;
int tl[22222];
int main(void){
  while(cin >> n >> m && n+m){
    for(int i = 1; i <= n+m; i++) cin >> tl[i];
    sort(tl,tl+n+m+1);
    int res = 0;
    for(int i = 1; i <= n+m; i++) res = max(res,tl[i]-tl[i-1]);
    cout << res << endl;
  }
}

Measured memory_bytes: 1256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
typedef long long ll;

int n, in;
vector<int> a, b, c;
ll ans = 0;

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

	for (int i = 0; i < n; i++) {
		vector<int>::iterator itr = lower_bound(a.begin(), a.end(), b[i]);
		ll uppernum = distance(a.begin(), itr);
		vector<int>::iterator itr2 = upper_bound(c.begin(), c.end(), b[i]);
		ll lowernum = c.size()-distance(c.begin(), itr2);
		ans += uppernum*lowernum;
	}

	cout << ans << endl;
}

Measured memory_bytes: 2416
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int x[n];
  int y[n];
  double xx[n];
  double yy[n];
  int i,j;
  for(i=0;i<n;i++){
    cin >> x[i] >> y[i];
    xx[i] = (double)x[i];
    yy[i] = (double)y[i];
  }
  int nkai = 1;
  for(i=2;i<=n;i++){
    nkai*=i;
  }
  double ans = 0.0;
  double tmp = 0.0;

  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      tmp += sqrt((xx[i]-xx[j])*(xx[i]-xx[j])+(yy[i]-yy[j])*(yy[i]-yy[j]));
    }
  }
  ans = tmp * (n-1) /(n*(n-1)/2);
  printf("%.10lf",ans);
}

Measured memory_bytes: 256
/*
 *created by Kraken on 26-04-2020 at 16:47
 */
import java.util.*;
import java.io.*;

public class Main {

  public static void main(String[] args) {
    FastReader sc = new FastReader();
    int s = sc.nextInt(), w = sc.nextInt();
    System.out.println((w >= s) ? "unsafe" : "safe");
  }

  static class FastReader {

    BufferedReader br;

    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        }
        catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      }
      catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 32844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
long long dp[100010][3];
long long a[100010][3];

int main()
{
    int N; cin >> N;
    rep(i, N)
    {
        rep(j, 3) cin >> a[i][j];
    }

    rep(i, N)
    {
        rep(j, 3)
        {
            rep(k, 3)
            {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    long long ans = 0;
    rep(j, 3) chmax(ans, dp[N][j]);
    cout << ans << endl;
}


Measured memory_bytes: 4992
N = int(input())
s = []
t = []

for _ in range(N):
    si, ti = input().split()
    s.append(si)
    t.append(int(ti))

X = input()
ans = 0
flag = False

for i in range(N):
    if flag:
        ans += t[i]
        
    if s[i]==X:
        flag = True

print(ans)

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

int main(){
    int N,A,B,p1,p2;

    cin >> N >> A >> B;
    
    p1 = N * A; p2 = B;
    if(p1 > p2)
        cout << p2 << endl;
    else
        cout << p1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


struct Node {
    LL i, j, d;
};

struct Move {
    LL i, j;
};
vector<Move> dirs{Move{-1, 0}, Move{1, 0}, Move{0, -1}, Move{0, 1}};

int main() {
    LL H, W;
    cin >> H >> W;
    vector<vector<bool>> visited(H, vector<bool>(W));
    queue<Node> q;
    REP(i, H) {
        string s;
        cin >> s;
        REP(j, SZ(s)) {
            if (s[j] == '#') {
                visited[i][j] = true;
                q.push(Node{i, j, 0});
            }
        }
    }
    LL ans;
    while (!q.empty()) {
        Node n = q.front();
        q.pop();
        ans = n.d;
        EACH(dir, dirs) {
            LL i = n.i + dir.i, j = n.j + dir.j;
            if (0 <= i && i < H && 0 <= j && j < W && !visited[i][j]) {
                visited[i][j] = true;
                q.push(Node{i, j, n.d + 1});
            }
        }
    }
    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 24628
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long LL;
const int N=2e5;
LL gi() {
	LL w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9')&&c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c<='9') w=w*10+c-'0',c=getchar();
	return q?w:-w;
}
LL s[N];
int f[N],g[N],F[N],G[N];
int main()
{
	const int mod=1e9+7;
	int n=gi()+1,i,k,ca=0,cb=0;
	LL A=gi(),B=gi();
	s[1]=-1LL<<60;for (i=2;i<=n;i++) s[i]=gi();
	f[1]=g[1]=1;
	for (i=3;i<=n;i++) {
		k=min(i-2,int(upper_bound(s+1,s+1+i,s[i]-A)-s-1));
		if (cb<k)
			(f[i-1]+=g[k]-g[cb])%=mod;

		k=min(i-2,int(upper_bound(s+1,s+1+i,s[i]-B)-s-1));
		if (ca<k)
			(g[i-1]+=f[k]-f[ca])%=mod;
		
		if (s[i]-s[i-1]<A)
			ca=i-2;
		if (s[i]-s[i-1]<B)
			cb=i-2;

		(f[i-1]+=f[i-2])%=mod;
		(g[i-1]+=g[i-2])%=mod;
	}
	printf("%d\n",int(((LL)f[n-1]-f[ca]+g[n-1]-g[cb])%mod+mod)%mod);
	
	return 0;
}


Measured memory_bytes: 2688
l = [int(input()) for _ in range(5)]
l.sort(key=lambda x: 10 if x%10==0 else x%10)
l = l[::-1]
ans = 0
for i in range(5):
    if i == 4 or l[i]%10==0:
        ans += l[i]
    else:
        ans += ((l[i]//10)+1)*10
print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    int n = sc.nextInt(), cnt=0, t;
	    if(n == 0) break;
	    int[] a = new int[n+1];
	    for(int i = 0; i < n; i++) a[i] = sc.nextInt();

	    for(int i = n-1; i > 0; i--)
		for(int j = 1; j <= i; j++)
		    if(a[j-1] > a[j]){
			t = a[j-1];
			a[j-1] = a[j];
			a[j] = t;
			cnt++;
		    }

	    System.out.println(Integer.toString(cnt));
	}
    }

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

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    if (a.at(i) == 0) {
      cout << 0 << '\n';
      return 0;
    }
  }
  
  ll ans = 1;
  for (int i = 0; i < n; i++) {
    if (1e18 / ans >= a.at(i)) {
      ans *= a.at(i);
    }
    else {
      cout << -1 << '\n';
      return 0;
    }
  }
  
  if (ans > (ll) 1e18) cout << -1 << '\n';
  else cout << ans << '\n';
}

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

int N,M,x,y,z;

struct UnionFind {
    vector<int> parent;
    int size;
    UnionFind(int n) :parent(n, -1), size(n) {}
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y)return false;
        if (sizeOf(x) < sizeOf(y))swap(x, y);
        parent[x] += parent[y]; parent[y] = x; size--;
        return true;
    }
    int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
    int sizeOf(int x) { return -parent[root(x)]; }
};

int main(){
    cin >> N >> M;
    UnionFind uf(N+1);
    REP(i,M){
        cin >> x >> y >> z;
        --x;--y;
        uf.unite(x,y);
    }
    int ans = 0;
    REP(i,N) if(i==uf.root(i)) ++ans;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
import std.stdio;
import std.string;
import std.math;
import std.conv;
import std.algorithm;
import std.bigint;

int[] a;

void main(){

    auto s = split(readln());
    int temp;
    for(int i=0;i<5;i++){
	a ~= to!int(s[i]);;
    }
    sort!("a > b")(a);
    writef("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);

}

Measured memory_bytes: 2528
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {
	uint H, W;
	cin >> H >> W;

	uint mod = pow(10, 9) + 7;

	vector<uint> cmb(W);
	cmb[0] = 1;

	for(uint i=0; i<H; i++) {
		string l;
		cin >> l;
		
		for(uint j=0; j<W; j++) {
			if(l[j] != '.'){
				cmb[j] = 0;
			} else if(j > 0) {
				cmb[j] = (cmb[j-1] + cmb[j]) % mod;
			} else {
				cmb[j] = cmb[j];
			}
		}
	}

	cout << cmb[W-1] << endl;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//string alp = "abcdefghijklmnopqrstuvwxyz";
using namespace std;
int main(){
  string n;
  cin >> n;
  cout << "ABC" << n << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_166
{
    class D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long x = ReadLong();
            var dict = new Dictionary<long, long>();
            for(long i = -150; i <= 150; i++)
            {
                long val = i * i * i * i * i;
                dict.Add(i, val);
            }

            foreach(long a in dict.Keys)
            {
                foreach(long b in dict.Keys)
                {
                    long val = dict[a] - dict[b];
                    if (val == x)
                    {
                        WriteLine(a + " " + b);
                        return;
                    }
                }
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll , ll> P;
typedef pair<ll, ll> PL;
const ll INT_INF = 2147483646;
const ll ll_INF = 9223372036854775807;
ll mod = 1e9+7;

bool SecondCompare(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
	       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
	       return a.second>b.second;
}

ll gcd(ll big, ll small){
    ll tmp = big%small;

    if(tmp == 0) return small;
    return gcd(small,tmp);
}

ll n;
const ll size = 1e5+10;
ll a[size];

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

    sort(a,a+n);

    ll sw = ll_INF;
    for(int i = 0; i < n; i++){
        sw = min(gcd(a[i],a[0]),sw);
    }

    ll ans = sw;

    cout << sw << endl;
}

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

struct StList
{
  int  m_iKey;
  StList *m_poPrev;
  StList *m_poNext;
  
  StList() :
    m_iKey(0), m_poPrev(nullptr), m_poNext(nullptr)
  { }

  StList(int a_iNumber, StList &a_roHead) :
    m_iKey(a_iNumber), m_poPrev(&a_roHead), m_poNext(a_roHead.m_poNext)
  { }

  ~StList() { }
};

void fnLinkedListSet(StList &a_roHead, StList &a_roTrail)
{
  char acCommand[80];
  int iMaxCommand, iNumber;

  cin.tie(0);
  ios::sync_with_stdio(false);
 
  cin >> iMaxCommand;
  for (int i = 0; i < iMaxCommand; i++)
  {
    cin >> acCommand;
    if (acCommand[0] == 'i')
    {
      cin >> iNumber;
      StList *poList = new StList(iNumber, a_roHead);
      a_roHead.m_poNext->m_poPrev = poList;
      a_roHead.m_poNext = poList;
    }
    else if (acCommand[6] == 'F')
    {
      StList *poList = a_roHead.m_poNext;
      poList->m_poNext->m_poPrev = poList->m_poPrev;
      a_roHead.m_poNext         = poList->m_poNext;
      delete poList;
    }
    else if (acCommand[6] == 'L')
    {
      StList *poList = a_roTrail.m_poPrev;
      a_roTrail.m_poPrev        = poList->m_poPrev;
      poList->m_poPrev->m_poNext = poList->m_poNext;
      delete poList;
    }
    else if (acCommand[0] == 'd')
    {
      cin >> iNumber;
      StList *poList = a_roHead.m_poNext;
      while (poList != &a_roTrail)
      {
        if (poList->m_iKey == iNumber)
        {
          poList->m_poNext->m_poPrev = poList->m_poPrev;     
          poList->m_poPrev->m_poNext = poList->m_poNext;
          delete poList;
          break;
        }
        poList = poList->m_poNext;
      }
    }
  }
}

void fnLinkedListGet(StList &a_roHead, StList &a_roTrail)
{
  StList *poList = a_roHead.m_poNext;
  while (poList != &a_roTrail)
  {
    if (poList != a_roHead.m_poNext) cout << " ";
    cout << poList->m_iKey;
    poList = poList->m_poNext;
    delete poList->m_poPrev;
  }
  cout << endl;
}

int main()
{
  StList oHead, oTrail;
  oHead.m_poNext  = &oTrail;
  oTrail.m_poPrev = &oHead;

  fnLinkedListSet(oHead, oTrail);
  fnLinkedListGet(oHead, oTrail);

  return 0;
}

Measured memory_bytes: 32460
n, mx = map(lambda s: int(s), list(input().split()))
xs = map(lambda s: int(s), list(input().split()))

mn = 9999999999

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

for x in xs:
    d = abs(mx-x)
    if mn == 9999999999:
        mn = d
    else:
        mn = gcd(mn, d)
print(mn)

Measured memory_bytes: 11096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ld A,B;
    string S;
    cin >> A >> B;
    cout << ll(A*B) << endl;
}


Measured memory_bytes: 3764
#include "bits/stdc++.h"

#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, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()


using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> x(N);
	for (int i = 0; i < N; i++) cin >> x[i];

	vector<int> souwa(N - K + 1, 1e9);
	for (int i = 0; i < N - K + 1; i++)
	{
		int left = i;
		int right = K + i;

		for (int l = left; l < right; l++)
		{
			souwa[i] = min(abs(x[left]) + abs(x[right - 1] - x[left]), abs(x[right - 1]) + abs(x[right - 1] - x[left]));
		}
	}

	sort(souwa.begin(), souwa.end());

	cout << souwa[0] << endl;

	return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define FOR(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	string s;
	cin>>s;
	rep(i,s.size()){
		putchar(s[s.size()-i-1]);
	}
puts("");
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


class BIT   // 1-indexed (0 is not used)
{
private:
    int num;
    vector<ll> bit;
public:
    BIT(int n):bit(vector<ll>(n+1, 0)), num(n) {}

    ll sum(int i) {   // sum of 1..i
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, ll x) {
        if (i > num) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};


int main(int argc, char* argv[])
{
    int Q;
    scanf("%d", &Q);

    map<int,int> mp;
    vector<vector<int> > z(Q);
    int i;
    for(i=0; i<Q; i++) {
        int t;
        scanf("%d", &t);
        z[i].push_back(t);
        if(t==1) {
            int a,b;
            scanf("%d%d", &a, &b);
            z[i].push_back(a);
            mp[a]=0;
            z[i].push_back(b);
        }
    }

    vector<ll> value;
    int num=0;
    auto it=mp.begin();
    for(; it!=mp.end(); ++it) {
        num++;
        it->second=num;
        value.push_back(it->first);
    }

    ll ans=0;
    BIT bit(num);
    BIT bit0(num);
    
    ll sum=0;
    for(i=0; i<Q; i++) {
        if(z[i][0]==1) {
            bit.add(mp[z[i][1]], 1);
            bit0.add(mp[z[i][1]], z[i][1]);
            sum += z[i][2];
        }
        else {
            int l=0, r=num+1;
            while(r-l>1) {
                int m=(l+r)/2;
                if(bit.sum(m)>=(bit.sum(num)+1)/2) {
                    r=m;
                }
                else {
                    l=m;
                }
            }
            printf("%lld %lld\n", value[r-1], sum+ value[r-1]*bit.sum(r)-bit0.sum(r)+bit0.sum(num)-bit0.sum(r)-value[r-1]*(bit.sum(num)-bit.sum(r)));
        }
    }

    return 0;
}



Measured memory_bytes: 20724
#include <iostream>
#include <queue>
#include <list>
#include <vector>

using namespace std;

#define MIN(x, y) x<y?x:y

int main()
{
	int x, y, z;

	cin>>x>>y>>z;
	
	cout<<z<<" "<<x<<" "<<y<<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<ll> a;
 ll max_num = 0;
 for(int i = 0; i < n; i++){
    ll k;
    cin >> k;
    a.push_back(k);
    max_num = max(max_num, k);
 }
 vector<ll> freq(max_num + 1, 0);
 for(int i = 0; i < n; i++){
    freq[a[i]] ++;
 }
 ll total_sum = 0;
 for(int i = 1; i <= max_num; i++){
    if(freq[i] > 1){
       total_sum += (freq[i] * (freq[i] - 1)) / 2;
    }
 }
 ll for_kth = 0;
 for(int i = 0; i < n; i++){
    for_kth = total_sum;
    if(freq[a[i]] > 1){
       for_kth -= (freq[a[i]] * (freq[a[i]] - 1)) / 2;
       if(freq[a[i]] > 2){
         for_kth += ((freq[a[i]] - 1) * (freq[a[i]] - 2)) / 2;
       }
    }
    cout << for_kth << endl;
 }
 return 0;
}

Measured memory_bytes: 5744
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

class UnionFindS{
private:
    vector<int> par;
public:
    UnionFindS(int n){
        par=vector<int>(n,-1);
    }
    int find(int x){
        if(par.at(x)<0) return x;
        else return par.at(x)=find(par.at(x));
    }
    int size(int x){
        return -par.at(find(x));
    }
    void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(size(x)<size(y)) swap(x,y);
        par.at(x)+=par.at(y);
        par.at(y)=x;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
};

signed main(void){
    int n,m; cin>>n>>m;
    UnionFindS uni(n);
    vector<int> a(m),b(m);
    rep(i,m){
        cin>>a.at(i)>>b.at(i);
        a.at(i)--; b.at(i)--;
    }
    reverse(all(a));
    reverse(all(b));
    int ans=n*(n-1)/2;
    vector<int> res(m);
    rep(i,m){
        res.at(i)=ans;
        if(!uni.same(a.at(i),b.at(i))){
            ans-=uni.size(a.at(i))*uni.size(b.at(i));
            uni.unite(a.at(i),b.at(i));
        }
    }
    reverse(all(res));
    rep(i,m){
        cout<<res.at(i)<<endl;
    }
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int, int>
#define ld long double
const int mod = 1e9 + 7;
 
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};



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

  
  string s;
  cin>>s;
int cnt=0;
  for(int i=0;i<s.length()/2;i++)
  {
    if(s[i]!=s[s.length()-1-i])cnt++;
  }

  cout<<cnt<<"\n";
    
}


Measured memory_bytes: 256
class SWAG():
    __slots__='unit','f','fold_r','fold_l','data_r','data_l'
    def __init__(self,unit,f,data):
        self.unit=unit
        self.f=f
        self.construct(data)
    def construct(self,data):
        self.fold_r=[self.unit]
        self.fold_l=[self.unit]
        self.data_r=[]
        self.data_l=[]
        sep=0--len(data)//2
        for t in data[sep:]:
            self.append(t)
        for t in data[sep-1::-1]:
            self.appendleft(t)
    def append(self,x):
        self.fold_r.append(self.f(self.fold_r[-1],x))
        self.data_r.append(x)
    def appendleft(self,x):
        self.fold_l.append(self.f(self.fold_l[-1],x))
        self.data_l.append(x)
    def pop(self):
        if not self.data_r:
            self.construct(self.data_l[::-1])
        if not self.data_r:
            return self.popleft()
        self.fold_r.pop()
        return self.data_r.pop()
    def popleft(self):
        if not self.data_l:
            self.construct(self.data_r)
        if not self.data_l:
            return False
        self.fold_l.pop()
        return self.data_l.pop()
    def fold_all(self):
        return self.f(self.fold_r[-1],self.fold_l[-1])
n,*p=map(int,open(0).read().split())
swag=SWAG(10**18,min,[])
a=0
for p in p:
    if p<swag.fold_all():
        a+=1
    swag.append(p)
print(a)

Measured memory_bytes: 25884
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
    long long s;
    cin >> s;
    long long rest = s % 500;
    long long ans = 0;
    ans += s/500 * 1000;
    ans += rest/5 * 5;
    cout << ans << endl;
}


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

#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, b, a) for(int i = (b); i >= (a); --i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define boost ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define M (ll)(1e9+7)
#define inf (ll)(2e9+9)
#define infl (ll)(2e18+9)
#define debug1(a) cout<<#a<<" = " <<a<<endl; 
#define debug2(a,b) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<endl; 
#define debug3(a,b,c) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<" , "<<#c<<" = "<<c<<endl; 
#define debug4(a,b,c,d) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<" , "<<#c<<" = "<<c<<" , "<<#d<<" = " <<d<<endl; 
  
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<char> vc; 
typedef vector<ll> vll; 
typedef vector< pair<int,int> > vpii;

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



void solve(){
  int n; cin>>n; 
  vi h(n); rep(i,0,n-1) cin>>h[i]; 
  vi dp(n); 
  dp[1]=abs(h[0]-h[1]); 
  rep(i,2,n-1){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])); 
  }
  cout<<dp[n-1]<<endl; 
}

int main() {
  clock_t beg=clock(); 
  boost;
  int t=1; 
  // cin>>t; 
  while(t--){
    solve(); 
  }
  clock_t end=clock(); 
  fprintf(stderr, "%lf\n", (double)(end-beg)/CLOCKS_PER_SEC);
}


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

#define N 1000


int max(int a, int b){
    if(a>b){
        return a;
    }else{
        return b;
    }
}

int lcs(char x[N+1], char y[N+1]){
    int c[N+1][N+1];
    int m=strlen(x);
    int n=strlen(y);

    char x2[N+1], y2[N+1];

    x2[0]=' ';
    y2[0]=' ';

    for(int i=0; i<m; i++){
        x2[i+1]=x[i];
    }
    for(int i=0; i<n; i++){
        y2[i+1]=y[i];
    }
    
    int maxl=0;
    for(int i=0; i<=m; i++){
        c[i][0]=0;
    }
    for(int j=1; j<=n; j++){
        c[0][j]=0;
    }

    for(int i=1; i<=m; i++){
        for(int j=1; j<=n; j++){
            if(x2[i]==y2[j]){
                c[i][j]=c[i-1][j-1]+1;
            }else{
                c[i][j]=max(c[i-1][j], c[i][j-1]);
            }
            maxl=max(maxl, c[i][j]);
        }
    }

    return maxl;
}

int main(void){
    char s1[N+1], s2[N+1];
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%s %s", s1, s2);
       
        printf("%d\n", lcs(s1, s2));
    }

    return 0;
}



Measured memory_bytes: 5628
/*
 * AOJ 2170: Marked Ancestor
 * ?¢???????
 * ?±?????????¶??\???+dfs+??????????????????+dfs???
 * ?????????????????????????????¢???????±??????\????????????????\?????????????dfs?????°????????????????\??????????????\???????????????¨??¶??\????????????????????????????????????????????????????????????????????¶?°???\???????????¶????????¨???????????¶????????????????????????dfs?????°?????????????????????????????°?????????????????°??\??????????????????????????´?????????????????°?????°??????
 */

#include <cstdio>
#include <iostream>
#include <stack>
#include <cstring>
#include <vector>

using namespace std;

typedef pair<char, int> pci;

stack<pci> s;

int fa[100010];
int p[100010];
int vis[100010];

vector<int> e[100010];

int n;

void dfs(int i, int f = 1) {
  if(vis[i]) {
    f = i;
  }
  fa[i] = f;
  vector<int> &ei = e[i];
  for(vector<int>::iterator it = ei.begin(); it != ei.end(); ++it) {
    dfs(*it, f);
  }
}

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

int main() {
  int i, j, q;
  long long ans;
  char op[3];
  while(scanf("%d%d", &n, &q) != EOF && n > 0) {
    memset(vis, 0, sizeof(vis));
    for(i = 1; i <= n; ++i) {
      e[i].clear();
    }
    ans = 0;

    vis[1] = 1;
    for(i = 2; i <= n; ++i) {
      scanf("%d", &j);
      e[j].push_back(i);
      p[i] = j;
    }
    for(i = 0; i < q; ++i) {
      scanf("%s%d", op, &j);
      if(op[0] == 'M') {
        ++vis[j];
      }
      s.push(make_pair(op[0], j));
    }
    dfs(1);

    while(!s.empty()) {
      i = s.top().second;
      if(s.top().first == 'M') {
        if(--vis[i] == 0) {
          fa[i] = find(p[i]);
        }
      } else {
        ans += find(i);
      }
      s.pop();
    }

    printf("%lld\n", ans);

  }
  return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll H, W;
    ll h, w;

    cin >> H >> W;
    cin >> h >> w;

    cout << H*W - (h*W+H*w-h*w) << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

int main()
{
    ll N, K;
    cin >> N >> K;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    vec csum(N+1, 0);
    REP(i,0,N) csum[i+1] = (csum[i] + A[i]) % K;
    
    ll cnt = 0;
    map<ll,ll> S;
    queue<ll> Q;
    REP(i,0,N+1) {
        ll t = (csum[i] - i) % K;
        t += t < 0 ? K : 0;
        cnt += S[t];
        ++S[t];
        Q.push(t);
        if(SZ(Q) >= K) {
            --S[Q.front()];
            Q.pop();
        }
    }

    PR(cnt);

    return 0;
}

/*



*/

Measured memory_bytes: 20388
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  GVI(a, N);
  map<int, int> list;
  FOR(i, N) { list[a[i]]++; }
  if (list.size() > 2) {
    print("No");
    return 0;
  }
  int A, ca, cb;
  if (list.size() == 2) {
    A = list.begin()->first;
    ca = list.begin()->second;
    if (list.rbegin()->first > A + 1) {
      print("No");
      return 0;
    }
    cb = list.rbegin()->second;
  } else {
    A = list.begin()->first;
    if (A == N - 1 || N % A == 0) {
      print("Yes");
    } else {
      print("No");
    }
    return 0;
  }
  if (ca - 1 + min(1, cb) <= A && A <= ca - 1 + cb / 2) {
    print("Yes");
  } else {
    print("No");
  }
  return 0;
}

Measured memory_bytes: 5376
# https://atcoder.jp/contests/abc144/tasks/abc144_d

import sys
from math import atan,pi
input=sys.stdin.readline

def main():
    a,b,x=map(int,input().split())
    if 2*x>=b*a**2:
        print(atan((2*(a**2*b-x))/a**3)*180/pi)
    else:
        print(atan(b**2*a/(2*x))*180/pi)
    
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 62464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=2001,INF=1<<30;

int main(){
    
    ll H,W,h,w;cin>>H>>W>>h>>w;
    ll a=H/h,b=W/w;
    if(h*w==1) cout<<"No"<<endl;
    else{
        ll m=(1000000000-1)/(h*w-1);
        if(a*b*(-(h*w-1)*m-1)+(H*W-a*b)*m>0){
            cout<<"Yes"<<endl;
            for(ll i=1;i<=H;i++){
                for(ll j=1;j<=W;j++){
                    if(j>=2) cout<<" ";
                    if(i%h==0&&j%w==0) cout<<-(h*w-1)*m-1;
                    else cout<<m;
                }
                cout<<endl;
            }
        }else cout<<"No"<<endl;
    }
}



Measured memory_bytes: 2944
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long N=sc.nextLong();
		long M=sc.nextLong();
		long max=1;
		for(int i=1; i*i<=M; i++){
			if(M%i==0 && i*N<=M){
				max=Math.max(max,i);
			}
			if(M%(M/i)==0 && (M/i)*N<=M){
				max=Math.max(max,(M/i));
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
int main(){
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = min(n, b-1);

  cout << floor((a*x)/b) - a * floor(x/b) << endl;

}


Measured memory_bytes: 3784
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
 int main(void){
     int n,x,y;
     cin >> n;
     long long s=0,a[n+10];
     for(int i=0; i<n; i++){
         cin >> x >> y;
         s+=x;
         a[i]=x+y;
     }
     sort(a,a+n,greater<long long>());
     for(int i=1; i<n; i+=2){
         s-=a[i];
     }
     cout << s << endl;
 }

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;


int main(){
    int N, M;
    int X[100005];
    int diff[100005];
    cin >> N >> M;
    for (int i = 0; i < M; ++i) cin >> X[i];

    sort(X, X+M);
    for (int i = 0; i < M-1; ++i) diff[i] = X[i+1] - X[i];
    sort(diff, diff+(M-1));
    
    int ans = 0;
    for (int i = 0; i < M-N; ++i) ans += diff[i];    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
#include <tuple>
using namespace std;
#define FORN(i,m,n) for(int i=(m); i<int(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
typedef long long ll;
 
int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int table[3][3];
  FORN(i,0,3) FORN(j,0,3) cin>>table[i][j];		     
  int n; cin>>n;
  vector<int> v(n);
  FORN(i,0,n) cin>>v[i];
  bool ok = false, g;
  FORN(i,0,3){
    g = true;
    FORN(j,0,3){
      if(find(v.begin(), v.end(), table[i][j]) == v.end()) g = false;
    }
    if(g) ok = true;
    g = true;
    FORN(j,0,3){
      if(find(v.begin(), v.end(), table[j][i]) == v.end()) g = false;
    }
    if(g) ok = true;
  }
  g = true;
  FORN(i,0,3) if(find(v.begin(), v.end(), table[i][i]) == v.end()) g = false;
  if(g) ok = true;
  g = true;
  FORN(i,0,3) if(find(v.begin(), v.end(), table[i][2-i]) == v.end()) g = false;
  if(g) ok = true;
  cout<<(ok ? "Yes" : "No")<<endl;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int isprime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0 && (i % 7 == 1 || i % 7 == 6) && (n / i % 7 == 1 || n / i % 7 == 6)) {
            return false;
        }
    }
    return true;
}

int toint(string s) {
    string b;
    copy_if(all(s), back_inserter(b), [](char c) { return c != ':'; });
    return stoi(b);
}

struct P { ll p, a, b, c, d, e, f, s, m; string nm; };

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    const int dir[4][2] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}};

    ll n; cin >> n;
    for (ll i = 1, lo = 1, hi = 3;; i++, lo *= 3, hi *= 3) {
        if (lo <= n && n <= hi) {
            cout << i << endl;
            return 0;
        }
    }
}



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

int main(){
ll a,b,x;
cin >> a >> b >>x;
ll ans = b/x - a/x;
if(a%x==0)
{ans++;}

cout << ans << endl;
return 0;

}
//

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define FASTBOI ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pll pair<long long, long long>
#define ll long long
#define f first
#define s second
#define mod 1000000007

using namespace std;

int main()
{
	FASTBOI;
	int n;
	cin>>n;
	vector<int> v(n);
	for(int y=0;y<n;y++)
		cin>>v[y];
	int val=0;
	for(int y=1;y<n-1;y++)
	{

		if(v[y]>v[y-1] and v[y]<v[y+1])
			val++;
		if(v[y]<v[y-1] and v[y]>v[y+1])
			val++;
	}
	cout<<val;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n;
	int c[50]={0};
	int v[50]={0};
	int aa[50]={0};
	cin >>n;
	for (int i=0;i<n;i++){
		cin >> v[i];
	} 
	for (int i=0;i<n;i++){
		cin >> c[i];
		aa[i]=v[i]-c[i];
	} 
	int sum=0;
	for (int k=0;k<n;k++){
		if (aa[k]>0){
			sum+=aa[k];
		}	
		
	}
	cout << sum <<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define per(i,a,b) for(ll i=(b)-1;i>=(a);i--)
ll x;
int main() {
    ios_base::sync_with_stdio(0);
    cin>>x;
    ll ans=0,y=100;
    while(y<x) ans++, y+=y/100;
    cout<<ans<<"\n";
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    // 頂点数と辺数
    int N, M;
    cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    vector<int> mark(N);
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty())
    {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v])
        {
            if (dist[nv] != -1)
                continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            mark[nv] = v;
            que.push(nv);
        }
    }

    puts("Yes");
    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = 1; v < N; ++v)
        cout << mark[v] + 1 << endl;
}

Measured memory_bytes: 10672
#include <iostream>
#include <stdio.h>
#include <vector>

const double PI=3.14159265358979323846;

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

int main(){
  int a=1,b=1;

  while(true){
    cin >> a >> b;
    if(a == 0 && b == 0) break;
    rep(i,a){
      rep(j,b){
	if(i % 2 == 0 && j % 2 == 0) cout << "#";
	else if(i % 2 == 0 && j % 2 != 0) cout << ".";
	else if(i % 2 != 0 && j % 2 == 0) cout << ".";
	else if(i % 2 != 0 && j % 2 != 0) cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define ll long long int
#include <math.h>
# define M_PI           3.14159265358979323846 
using namespace std;
int main () {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r;
    cin>>r;
    double x=2*r*M_PI;
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 3800
n = int(input())
playList = []
sumTerm = 0
for i in range(n) :
    song = input().split()
    song[1] = int(song[1])
    playList.append(song)
    sumTerm += song[1]
x = input()

tmpSumTerm = 0

for i in range(n) :
    tmpSumTerm += playList[i][1]
    if playList[i][0] == x :
        print(sumTerm - tmpSumTerm)
        break


Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

int64_t calc(int64_t a, int64_t b)
{
    // cout << a << ", " << b << ", " << b - a << endl;
    if (b >= a)
        return b - a;
    return 0x7ffffffffffffffLL;
}

int main()
{
    int64_t x, y;
    cin >> x >> y;

    int64_t ans = 0x7ffffffffffffffLL;

    ans = min(ans, calc(x, y));
    ans = min(ans, calc(-x, y) + 1);
    ans = min(ans, calc(x, -y) + 1);
    ans = min(ans, calc(-x, -y) + 2);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def fenec(k, h_list):
  h_list.sort()
  if k >= len(h_list):
    return 0
  else:
    ans = 0
    for i in range(len(h_list)-k):
      ans += h_list[i]
    return ans
    
n, k = [int(i) for i in input().split()]
h_list = [int(i) for i in input().split()]

print(fenec(k, h_list))


Measured memory_bytes: 25768
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    int n; cin >> n;
    vi v(n);   
    ll res = 0;
    forn(n) {
        cin >> v[i];
    }
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            res += v[i] * v[j];
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int a,b;
    string ans;
    cin>>a>>b;
    cout<<a+(b/2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#A
#n = int(input())
#print(3*n**2)
#B
#n, d = map(int, input().split())
#canseerange = 2*d+1
#if n % canseerange == 0:
#    print(int(n/canseerange))
#else:
#    print(int(n/canseerange)+1
#C
n = int(input())
ans = 0
most1 = 0
most2 = 0
ed = False
for i in range(n):
    t = int(input())
    ed = False
    if most1 <= t:
        most2 = most1
        most1 = t
        ans = i
        ed = True
    elif most2 <= t and ed == False:
        most2 = t
for i in range(n):
    if i==ans:print(most2)
    else:print(most1)


Measured memory_bytes: 55640
// https://atcoder.jp/contests/dp/tasks/dp_j

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mod 1000000007
#define gcd __gcd
// #define inf INT_MAX
#define inf 1e9+1
#define INF LLONG_MAX
#define minf INT_MIN
#define MINF LLONG_MIN
#define pb push_back
#define all(v) v.begin(),v.end()
#define print(v) for(auto x:v) cout<<x<<" "; cout<<"\n";
#define printn(v) for(auto x:v) cout<<x<<"\n";
#define F first
#define S second
#define mp make_pair

int dp[101][100001];
vector<int>wt;
vector<int>val;
int n, capacity;

//dp[i][j] : minimum weight W, we have to carry to get the value j
int knapsack_2(int max_profit) {
	for (int j = 0; j <= max_profit; j++) dp[0][j] = inf;
	for (int i = 0; i <= n; i++) dp[i][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= max_profit; j++) {
			if (val[i] <= j) dp[i][j] = min(wt[i] + dp[i - 1][j - val[i]], dp[i - 1][j]);
			else dp[i][j] = dp[i - 1][j];
		}
	}
	int ans = 0;
	for (int j = 0; j <= max_profit; j++)
		if (dp[n][j] <= capacity) ans = j;
	return ans;
}

int32_t main() {
	fastio;
	cin >> n >> capacity;
	wt.resize(n + 1, 0);
	val.resize(n + 1, 0);
	int max_profit{};
	for (int i = 1; i <= n; i++) {
		cin >> wt[i] >> val[i];
		max_profit += val[i];
	}
	cout << knapsack_2(max_profit) << endl;
}

Measured memory_bytes: 43096
[n,m] = input().split(' ')
v = []
n = int(n)
m = int(m)
for i in range(m):
    [s,c] = input().split(' ')
    s = int(s)
    s-=1
    v.append((s,c))
ans = -1
for i in range(1000):
    temp = str(i)
    check = (len(temp) == n)
    for (s,c) in v:
        check = check and (temp[s]==c)
    if(check):
        ans = i
        break
print(ans)
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 998244353;
ll powmod(ll x,ll n){
    if(n == 0)return 1;
    ll ans = powmod(x*x%MOD,n/2);
    if(n % 2)ans = ans * x % MOD;
    return ans;
}

vector<int> compress(map<int,ll> mp){
    auto itr = mp.end();
    itr--;
    int size = (itr->first) + 1;
    vector<int> vec(size);
    for(auto p:mp){
        vec[p.first] = p.second;
    }
    return vec;
}
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    map<int,ll> mp;
    rep(i,0,N)mp[V[i]]++;
    auto vec = compress(mp);
    /*
    for(auto i:vec){
        cout << i << " ";
    }cout << endl;
    */
    if(vec[0] != 1 || V[0] != 0){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    rep(i,1,vec.size()){
        int n = vec[i-1], r = vec[i];
        ll num = powmod(n, r);
        //cout << num << endl;
        ans = ans % MOD * num % MOD;
    }
    cout << ans << endl;

}

Measured memory_bytes: 13568