akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void){
    int x[4][13] = {0};
    int n;
    int i, t, k;
    char card;
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf(" %c %d", &card, &t);
        if(card == 'S')
            x[0][t -1] = 1;
        if(card == 'H')
            x[1][t -1] = 1;
        if(card == 'C')
            x[2][t -1] = 1;
        if(card == 'D')
            x[3][t -1] = 1;
    }
    for(i = 0; i < 4; i++){
        for(k = 0; k < 13; k++){
            if(x[i][k] == 0){
                if(i == 0)  printf("S %d\n", k + 1);
                if(i == 1)  printf("H %d\n", k + 1);
                if(i == 2)  printf("C %d\n", k + 1);
                if(i == 3)  printf("D %d\n", k + 1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vll = vector<ll>;
#define x first
#define y second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define szz(x) (int) (x).size()
#define FOR(i,a,b) for (int i = (a), _for = (b); i < _for; i++)
#define REP(i,n) FOR(i,0,(n))
#define _ << " " <<
const ll MOD = 1000000007ll;
const ll INF = 0x3f3f3f3f3f3f3f3f;
inline ll SUB(ll a, ll b) { return a-b >= 0ll ? a-b : a-b+MOD; }
inline ll ADD(ll a, ll b) { return a+b >= MOD ? a+b-MOD : a+b; }
inline ll MUL(ll a, ll b) { return a*b % MOD; }

constexpr int MAXX = 3000;
double dp[MAXX + 3][MAXX + 3];
double p[MAXX + 3];
int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  REP(i,n) cin >> p[i];
  dp[0][0] = 1.0;
  REP(k,n) {
    REP(i, k + 1) {
      int j = k - i;
      dp[i+1][j] += p[k] * dp[i][j];
      dp[i][j+1] += (1.0 - p[k]) * dp[i][j];
    }
  }

  double nas = 0.0;
  FOR(i, (n + 1)/2, n + 1) nas += dp[i][n - i];
  
  cout << setprecision(10) << nas << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct niku { 
  ll i, b; 
  bool operator< (const niku &x) const { return b<x.b||(b==x.b&&i<x.i); };
  bool operator> (const niku &x) const { return b>x.b||(b==x.b&&i>x.i); };
};

struct SegTree {
  int size;
  vector<niku> pos;
  SegTree(ll N) { size = 1; while(size<N) size<<=1; pos.resize(size*2,{0,0}); }
  niku operator[](const ll &x) const { return pos[x+size]; }

  void build() { per(i,size) operate(i); }
  void set(ll x, const niku v) { pos[x+size] = v; }
  void update(ll x, const niku v) { set(x,v); x+=size; while (x>>=1) operate(x); }
  niku query(ll a, ll b) {
    niku L = {0,0}, R = {0,0};
    for (a+=size, b+=size; a<b; a>>=1, b>>=1) {
      if (a&1) { L = q(L,pos[a]); a++; }
      if (b&1) { b--; R = q(pos[b],R); }
    }
    return q(L,R);
  }
  void operate(ll i) { pos[i] = max(pos[i*2], pos[i*2+1]); }
  niku q(niku x, niku y) { return max(x, y); }
};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

vector<vector<ll>> imos;
SegTree st(10000);

void dfs(ll l, ll r) {
  ll m = st.query(l,r).i;
  imos[l][m] += st[m].b; imos[m+1][m] -= st[m].b;
  imos[l][r] -= st[m].b; imos[m+1][r] += st[m].b;
  if (l!=m) dfs(l,m);
  if (m+1!=r) dfs(m+1,r);
}

int main() {
  ll N, M; cin >> N >> M;
  ll A[N-1]; rep(i,N-1) cin >> A[i];
  ll d[N] = {}; rep(i,N-1) d[i+1] = d[i] + A[i];
  ll B[N][M]; rep(i,N) rep(j,M) cin >> B[i][j];

  imos.resize(N+1); rep(i,N+1) imos[i].resize(N+1,0);
  rep(j,M) {
    rep(i,N) st.update(i, {i,B[i][j]});
    dfs(0,N);
  }

  // ll sum[N][N] = {};
  rep(i,N) rep(j,N) {
    // sum[i][j] += imos[i][j];
    if (i>0) imos[i][j] += imos[i-1][j];
    if (j>0) imos[i][j] += imos[i][j-1];
    if (i>0&&j>0) imos[i][j] -= imos[i-1][j-1];
  }
  // rep(i,N) debug(sum[i],sum[i]+N);

  ll result = 0; rep(i,N) repr(j,i,N) result = max(result, imos[i][j]-(d[j]-d[i]));
  cout << result << endl;

  return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll A, B, C;
    cin >> A >> B >> C;
    cout << min(B / A, C) << endl;
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 256
m,d=gets.split.map(&:to_i)
ans = 0
(1..m).each do |mo|
  (1..d).each do |da|
    next if da < 10
    d1, d2 = da.to_s.split('').map(&:to_i)
    next if d1 < 2
    next if d2 < 2
    ans += 1 if d1*d2 == mo
  end
end
p ans


Measured memory_bytes: 2044
n, m = map(int, input().split())
keys = dict()
min_cost = dict()
for i in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    bit = 0
    for x in c:
        bit |= 1 << (x - 1)
    if bit in keys and keys[bit] <= a:
        continue
    keys[bit] = a
    min_cost[bit] = a

for i in range(1, 1 << n):
    if not i in min_cost:
        continue 
    for bit, cost in keys.items():
        bit |= i
        if i != bit:
            if bit in min_cost:
                min_cost[bit] = min(min_cost[bit], min_cost[i] + cost)
            else:
                min_cost[bit] = min_cost[i] + cost

if not (1 << n) - 1 in min_cost:
    print(-1)
else:
    print(min_cost[(1 << n) - 1])

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

int main(){
 int n;
 cin>>n;
 int a[100];
 for(int i=0;i<n;i++) cin>>a[i];
 for(int i=0;i<n-1-i;i++)swap (a[i], a[n-1-i]);
 for(int i=0;i<n;i++){
 if(i) cout<<" ";
 cout<<a[i];
 }
cout<<endl;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}
int main(){
	int n; cin >> n;
	string s; cin >> s;
	vector<int> ans(n);
	for(int i = 0; i < s.size(); i++){
		if(i == 0 && s[i] == 'I')ans[i] = 1;
		else if(i == 0 && s[i] == 'D')ans[i] = -1;
		else if(i != 0 && s[i] == 'I')ans[i] += ans[i-1] + 1;
		else if(i != 0 && s[i] == 'D')ans[i] += ans[i-1] - 1;
	}
	sort(ans.begin(), ans.end());
	cout << max(0, ans[ans.size()-1]) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n;
char c[100010][10];
string s;
vector<string> vec;
int cnt;
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
		sort(c[i], c[i] + 10);
		for (int j = 0; j < 10; j++)s += c[i][j];
		vec.push_back(s);
		s = "";
	}
	sort(all(vec));
	for (int i = 0; i < n; i++) {
		if (1 <= i && vec.at(i - 1) == vec.at(i)) cnt++;
		else {
			ans += cnt * (cnt - 1) / 2;
			cnt = 1;
		}
	}
	ans += cnt * (cnt - 1) / 2;
	cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 3005;
const int INF = 1001001001;
const int MOD = 1000000007;

int S[MAX][MAX];
ll dp[MAX][MAX][5];

int main(){
    int R, C, K;
    cin >> R >> C >> K;

    rep(i, K) {
        int r, c, v;
        cin >> r >> c >> v;
        r--, c--;
        S[r][c] = v;
    }

    rep(r, R)rep(c, C)rep(n, 4) {
        ll pre = dp[r][c][n];

        chmax(dp[r][c+1][n], pre);
        chmax(dp[r+1][c][0], pre);
        if (n < 3) {
            chmax(dp[r][c+1][n+1], pre + S[r][c]);
            chmax(dp[r+1][c][0], pre + S[r][c]);
        }
    }

    ll ans = 0;
    rep(n, 4) chmax(ans, dp[R][C-1][n]);
    rep(n, 4) chmax(ans, dp[R-1][C][n]);
    cout << ans << endl;
}

Measured memory_bytes: 391076
#include<stdio.h>

void showArray(int A[],int N){
	int i;
	for(i=0;i<N-1;i++)
		printf("%d ",A[i]);
	printf("%d\n",A[N-1]);
}

void selectionSort(int A[],int N){
	int i,j,minj;
	int count=0;
	for(i=0;i<N;i++){
		minj=i;
		for(j=i;j<N;j++){
			if(A[j]<A[minj]){
				minj=j;
			}
		}
		int temp=A[i];
		A[i]=A[minj];
		A[minj]=temp;
		if(i!=minj)count++;
	}
	
	showArray(A,N);
	printf("%d\n",count);
}



int main(void){
		int n;
		int array[101];
		scanf("%d",&n);
		for(int i=0;i<n;i++)
			scanf("%d",&array[i]);

		selectionSort(array,n);
		
			
		return 0;
}

Measured memory_bytes: 1772
import sys
import socket
from collections import Counter

if socket.gethostname() == 'N551J':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    h, w = read_int_list()
    c = Counter()
    for i in range(h):
        c += Counter(read_str())
    values = sorted(c.values(), reverse=True)
    m = [4] * ((h // 2) * (w // 2))
    if h % 2 == 1:
        m = m + [2] * (w // 2)
    if w % 2 == 1:
        m = m + [2] * (h // 2)
    if h % 2 == 1 and w % 2 == 1:
        m = m + [1]
    for v in m:
        if values[0] < v:
            return 'No'
        else:
            values[0] -= v
            if values[0] == 0:
                values.pop(0)
            else:
                values.sort(reverse=True)
    return 'Yes'


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i=0;i<(n);i++)

int n,q,c=0;
int S[1000000], T[1000000];

int bs(int key) {
	int l=0,r=n,mid;
	while (l < r) {
		mid = (l+r) / 2;
		if (S[mid] == key) return 1;
		else if(key < S[mid]) r = mid;
		else l = mid + 1;
	}
	return 0;
}

int main() {
	cin >> n;
	rep(i,n) cin >> S[i];
	cin >> q;
	rep(i,q) cin >> T[i];
	rep(i,q) {
		c += bs(T[i]);
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
int main() {
  string s;
  cin>>s;
  ll n=s.size()+1;
  vec a(n);
  ll countup=0;
  ll countdown=0;
  loop(i,n-1){
    if(s[i]=='<'){
      countup++;
    }
    else countup=0;
    a[i+1]=countup;
  }
  pool(i,n-1){
    if(s[i]=='>'){
      countdown++;
    }
    else countdown=0;
    a[i]=max(a[i],countdown);
  }
  putout(sum(a));
  
}


Measured memory_bytes: 4740
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }
    String ans = "second";
    if (N == 1) {
      if (a[0] % 2 == 1) {
        ans = "first";
      }
    } else {
      for (int i = 0; i < N; i++) {
        if (a[i] % 2 == 1) {
          ans = "first";
        }
      }
    }
    System.out.println(ans);
  }
}

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

using namespace std;


int main(){
  int N;
  int K=0;
  cin >> N;
  vector<int> d(N);
  for(int& a : d){
    cin >> a;
  }
  sort(d.begin(),d.end());
  int div=d.at(N/2);
  if(d.at(N/2-1) == div){
    cout << 0 << endl;
  }
  else{
    int ans;
    ans=d.at(N/2)-d.at(N/2-1);
    cout << ans << endl;
  }
  return false;
}

Measured memory_bytes: 640
// The very basic /////////////////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ALL_H 1

// Debug it by D(x) ///////////////////////////////////////////////////////////
#define DEBUG 0
#if DEBUG
#define D(x) x
#else
#define D(x)
#endif

// Print elements of containers using << operator /////////////////////////////
// pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  return s << "(" << p.first << ", " << p.second << ")";}
// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  for (auto &elem : v) {
    s << elem;
    if (&elem != &v.back()) s << " ";
  }
  return s;
}
// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  for (auto &elem : vv) {
    s << elem;
    if (&elem != &vv.back()) s << endl;
  }
  return s;
}
// map
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
  s << "{" << endl;
  for (auto &elem: m) {
    s << " " << elem.first << " : " << elem.second << endl;
  }
  s << "}";
  return s;
}
//set
template<typename T> ostream& operator<<(ostream& s, const set<T>& m) {
  s << "{ ";
  for (auto &elem: m) {
    s << elem << " ";
  }
  s << "}";
  return s;
}

// Convenient macros //////////////////////////////////////////////////////////

// types
#define ll long long
#define ld long double
#define int ll
#define Pi pair<int, int>
#define Graph vector<vector<int>>
#define WeightGraph vector<vector<Pi>>

// other
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

// update max or min //////////////////////////////////////////////////////////

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// gcd
int gcd(int a,int b){return b?gcd(b,a%b):a;}

// for grids
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

///////////////////////////////////////////////////////////////////////////////
//                             Start Coding Here                             //
///////////////////////////////////////////////////////////////////////////////

signed main() {
  string S; cin >> S;
  
  int N = (int)S.size();
  
  int P = (1LL)<<(N-1);
  
  int ans = 0;
  rep(i, P) {
    int t = 0;
    D(cout <<"i: "<< i << endl);
    int temp = 0;
    rep(j, N) {
      int mask = 1 << j;
      if (i & mask) {
        ans += temp * 10 + (S[j] - '0');
        temp = 0;
      } else {
        temp = temp * 10 + (S[j] - '0');
        if ( i == 1) D(cout << temp << endl);
      }
      if (j == N-1) {
        D(cout << "temp: " << temp << endl);
        ans += temp;
        temp = 0;
      }
      D(cout << "ans: "  << ans << endl);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

constexpr int INF = 1e9;
vector<vector<int>> graph, used;

void dijkstra(int s) {
    vector<int> dist(graph.size(), INF), searched(graph.size(), 0), prev(graph.size(), -1);
    priority_queue<pair<int, int>> pq;
    dist[s] = 0;
    pq.push({0, s});
    while (pq.size()) {
        int ver = pq.top().second;
        pq.pop();
        if (searched[ver]) continue;
        rep(i, graph.size()) {
            if (!graph[ver][i]) continue;
            int alt = dist[ver] + graph[ver][i];
            if (alt < dist[i]) {
                dist[i] = alt;
                prev[i] = ver;
                pq.push({-alt, i});
            }
        }
        searched[ver] = 1;
    }
    rep(i, graph.size()) {
        if (prev[i] == -1) continue;
        used[i][prev[i]] = 1;
        used[prev[i]][i] = 1;
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    graph = used = vector<vector<int>>(N, vector<int>(N, 0));
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        graph[a - 1][b - 1] = c;
        graph[b - 1][a - 1] = c;
    }
    
    rep(i, N) dijkstra(i);
    int cnt = 0;
    rep(i, N) rep(j, N) {
        if (!graph[i][j]) continue;
        if (!used[i][j]) ++cnt;
    }
    cout << cnt / 2 << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int l, r;
    int ans = 0;
    while(l!=n){
        l = n;
        if(h[0]!=0){
            l = 0;
        }else{
            for(int i = 1; i < n; i++){
                if(h[i-1]==0 && h[i]!=0){
                    l = i;
                    break;
                }
            }
        }
        r = n;
        for(int i = 1; i < n; i++){
            if(h[i-1]!=0 && h[i]==0){
                r = i;
                break;
            }
        }
        for(int i = l; i < r; i++){
            h[i]--;
        }
        ans++;
    }
    ans--;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
template <class A, class B> inline A max(A a, B b){return(a>b?a:b);}
template <class A, class B> inline A min(A a, B b){return(a<b?a:b);}
const lol inf=(1LL<<60);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n;
  vector<int> a(n);
  for(auto&&i:a) cin >>i;
  lol ans=0;
  sort(a.begin(),a.end(),greater<int>());
  map<int,int> ma;
  ma[a[0]]=1;
  for(int i=1;i<n;i++){
    auto r=ma.rbegin();
    ans+=r->fi;
    r->se--;
    if(r->se==0) ma.erase(r->fi);
    ma[a[i]]+=2;
  }
  cout <<ans<<'\n';
  return (0);
}

Measured memory_bytes: 8688
#include<bits/stdc++.h>                                                                          
using namespace std;
int main()
{
  int N,K;
  cin >> N >> K;
  vector<int> l(N);
  for(int i=0; i<N; i++){
    cin >> l.at(i);
  }
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int sum=0;
  for(int i=0; i<K; i++){
    sum+=l.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))

xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

MODULO = 10**9 +7

def MSum(x, y):
    return (x + y) % MODULO

def MPro(x, y):
    return (x * y) % MODULO

def foo(zs, k):
    s = 0
    for i in range(k):
       s = MSum(s, MPro(MPro(zs[i], k-i), i+1))
    return s

def diff(zs, k):
    previous = None
    rs = [0] * (k-1)
    for i, z in enumerate(zs):
        if i == 0:
            previous = z
            continue
        rs[i-1] = z - previous
        previous = z
    return rs

dx = diff(xs, n)
dy = diff(ys, m)

print(MPro(foo(dx, n-1), foo(dy, m-1)))



Measured memory_bytes: 19120
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int ans=0;
	int count[10000]={};
	for(int i=1;i<=10000;i++){
		for(int j=1;j<=10000;j++){
			if(i % j == 0) count[i]++;
		}
		if(count[i] == n){
			ans = i;
			break;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}



Measured memory_bytes: 3128
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		string r = Console.ReadLine();
		int n = a[0];
		int k = a[1];
		string[] s = new string[n];
		
		for(int b=0; b!=n; b++){
			s[b] = r.Substring(b,1);
		} 
		
		string c = s[k-1];
		c = c.ToLower();
		s[k-1] = c;
		
		string d = String.Join("",s);
		Console.WriteLine(d);
		
		
		
		
	}
}

Measured memory_bytes: 13396
N,K = map(int,input().split())
l = N//K
a = 0
b = 0

if N%K == 0:
    print(0)
else:
    a = abs(N-(K*l))
    b = abs(a-K)
    if a >= b:
        print(b)
    elif a <= b:
        print(a)

Measured memory_bytes: 3060
using System;
using System.Linq;

class prog{
  static void Main(){
    int N = int.Parse(Console.ReadLine());
    int[] l = new int[N];
    int[] r = new int[N];
    for(int i = 0; i < N; i++){
      int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
      l[i] = input[0];
      r[i] = input[1];
    }
    
    int sum = 0;
    for(int i = 0; i < N; i++){
      sum += r[i] - l[i] + 1;
    }
    
    Console.WriteLine(sum);
  }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
static const ll mod=998244353;
ll N,K;
ll dp[200005];
ll sum[200005];
int main(){
  cin>>N>>K;
 vector<P>A(K);
  for(ll i=0;i<K;i++){
  ll l,r;cin>>l>>r;
    P p(l,r);A[i]=p;
  }
  dp[0]=1;sum[0]=1;
  for(ll i=1;i<N;i++){
    for(ll j=0;j<K;j++){
    ll l=A[j].first;ll r=A[j].second;
      if(i-l<0){}else if(0<=i-l && 0<=i-r-1){
      dp[i]=(dp[i]+sum[i-l]-sum[i-r-1]+2*mod)%mod;
      }else
        dp[i]=(dp[i]+sum[i-l])%mod;
     }sum[i]=(sum[i-1]+dp[i])%mod;
  }cout<<dp[N-1]<<endl;
    
  return 0;
}  

Measured memory_bytes: 6748
#include <bits/stdc++.h>
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
 
const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;
 
int main()
{
	int t1, t2, a, b, k;
	cin >> a >> b;
	t1 = a * 60 + b;
	cin >> a >> b;
	t2 = a * 60 + b;
	cin >> k;
	cout << max(t2 - t1 - k, 0);
}


Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<string>
#include<cctype>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)

bool check(string s){
  vector<char> v;
  REP(i, s.length()){
    if(s[i] == '(') v.push_back('(');
    else if(s[i] == '[') v.push_back('[');

    else if(s[i] == ')'){
      if(v.size() == 0 || v[v.size() - 1] != '(') return false;
      v.pop_back();
    } else if(s[i] == ']'){
      if(v.size() == 0 || v[v.size() - 1] != '[') return false;
      v.pop_back();
    }
  }
  return v.size() == 0;
}

int main(){
  string str;
  while(getline(cin, str)){
    if(str == ".") break;
    cout <<(check(str) ? "yes" : "no") <<endl;
  }
}

//int search(vector<char> &v, char c){
//    for(int i = v.size() - 1; i >= 0; i--){
//        if(v[i] == c){
//            int a = 0, b = 0;
//            FOR(j, i + 1, v.size()){
//                if(v[j] == '(') a++;
//                else if(v[j] == '[') b++;
//                else if(v[j] == ')'){
//                    if(a <= 0) return -1;
//                    else a--;
//                }
//                else if(v[j] == ']'){
//                    if(b <= 0) return -1;
//                    else b--;
//                }
//            }
//            if(a == 0 && b == 0) return i;
//            else return -1;
//        }
//    }
//    return -1;
//}
//
//int main(){
//    string str;
//    while(getline(cin, str)){
//        if(str == ".") break;
//        bool OKflg = true;
//        vector<char> v;
//        REP(i, str.length()){
//            if(str[i] == '(') v.push_back('(');
//            else if(str[i] == '[') v.push_back('[');
//            else if(str[i] == ')'){
//                int tmp = search(v, '(');
//                if(tmp == -1){
//                    OKflg = false;
//                    break;
//                } else REP(j, v.size() - tmp + 1) v.pop_back();
//            }
//            else if(str[i] == ']'){
//                int tmp = search(v, '[');
//                if(tmp == -1){
//                    OKflg = false;
//                    break;
//                } else REP(j, v.size() - tmp + 1) v.pop_back();
//            }
//        //debug
//        REP(i, (int)(v.size())) cout <<v[i] <<", "; cout <<endl;
//        }
//        if(OKflg && v.size() == 0) cout <<"yes" <<endl;
//        else cout <<"no" <<endl;
//    }
//    return 0;
//}
//
//

Measured memory_bytes: 1204
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	HashMap<List<Long>, Long> f = new HashMap<>();
	int N;
	long W;
	long[] w, v;

	void run() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		W = sc.nextLong();
		w = new long[N];
		v = new long[N];
		for (int i = 0; i < N; ++i) {
			w[i] = sc.nextLong();
			v[i] = sc.nextLong();
		}
		System.out.println(func(W, 0));
	}

	long func(long ww, int num) {
		if (ww < 0)
			return -Long.MAX_VALUE / 16;
		if (num == N)
			return 0;
		if (f.containsKey(Arrays.asList(ww, (long) num)))
			return f.get(Arrays.asList(ww, (long) num));
		long ret = Math.max(func(ww - w[num], num + 1) + v[num], func(ww, num + 1));
		f.put(Arrays.asList(ww, (long) num), ret);
		return ret;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 55312
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>

using namespace std;
typedef long long ll;

void imie() {
	cout << "hello" << "\n";
}

const ll INF = 1e18 + 5;
const int mod = 1e9 + 7;

void solve() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>> dp(h, vector<int>(w));
	vector<vector<char>> str(h, vector<char>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> str[i][j];
		}
	}

	for (int i = h - 1; i >= 0; i--) {
		for (int j = w - 1; j >= 0; j--) {
			if (str[i][j] == '.') {
				if (i == h - 1 && j == w - 1) {
					dp[i][j] = 1;
				}
				else if (i == h - 1) {
					dp[i][j] = dp[i][j + 1];
				}
				else if (j == w - 1) {
					dp[i][j] = dp[i + 1][j];
				}
				else {
					dp[i][j] = dp[i + 1][j] + dp[i][j + 1];
				}
				
				if (dp[i][j] >= mod) dp[i][j] -= mod;
			}
		}
	}

	cout << dp[0][0];
}


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

	solve();

	/*
	int t;
	cin >> t;
	while (t) {
		solve();
		cout << "\n";
		t--;
	}
	*/

}



Measured memory_bytes: 8124
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll dp[10005][2][10];

signed main(){
	string s; cin>>s;
	int k; cin>>k;
	int n=s.size();
	dp[0][0][0]=1;
	rep(i,n){
		rep(j,k+1){
			dp[i+1][1][j+1] += dp[i][1][j]*9;
			dp[i+1][1][j] += dp[i][1][j];

			int ni=s[i]-'0';

			if(ni>0){
				dp[i+1][1][j+1] += dp[i][0][j]*(ni-1);
				dp[i+1][1][j] += dp[i][0][j];
				dp[i+1][0][j+1] = dp[i][0][j];
			}else{
				dp[i+1][0][j] = dp[i][0][j];
			}
		}
	}
	cout<<dp[n][0][k]+dp[n][1][k]<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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();

        System.out.println((b - a) == (c - b) ? "YES" : "NO");
    }
}


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int MAX=1e6;

int main(){
    int N; cin >> N;
    int a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    sort(a,a+N);
    int ans=0;

    bool e[MAX+1]={};
    for(int i=0;i<N;i++){
        if(e[a[i]]) continue;
        for(int j=2*a[i];j<=a[N-1];j+=a[i]){
            e[j]=true;
        }
    }
    for(int i=0;i<N;i++){
        if(a[i]==a[i+1]) continue;
        if(a[i]==a[i-1]) continue;
        if(e[a[i]]==false) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5308
ary = Array.new
while line = $stdin.gets
  ary << line.chomp.split
end
n = ary[0][0].to_i
m = ary[0][1].to_i
ary.delete_at(0)
ary.map!{|item| item.map(&:to_i) }
ary.sort!{|a, b| a[0] <=> b[0] }
b = 0
y = 0
k = 0
while b != m do
    iru = m-b
    if ary[k][1] == 0 then
        k = k + 1
    elsif ary[k][1] >= iru then
        y = y + ary[k][0]*iru
        b = b + iru
    else
        y = y + ary[k][0]*ary[k][1]
        b = b + ary[k][1]
        k = k + 1
    end
end
print y

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        ArrayList<String> s = new ArrayList<String>();
        for (int i = 0; i < n; i++) {
            s.add(sc.next());
        }

        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            String t = sc.next();
            s.remove(t);
        }
        s.sort(null);
        String[] s1 = new String[s.size()];
        s1 = s.toArray(s1);

        int max = 1;
        if (s1.length > 0) {
            int cnt = 1;
            for (int i = 1; i < s1.length; i++) {
                if (s1[i].equals(s1[i-1])) {
                    cnt++;
                    max = Math.max(max, cnt);
                } else {
                    cnt = 1;
                }
            }
        } else {
            max = 0;
        }

        System.out.print(max);
    }
}


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

int main(){
    int x, y;
    while( 1 ){
        cin >> x >> y;
        if( x == 0 && y == 0 ) break;
        if( x <= y ){
            cout << x << " " << y << endl;
        }else{
            cout << y << " " << x << endl;
        }
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
// For actual content check from line 100
#define timeKyaHorhaH 1.0 * clock() / CLOCKS_PER_SEC

#define FORG(i,a,n) for(lld i=(lld)a;a<n?i<(lld)n:(lld)n<i;a<n?++i:--i) //for - general
#define FORZ(i,n) for(lld i=0;i<(lld)n;++i) //for - zero
#define FORGI(i,a,n,inc) for(lld i=(lld)a;a<n?i<(lld)n:(lld)n<i;a<n?i+=inc:i-=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<(lld)n;i+=inc) //for - zero incremental
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define MEM(a,val) memset(a,val,sizeof(a));
 
#define SORTall(m) sort(m.begin(),m.end());
#define all(m) m.begin(),m.end()
 
#define st first
#define nd second
#define pb push_back
#define DEC(x) fixed<<setprecision(x)
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
//DEBUGGER------------------------------------------------------------------------
// #define DEBUG(x) cerr<<(#x)<<" is "<<(x)<<"\n" //to debug values of variables
#define DEBUGON
#define ZINDA cerr<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point

#ifdef DEBUGON
	vector<string> vec_splitter(string s) 
	{
		for(char& c: s) c = c == ',' ?  ' ': c;
		stringstream ss; ss << s;
		vector<string> res;
		for(string z; ss >> z; res.push_back(z));
		return res;
	}

	void debug_out(vector<string> args, int idx) { cerr << endl; }
	template <typename Head, typename... Tail>
		void debug_out(vector<string> args, int idx, Head H, Tail... T) 
		{
			if(idx > 0) cerr << ", ";
			stringstream ss; ss << H;
			cerr << args[idx] << " = " << ss.str();
			debug_out(args, idx + 1, T...);
		}

	#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__);
	#define DEBUG(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__);	
#else
	#define debug(...) 320;
	#define DEBUG(...) 320;
#endif

lld power(lld b, lld e)
{
	assert(e>=0);
    if(e==0)
        return 1;
    if(e%2==1)
        return b*power(b*b,(e-1)/2);
    else
        return power(b*b,e/2);
}
 
lld power(lld b, lld e, lld m)
{
	assert(e>=0);
	if(e==0)
		return 1;
	if(e%2==1)
		return b*power(((b%m)*(b%m))%m,(e-1)/2,m)%m;
	else
		return power(((b%m)*(b%m))%m,e/2,m)%m;
}
 
int nDig(lld n)
{
	if(n<0) 
		n*=-1;
	if(n==0)
		return 1;

    return floor(log10(n) + 1);
}

int lognk(lld n, lld k) // logk(n)
{
	assert(n>=0 and k>=0 and k!=1);
	if(n==0)
		return -1;

	return lognk(n/k,k)+1;
}

const long double pi = acos(-1);
#define endl '\n'
#define mod 1000000007

//endl : changed to '\n', to flush comment that definition
//--------------------------------------------------------------------------------

lld arr[10000007];
void swagWaalaFunction()
{
	lld n,ans=0;
	cin>>n;

	for (lld i = 1; i <= n; ++i)
	 for (lld j = i; j <= n; j += i)
	  ++arr[j];	

	FORZ(i,n+1)
		ans+=i*arr[i];

	cout<<ans;
	return;
}

int main()
{
    SPEEDUP;
 	lld t=1;
 	//cin>>t;

 	#ifdef PRIMES
 		sieve();
 	#endif

 	#ifdef CHOOSE
 		nCrModInit();
 	#endif

 	while(t--)
 		swagWaalaFunction();
	
	// cerr<<"\n"<<timeKyaHorhaH; 	
 	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n+1, -1);
	for(int i=1; i<=n; i++) cin >> a[i];
	int ans=0, succ=0;
	for(int i=n; i>=0; i--){
		if(a[i]==i){
			succ++;
		}else{
			ans += (succ+1)/2;
			succ = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
let () =
  let comp x y =
    let s = String.compare (fst x) (fst y) in
    if s = 0 then
      if (snd x) > (snd y) then 1 else -1
    else
      s
  in
  let rec read h =
    try let (x,y) = Scanf.scanf " %s %d\n" (fun x y -> (x,y)) in
        read ((x,y)::h)
    with End_of_file -> h
  in
  let l = read [] in
  let sorted = List.sort comp l in
  let rec loop prev = function
      [] -> print_newline ()
    | h::tl ->
       if prev = (fst h) then
         Printf.printf " %d" (snd h)
       else
         begin
           if prev <> "" then Printf.printf "\n" else ();
           Printf.printf "%s\n%d" (fst h) (snd h)
         end;
       loop (fst h) tl

  in loop "" sorted
;;

Measured memory_bytes: 2452
#include <iostream>

using namespace std;

int n,k;
int* w;

bool clear(int P) {
  int cnt = 1;
  int W = 0;
  for (int i = 0; i < n; i++) {
    if (w[i] > P) {
      return false;
    }
    if (W + w[i] > P) {
      cnt++;

      if (cnt > k) {
        return false;
      }

      W = w[i];
    } else {
      W += w[i];
    }
  }
  return true;
}

int main() {
  cin >> n >> k;
  w = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }

  int l = 0;
  int r = 1000000000;
  int m;
  while (l < r) {
    m = (l + r) / 2;
    if (clear(m)) {
      r = m;
    } else {
      l = m + 1;
    }
  }
  cout << l << endl;
}

Measured memory_bytes: 1568
// 2020 03/28 ABC 160 C
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main () {
    int K, N;
    int a, tmp1, tmp2;
    int ans;
    vector<int> dst;
    cin >> K >> N;
    vector<int> R;

    rep(i, N) {
        cin >> a;
        dst.push_back(a);
    }

    sort(dst.begin(), dst.end());
    R.push_back(dst[0]);
    rep(i, N-1) {
        R.push_back(dst[i+1] - dst[i]);
    }
//    rep(i, R.size()) {
//        cout << R[i] << endl;
//    }

    tmp1 = *max_element(R.begin(), R.end());
    tmp2 = K - dst[N-1] + dst[0];
    ans = max(tmp1, tmp2);

//    cout << tmp1 << " " << tmp2 << " " << ans << endl;

    cout << K - ans << endl;

    return 0;
}


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


int main(){
  int N;
  cin >> N;
  vector<tuple<string, int, int>> S(N);
  for(int ii=0; ii<N; ii++){
    string s;
    int p;
    cin >> s >> p;
    S[ii] = make_tuple(s, p, ii+1);
  }
  sort(
    S.begin(),
    S.end(),
    [](const tuple<string, int, int>& a, const tuple<string, int, int>& b){
      if(get<0>(a) != get<0>(b)) return get<0>(a) < get<0>(b);
      return get<1>(a) > get<1>(b);
    }
  );
  for(auto& s : S){
    cout << get<2>(s) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define int long long int

using namespace std;
typedef pair<int, int> PII;
typedef pair<PII, int> PPI;
typedef pair<int, PII> PIP;
typedef pair<PII, PII> PPP;
typedef vector<PII> VP;
typedef VP::iterator VPI;
typedef vector<int> VI;
const int INF = 3e18;
const double PI = acos(-1);
const int MOD = 1e9 + 7;

int w, h, p[100010], q[100010];
int ans = 0;
int w_done = 0, h_done = 0;

priority_queue<PII, VP, greater<PII> > qu;
signed main()
{
  cin >> w >> h;
  for(int i = 1; i <= w; i++){
    cin >> p[i];
    qu.push(MP(p[i], i));
  }
  for(int i = 1; i <= h; i++){
    cin >> q[i];
    qu.push(MP(q[i], -i));
  }

  while(!qu.empty()){
    PII now = qu.top();
    qu.pop();

    if(now.S > 0){
      ans += now.F * (h + 1 - h_done);
      w_done++;
    }
    else{
      ans += now.F * (w + 1 - w_done);
      h_done++;
    }
  }

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


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int niza[n];
    for(int i=0; i<n; i++)
    {
        cin>>niza[i];
    }
    int sum=0;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(i==j)continue;
            sum+=niza[i]*niza[j];
        }

    }
    cout<<sum/2<<endl;
    return 0;
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    //lol result{0};
    lol n; cin >> n;
    int x;
    lol sum{0};
    //int k; cin >> k;
    vector<int> a(100001);
    REP(i, n)
    {
        cin >> x;
        a[x]++;
        sum += x;
    }
    int q; cin >> q;
    vector<int> b(q);
    vector<int> c(q);
    REP(i, q)
    {
        cin >> b[i];
        cin >> c[i];
    }
    REP(i, q)
    {
        int count{0};
        count = a[b[i]];
        sum = sum + (c[i] - b[i])*count;
        cout << sum;
        cout << endl;
        a[b[i]] = 0;
        a[c[i]] += count;
    }

    //cout << result << endl;
    return 0;
}

Measured memory_bytes: 4516
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    long long x, y=100, cnt=0;
    cin>>x;
 
    while(true){
        if(x<=y){
            cout<<cnt<<endl;
            return 0;
        }
        cnt++;
        y=y+y/100;
    }
}

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

int main(){
    int n;
    cin >> n;
    int a, b, c;
    a = n/100;
    b = (n-100*a) / 10;
    c = (n-100*a-10*b);
    if(a == 7){
        cout << "Yes" << endl;
    }
    else if(b == 7){
        cout << "Yes" << endl;
    }
    else if(c == 7){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <math.h>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

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

int main(void){
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double h_pole_speed = 2 * M_PI / 12.0;
  double m_pole_speed = 2 * M_PI / 60.0;
  double h_dist = h_pole_speed * (H + M / 60) ;
  double m_dist = m_pole_speed * M;
  double dist = sqrt(A*A+B*B-2*A*B*cos(h_dist-m_dist));
  cout << fixed << setprecision(15) << dist << endl;
  return 0;
};

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
long long n,m,ans,temp;

int main()
{
cin>>n>>m;
for(int i=1;i<=m;i++)
{
	cin>>temp;
	ans+=temp;
}
if(n-ans<0)cout<<-1<<endl;
else cout<<n-ans<<endl;
} 

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ep emplace_back
#define st first
#define sc second

using namespace std;

const ll mod = 998244353;
const int e = 300;
const int base = 311;

// dung igt thay cho gt luc tinh giai thua
// 3
// cach tao hoan vi tu n so : n*(n+1)/2;

ll a[e];
ll b[e][e];

int main()
{
   ll n, m, c;
   cin >> n >> m >> c;
   ll ans = 0;
   for(int i=1; i<=m; i++) cin >> a[i];
   for(int i=1; i<=n; i++)
   {
       ll s = 0;
       for(int j=1; j<=m; j++)
       {
           cin >> b[i][j];
           s += b[i][j] * a[j];
       }
       if(s + c > 0)
       ans ++;
   }
   cout << ans;

}


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

int main() {
    long long N;
    cin >> N;
    vector<long long> A(N);
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }

    long long m = N * (N + 1) / 2;
    if (sum % m != 0) {
        cout << "NO" << endl;
        return 0;
    }
    long long num = sum / m;

    for (int i = 0; i < N; i++) {
        long long gap = 0;
        if (i != N - 1) {
            gap = A[i + 1] - A[i] - num;
        } else {
            gap = A[0] - A[N - 1] - num;
        }
        if (gap % N != 0 || gap > 0) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

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

int main() {
	int S;
	int h, m, s;
	cin >> S;
	h = S/3600;
	m = S%3600/60;
	s = S%3600%60;
	cout << h << ":" << m << ":" << s << endl;
	
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define MAX 100000
using namespace std;
int v[MAX][3],n;
int dp[MAX][3];
int solve(int day, int choose)
{
	if(day>=n)
		return 0;
	if(dp[day][choose]!=-1)
		return dp[day][choose];
	int a,b;
	if(choose==0)
		a = 1, b = 2;
	else if(choose==1)
		a = 0, b = 2;
	else
		a = 0, b = 1;
	return (dp[day][choose] = max(solve(day+1,a)+v[day][a],solve(day+1,b)+v[day][b]));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	for(int i=0;i<n;++i)
		for(int j=0;j<3;++j)
			cin>>v[i][j],dp[i][j] = -1;
	int ans = 0;
	for(int i=0;i<3;++i)
		ans = max(ans,solve(0,i));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12228
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    string s, t;
    cin >> s >> t;

    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == t[i])
        {
            ans ++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
?????¢
"""
import math
x1, y1, x2, y2 = map(float,input().strip().split())
x = x1 - x2
y = y1 - y2

distance = math.sqrt(x * x + y * y)

print(distance)

Measured memory_bytes: 7552