akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod %
using namespace std;
using ll = long long;
using P = pair<int,int>;

//解説放送観て回答

int main(){
    int n; cin >> n;
    vector<int> p(n), q(n);
    rep(i,n) cin >> p.at(i);
    rep(i,n) cin >> q.at(i);
    vector<int> a(n);
    rep(i,n) a[i] = i + 1;

    map<vector<int>, int> mp;
    do{
        mp[a] = mp.size();
    }while(next_permutation(a.begin(),a.end()));

    cout << abs(mp[p] - mp[q]) << endl;
}

Measured memory_bytes: 5248
import math
from itertools import accumulate
q=int(input())
l=[]
r=[]
for i in range(q):
  a,b=list(map(int,input().split()))
  l.append(a)
  r.append(b)
  
def is_prime(n):
  if n==1:
    return False
  elif n==2:
    return True
  else:
    for i in range(2,int(math.sqrt(n)+1)):
      if n%i==0:
        return False
  return True

l_min=min(l)
r_max=max(r)
ruiseki=[]
for i in range(l_min,r_max+1):
  if i%2==1 and is_prime(i) and is_prime((i+1)//2):
    ruiseki.append(1)
  else:
    ruiseki.append(0)
    
ruiseki=[0]+list(accumulate(ruiseki))

for i in range(q):
  print(ruiseki[r[i]-l_min+1]-ruiseki[l[i]-l_min])
  
    
    
  


Measured memory_bytes: 21476
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long a = in.nextLong();
            long b = in.nextLong();
            long c = in.nextLong();
            long d = in.nextLong();

            for (int i = 0; i < n; i++) {
                long max = a + d * i - c * (n - 1 - i);
                long min = a + c * i - d * (n - 1 - i);

                if (min <= b && b <= max) {
                    out.println("YES");
                    return;
                }
            }

            out.println("NO");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 23380
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

#define size_t int
typedef long long ll;
// #define int long long
typedef vector<int> VI;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define debug(x) cerr << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug1(i, x) cerr << "(" << (i) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug2(i, j, x) cerr << "(" << (i) << ", " << (j) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
template <typename T> class vec2d : public vector<vector<T>> {
public:
    vec2d(int H, int W): vector<vector<T>> (H, vector<T>(W)) {
    }
};
template <typename T> istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template <typename T> ostream& operator << (ostream& os, vector<T>& vec){
  REP(i, vec.size()) {
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0);
        // cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

signed main(signed argc, char **argv) {
  int N;
  cin >> N;
  VI H(N);
  cin >> H;
  int max = 0;
  int ans = 0;
  for (size_t i = 0; i < N; i++) {
    if (H[i] >= max) {
      ans++;
      max = H[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        long x=fsc.nextLong();
        fsc.close();
        int s=0;
        int add=1;
        while(true){
            s+=add;
            if(s>=x){
                System.out.println(add);
                return;
            }
            add++;
        }
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define fix  cout<<std::fixed;
#define mk make_pair
#define N 200005
#define mod 1000000007
#define time  cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
#define IOS        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
  ll n,k; cin >> n >> k;
  vector<int> a(n),s,ord(n+1, -1); 
  for(int i=0;i<n;i++) cin >> a[i];
  int c = 1, l = 0;
  {
    int v = 1;
    while(ord[v] == -1){
      ord[v] = s.size();
      s.push_back(v);
      v = a[v-1];
    }
    c = s.size() - ord[v];
    l = ord[v];
  }
  if(k < l) cout << s[k] << endl;
  else{
    k -= l;
    k %= c;
    cout << s[l+k] << endl;
  }
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, a, b, r;

int main() {
	cin >> n >> a >> b;
	if (a>b || (n==1 && a!=b)) r = 0;
	else if (n==1 && a==b) r = 1;
	// (最小値をn-1回、最大値を1回使う総和)から(最小値を1回、最大値をn-1回使う総和)までの数字を全て作れる
	else r = (n-2)*(b-a) + 1;
	cout << r << ln;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(), b = sc.nextLong(), n = sc.nextLong();
        long x = 0;
      	if (n < b) {
            x = n;
        }
        else if (n > b) {
            x = b - 1;
        }
        else {
            x = b > 1 ? b - 1 : 1;
        }
        long ans = (a * x)/b;
        if (b == 1) {
            ans = 0;
        }

        System.out.println(ans);
    }
}

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

int main() {
  int k, a, b, ans = 0 ,as = false;
  cin >> k >> a >> b; 
  
  while(a <= b){
        if(0 == a % k){
          as=true;
          break;
        }
        a++;
  }
  if(as == true)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
        
    
  
}


Measured memory_bytes: 3580
#年齢を取得
N = int(input())
#年齢による条件判断
if N == 1:
    print('Hello World')
elif N == 2:
    #AとBの値を取得
    A = int(input())
    B = int(input())
    #制約の判断
    if A < 1 or A > 9 or B < 1 or B > 9:
        SystemExit
    print(A+B)


Measured memory_bytes: 2940
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll right=(c-(a+b));
    if(right<0)
    {
        cout<<"No";
        return;
    }
    right=(right*right);
    ll left=4*a*b;
    if(left<right)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 12032
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    int n, x;
    int i, sum = 0, ans = 0;
    
    cin >> n >> x;
    
    int m[n];
    
    for(i = 0; i < n; i++) {
        cin >> m[i];
        sum += m[i];
    }
    
    sort(m, m+n);
    
    ans += n;
    ans += (x - sum) / m[0];
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int N, M;
	int total = 0;

	cin >> N;
	int T[N];

	for (int i = 0; i < N; i++) {
		cin >> T[i];
		total += T[i];
	}
	cin >> M;
	int P[M], X[M];

	for (int i = 0; i < M; i++) {
		cin >> P[i] >> X[i];
	}
	for (int i = 0; i < M; i++) {
		cout << (total - T[P[i] - 1] + X[i]) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if (a%2==b%2) {
    int k=(a+b)/2;
    cout << k << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void answer1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void answer2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void answer3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void answer(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i, j;
  //ll n;
  //cin >> n;
  ll n;
  cin >> n;
  //string s; cin >> s;
  ll result = 0;
  bool judge = true;
  
  vector<ll> a(n),b(n);
  for(i=0;i<n;i++){
    cin >> a[i];
    b[i] = a[i];
  }
    
  sort(ALL(b));

  for(i=0;i<n;i++){
    if(a[i]>=b[n/2]){
      cout<<b[n/2-1]<<endl;
    }
    else{
      cout<<b[n/2]<<endl;
    }
  }





  return 0;
}

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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

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


signed main(){


	string S;
	cin >> S;
	int m = (S[5]-'0')*10 + (S[6]-'0');

	if (m <= 4)
		cout << "Heisei" << endl;
	else
		cout << "TBD" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
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;}

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define repi(i,a,b) for(int i=(a),_i=(b);i<_i;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif

int main() {
  int in(K);
  int in(A);
  int in(B);

  rep(i, A, B+1) {
    if (i % K == 0) {
      cout << "OK\n";
      return 0;
    }
  }
      cout << "NG\n";

  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	double h, w, x, y;
	cin >> h >> w >> x >> y;
	double nx = h / 2, ny = w / 2;
	cout << h * w / 2 << " ";
	if (x == nx && y == ny)cout << 1 << endl;
	else cout << 0 << endl;
	ggr
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    map<ll,ll> m;
    ll ans=0;
    rep(i,n){
        ll a;
        cin>>a;
        ans+=a;
        m[a]++;
    }
    int q;
    cin>>q;
    rep(i,q){
        ll b,c;
        cin>>b>>c;
        ans+=m[b]*(c-b);
        m[c]+=m[b];
        m[b]=0;
        cout<<ans<<endl;
    }
}



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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

void solve(){
	int n, last, a;
	ll ans = 0ll;
	scanf("%d%d", &n, &last);
	if (last) {
		printf("-1\n");
		return;
	}
	REP(i, 1, n){
		scanf("%d", &a);
		if (a > last + 1){
			printf("-1\n");
			return;
		} else if (a < last + 1){
			ans += last;
		}
		last = a;
	}
	ans += last;
	printf("%lld\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char str[4];
    int a[4];
    gets(str);
    for(int i=0;i<4;i++)
        a[i] = str[i]-'0';
    int ans,temp,i;
    for(i = 0;i<8;i++)
    {
        ans = a[0];
        for(int j = 0;j<3;j++)
        {
            temp = ((i>>j)&1)?1:-1;
            ans += temp * a[j+1];
        }
        if(ans==7) break;
    }
    printf("%d",a[0]);
    char c;
    for(int j=0;j<3;j++)
    {
        c = ((i>>j)&1)?'+':'-';
        printf("%c%d",c,a[j+1]);
    }
    printf("=7");
}


Measured memory_bytes: 128
#include <climits>
#include <cstdlib>
#include <iostream>

int main() {
    long long N, K;
    std::cin >> N >> K;
    long long H[N];
    for (int i = 0; i < N; i++) {
        std::cin >> H[i];
    }
    long long dp[N];
    for (int i = 0; i < N; ++i) {
        dp[i] = LLONG_MAX;
    }
    dp[0] = 0;
    for (int i = 0; i < N - 1; ++i) {
        for (int j = 1; j < K + 1; ++j) {
            if (i + j < N) {
                dp[i+j] = std::min(dp[i+j], dp[i] + abs(H[i+j] - H[i]));
            }
        }
    }
    std::cout << dp[N-1] << std::endl;
    return 0;
}

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

using namespace std;

int main()
{
    int N,M,sum;
    cin >> N ;
    vector<int> T(N);
    for (int i = 0; i < N; i++)
    {
        cin >> T.at(i);
        sum += T.at(i);
    }
    cin >> M ;
    vector<int> P(M),X(M);
    for (int i = 0; i < M; i++)
    {
        cin >> P.at(i) >> X.at(i);
        cout << (sum - T.at(P.at(i)-1) + X.at(i)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
 int n,i,j;
 int x[8]={};
 int y[8]={};
 scanf("%d",&n);
 for (i=0;i<n;i++)
  scanf("%d%d",&x[i],&y[i]);
 double s=0;
 for (i=0;i<n;i++)
  for (j=i+1;j<n;j++)
   s+=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
 printf("%.7f\n",s/n*2);
 return 0;
}

Measured memory_bytes: 128
// you**can**do**anything :~  
#include <bits/stdc++.h>
#include<iostream> 
#include<algorithm> 
#include<vector> 
#define ll long long
//#define  loop(y)  for((int)i=0 ; i<int(y) ,i++)
const int maxn=5e5+10;
using namespace std;
int main() {
cin.tie(0); cout.tie(0);
//ios_base :: sync_with_stdio( 0 ) ;
 ll n ,m ,x,sum=0;
 cin>>n;
map<ll ,ll>a;

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

ll all=((n*(n+1))/2)-1 ,current=2 ,ans=0;


//cout<<all<<" "<<a[1]<<" "<<a[2]; 
for(int i=1 ;i<= n ;i++){
	
	ans=0;
	
	for(int y=0 ; y<a[i] ;y++){
		if(all-current >= 0)
		 ans++,
		   current++;
		
	}
	
	
	cout<<ans<<endl;
	
}







}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    ll ans = 0;
    rep (i, N) {
        ans += i;
    }

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

Measured memory_bytes: 256
import sys
n,q=map(int,input().split())
s=input()
l=[[i for i in l.split()] for l in sys.stdin]
def right_fallen(x):
  stack=x
  for i in range(q):
    if stack==n:
      return True
    if stack==-1:
      return False
    if l[i][0]==s[stack]:
      if l[i][1]=='R':
        stack+=1
      else:
        stack-=1
  if stack==n:
    return True
  return False
def left_fallen(x):
  stack=x
  for i in range(q):
    if stack==n:
      return False
    if stack==-1:
      return True
    if l[i][0]==s[stack]:
      if l[i][1]=='R':
        stack+=1
      else:
        stack-=1
  if stack==-1:
    return True
  return False
def binary_search():
  ok=n
  ng=-1
  while(abs(ok-ng)>1):
    mid=(ok+ng)//2
    if right_fallen(mid):
      ok=mid
    else:
      ng=mid
  return ok
def binary_search2():
  ok=-1
  ng=n
  while(abs(ok-ng)>1):
    mid=(ok+ng)//2
    if left_fallen(mid):
      ok=mid
    else:
      ng=mid
  return ok
print(binary_search()-binary_search2()-1)

Measured memory_bytes: 86620
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

// ────────────────────────────────────────────────────

int main() {
	int n; cin >> n;
	vi a(n); rep(i, n) cin >> a[i];

	int q; cin >> q;
	vi x(q), y(q); rep(i, q) cin >> x[i] >> y[i];

	vi sorted(n);
	sorted = a;
	sort(ASC(sorted));

	int same = 0;
	vb check(n, false);
	rep(i, n) if (a[i] == sorted[i]) same++, check[i] = true;

	int cnt = 0;

	rep(i, q) {
		if (same == n) break;

		swap(a[x[i] - 1], a[y[i] - 1]);

		if (a[x[i] - 1] == sorted[x[i] - 1] && check[x[i] - 1] == false) same++, check[x[i] - 1] = true;
		if (a[y[i] - 1] == sorted[y[i] - 1] && check[y[i] - 1] == false) same++, check[y[i] - 1] = true;
		if (a[x[i] - 1] != sorted[x[i] - 1] && check[x[i] - 1] == true) same--, check[x[i] - 1] = false;
		if (a[y[i] - 1] != sorted[y[i] - 1] && check[y[i] - 1] == true) same--, check[y[i] - 1] = false;

		cnt++;
	}

	rep(i, n) {
		if (a[i] != sorted[i]) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << cnt << endl;
}



Measured memory_bytes: 7600
#include <bits/stdc++.h>
using namespace std;
#define ll long
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define m_p make_pair
#define p_b push_back
#define MOD 1000000007
typedef pair<ll,ll> pl;

ll t;
map<pl,ll> edges[1];
map<pl,ll> marked[1];
map<ll,ll> zero[1];
stack<ll> v[1][100005];
ll m,n;
ll edgecutter(ll a,ll b);

ll edge_num(ll a)
{


	while(!v[t][a].empty())
	{
		ll y = v[t][a].top();
		v[t][a].pop();

		if(marked[t][m_p(a,y)]==1||marked[t][m_p(y,a)]==1)
		{
			//cazz;
		}
		else
		{
			return edgecutter(y,a);

		}
	}
	return 0;

}

ll edgecutter(ll a,ll b)
{
	marked[t][m_p(a,b)]=1;

	ll x = edge_num(a);

	ll y = edge_num(b);

	if(x%2==1)
	{
		edges[t][m_p(b,a)] = 1;
	}
	else
	{
		edges[t][m_p(a,b)] = 1;
	}
	return (1+x+y);

}


int main()
{
	nfs;

	//cin >> t;
	t = 1;

	while(t--)
	{
		cin >> n >> m;
		pl storer[m];

		ll i;
		ll a,b;

		if(m%2==1)
		{
			F(i,0,m)
			{
				cin >> a >> b;

			}
			cout << -1 << endl;
			continue;

		}
		F(i,0,m)
		{

			cin >> a >> b;
			storer[i].first = a;
			storer[i].second = b;
			v[t][a].push(b);
			v[t][b].push(a);
		}

		edgecutter(storer[0].first,storer[0].second);
		F(i,0,m)
		{
			if(1 - edges[t][storer[i]])
            {

                cout << storer[i].first << " " << storer[i].second << endl;
            }
            else
            {

                cout << storer[i].second << " " << storer[i].first << endl;

            }
		}
		//cout << endl;



	}
	return 0;

}



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

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}

int a[35];

void solve()
{
  string ans = "";
  int pre, i, dir = 0, now = 0;
  int mov[] = {1,5,-1,-5};
  string c[] = {"R","D","L","U"};
  do
  {
    pre = (dir+2)%4;
    for(i=(pre+1)%4;i!=pre;++i%=4)
    {
      if(a[now]>>i&1)
      {
        dir = i;
        break;
      }
    }
    if(i == pre) dir = pre;
    ans += c[dir];
    now += mov[dir];
  }
  while(now != 0);
  cout << ans << "\n";
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  fill_n(a,35,0);
  string s; int c;
  REP(i,9)
  {
    cin >> s;
    c = i/2;
    if(i%2==0)
    {
      REP(j,4) if(s[j]=='1')
      {
        a[c*5+j] += 1;
        a[c*5+j+1] += 4;
      }
    }
    else
    {
      REP(j,5) if(s[j]=='1')
      {
        a[c*5+j] += 2;
        a[(c+1)*5+j] += 8;
      }
    }
  }
  solve();
  return 0;
}

Measured memory_bytes: 1172
def main():
    N = int(input())
    s = [int(input()) for _ in range(N)]

    tot = sum(s)

    if tot % 10 == 0:
        s.sort()
        for x in s:
            if x % 10 == 0: continue
            tot -= x
            break
        else:
            tot = 0
    print(tot)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
    

  int N;
  cin >> N;
  vector<int> a(N+1);
  for(int i = 1;i <= N;i++)cin >> a[i];

  map<int,int> mp;

  vector<int> ans;
  for(int i = N;i >= 1;i--){
    int d = (a[i]+mp[i]) % 2;
    if(d)ans.push_back(i);
    for(int j = 1;j * j <= i;j++){
      if(i % j == 0){
        if(j * j != i){
          mp[j] += d;
          mp[i/j] += d;
        }
        else{
          mp[j] += d;
        }
      }
    }
  }

  cout << ans.size() << endl;
  for(int i = 0;i < ans.size();i++)cout << ans[i] << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 11384
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=100005;
#define M 1000000021
#define double long double
#define BINF 1000000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
const int LG = 22;



#undef int
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#define int long long int

	int n,mm;
	cin>>n>>mm;

	map<int,int>m;
	int ans=0;

	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		for(int j=0;j<k;j++){
			int x;
			cin>>x;
			m[x]++;
		}
	}
	for(auto i:m)
		if(i.S==n) ans++;
	cout<<ans<<endl;


return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from bisect import bisect_left

INF = 10**17

N = int(input())
A = list(map(int, input().split()))
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)


stack = [0]
ans = [-1]*N
dp = [INF]*(N+1)
to_rev = [(-1, -1) for _ in range(N)]
while stack:
    p = stack.pop()
    if p >= 0:
        ind = bisect_left(dp, A[p])
        to_rev[p] = (ind, dp[ind])
        dp[ind] = A[p]
        ans[p] = bisect_left(dp, INF)
        stack.append(~p)
        for np in graph[p]:
            if ans[np] == -1:
                stack.append(np)
    else:
        p = ~p
        ind, score = to_rev[p]
        dp[ind] = score

print(*ans, sep="\n")

Measured memory_bytes: 144692
A = list(input())

if A[0] == A[1] == A[2] == 'R':
    print(3)
elif A[0] == A[1] == 'R' or A[1] == A[2] == 'R':
    print(2)
elif 'R' in A:
    print(1)
else:
    print(0)

Measured memory_bytes: 61632
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
    ll N, M, K;
    cin>>N>>M>>K;
    ll dist = 0;
    for(int i=0;i<N;++i){
        for(int j=0;j<M;++j){
            dist += (M-j-1)*(M-j)/2 % mod;
            dist %= mod;
            dist += (N-i-1)*(N-i)/2%mod*M%mod;
            dist %= mod;
            dist += j*(j+1)/2%mod*(N-i-1)%mod;
            dist %= mod;
            dist += (M-j-1)*(M-j)/2%mod*(N-i-1)%mod;
            dist %= mod;
        }
    }
    ll ue = 1, shita1 = 1, shita2 = 1;
    for(ll i=1;i<=N*M-2;++i){
        ue *= i;
        ue %= mod;
    }
    for(ll i=1;i<=K-2;++i){
        shita1 *= i;
        shita1 %= mod;
    }
    for(ll i=1;i<=N*M-K;++i){
        shita2 *= i;
        shita2 %= mod;
    }
    ll two, tmpshita1, tmpshita2, shita11=1, shita22=1, h;
    h = mod - 2;
    while(h>0){
        two = 1;
        tmpshita1 = shita1;
        tmpshita2 = shita2;
        while(2*two<=h){
            two *= 2;
            tmpshita1 *= tmpshita1;
            tmpshita1 %= mod;
            tmpshita2 *= tmpshita2;
            tmpshita2 %= mod;
        }
        h -= two;
        shita11 *= tmpshita1;
        shita11 %= mod;
        shita22 *= tmpshita2;
        shita22 %= mod;
    }
    cout<<dist*ue%mod*shita11%mod*shita22%mod<<endl;
}



Measured memory_bytes: 256
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  string s, t;
  cin >> s >> t;
  int ans = INF;
  for (int i = 0; i <= s.size() - t.size(); i++) {
    int cnt = 0;
    for (int j = 0; j < t.size(); j++) {
      if (s[i + j] != t[j]) cnt++;
    }
    chmin(ans, cnt);
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

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


Measured memory_bytes: 3648
#include<stdio.h>

int main()
{
	int a, b, k, i, j;

	scanf("%d", &k);
	scanf("%d %d", &a, &b);
	i = a;

	while (a <= i && i <= b) {
		for (j = 1;j <=(int)(1000/k);j++) {
			if (i == j * k) {
				printf("OK");
				return 0;
			}
		}
		i++;
	}
	printf("NG");
	return 0;
}

Measured memory_bytes: 1728
def main():
    n = int(input())
    array = [int(x) for x in input().split()]

    cnt = 0
    for i in range(n):
        min_idx = i
        for j in range(i+1, n):
            if array[min_idx] > array[j]:
                min_idx = j
        if min_idx != i:
            tmp = array[i]
            array[i] = array[min_idx]
            array[min_idx] = tmp
            cnt += 1

    print(" ".join(map(str, array)))
    print(cnt)


main()


Measured memory_bytes: 5600
var input= require('fs').readFileSync('/dev/stdin', 'utf8');
var ar = input.split(' ').map(Number);
var W = ar[0];
var H = ar[1];
var x = ar[2];
var y = ar[3];
var r = ar[4];

if (x-r<0 || x+r>W || y-r<0 || y+r>H) console.log('No')
else console.log('Yes')


Measured memory_bytes: 15112
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int M = 1000000007;

int main() {
    while (1) {
        int n;
        cin >> n;
        if (!n) return 0;

        vector<int> w(n);
        for (int i = 0; i < n; ++i) {
            cin >> w[i];
        }
        vector<vector<int>> dp(n, vector<int>(n + 1, 0));
        for (int i = 2; i <= n; ++i) {
            for (int j = 0; i + j <= n; ++j) {
                if (dp[j + 1][i - 2] == i - 2 && abs(w[j] - w[i + j - 1]) < 2) {
                    dp[j][i] = i;
                    continue;
                }
                for (int k = 1; k < i; ++k) {
                    dp[j][i] = max(dp[j][i], dp[j][k] + dp[j + k][i - k]);
                }
            }
        }
        cout << dp[0][n] << "\n";
    }
}

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

int main(){
  int a, b, c; 
  cin >> a >> b >> c;
  
  int ma = max({a, b, c});
  int rem = 3 * ma - (a + b + c);
  
  int ans = 0;
  if(rem % 2 == 0){
    ans = rem / 2;
  }else{
    ans = rem / 2 + 2;
  }
  
  cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
input = readlines()

meta = input.shift.chomp.split("\s").map{|x| x.to_i}

total = meta[0]
buy = meta[1]

prices = input.shift.chomp.split("\s").map{|x| x.to_i}

prices.sort!

res = 0
(1..buy).each do |i|
  res += prices[i - 1]
end

puts res


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

int main() {
	int a, b;

	std::cin >> a >> b;

	int ans = 0;

	if (a > b) {
		ans = a;
		a--;
	}
	else {
		ans = b;
		b--;
	}
	
	ans += std::max(a, b);

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[11];
int main() {

    for (int i = 0; i < 3; i++) {
        int n;
        cin >> n;
        a[n]++;
    }
//    cout << a[5] << a[7] << '\n';
    if (a[5] == 2 && a[7] == 1) cout << "YES" << '\n';
    else cout << "NO" << '\n';

}


Measured memory_bytes: 256
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>

using namespace std;

typedef pair<double, double>P;

int N;
const double INF=1000000000;
P A[1000000];

bool comp_y(P a,P b){
  return a.second<b.second;
}

double closest_pair(P *a, int n){
  if(n<=1)return INF;
  int m=n/2;
  double x=a[m].first;
  double d=min(closest_pair(a,m),closest_pair(a+m,n-m));
  inplace_merge(a,a+m,a+n,comp_y);

  vector<P>b;
  for(int i=0;i<n;i++){
    if(abs(a[i].first-x)>=d)continue;
    for(int j=0;j<b.size();j++){
      double dx = a[i].first-b[b.size()-j-1].first;
      double dy = a[i].second-b[b.size()-j-1].second;
      if(dy>=d)break;
      d=min(d,dx*dx+dy*dy);
    }
    b.push_back(a[i]);
  }
  return d;
}

int main(void){

  P in;

  cin >> N;
    for(int i=0;i<N;i++){
      cin >> in.first >> in.second;
      A[i]=in;
    }
    sort(A,A+N);
    double ans=closest_pair(A,N);
    cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 28316
n=int(input())
a=n//3*(n//3+1)//2
threesum=a*3
b=n//5*(n//5+1)//2
fivesum=b*5
c=n//15*(n//15+1)//2
fifteensum=c*15
left=threesum+fivesum-fifteensum
sum=n*(n+1)//2
print(sum-left)

Measured memory_bytes: 61692
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = line[0];
            int B = line[1];
            int T = line[2];
            Console.WriteLine(T / A * B);
        }
    }
}

Measured memory_bytes: 13140
INF = float('inf')
N,M,L = map(int,input().split())
cost = [[INF]*N for _ in range(N)]
for i in range(M):
    a,b,c = map(int,input().split())
    cost[a-1][b-1] = c
    cost[b-1][a-1] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            if cost[i][j] > cost[i][k]+cost[k][j]:
                cost[i][j] = cost[i][k]+cost[k][j]

for i in range(N):
    for j in range(N):
        if cost[i][j] > L:
            cost[i][j] = INF
        else:
            cost[i][j] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            if cost[i][j] > cost[i][k]+cost[k][j]:
                cost[i][j] = cost[i][k]+cost[k][j]

for i in range(N):
    for j in range(N):
        if cost[i][j] == INF:
            cost[i][j] = -1
        else:
            cost[i][j] -= 1

Q = int(input())

for i in range(Q):
    s,t = map(int,input().split())
    print(cost[s-1][t-1])



Measured memory_bytes: 77784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    char c; cin >> c;
    if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u') cout << "vowel\n";
    else cout << "consonant\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main () {
	int M[N][N];
	int n, u, k, v;
	int i, j;

	scanf("%d",&n);

	for ( i = 0; i < n; i++) {
		for ( j = 0; j < n; j++) M[i][j] = 0;
	}

	for ( i = 0; i < n; i++) {
		scanf("%d%d", &u, &k);
		u--;
		for ( j = 0; j < k; j++) {
			scanf("%d",&v);
			v--;
			M[u][v] = 1;
		}
	}

	for ( i = 0; i < n; i++) {
		for ( j = 0; j < n; j++) {
			if (j) printf(" ");
			printf("%d",M[i][j]);
		}
		printf("\n");
	}

	return 0;
}



Measured memory_bytes: 2052
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

res = 0

for aa in a:
    x -= aa
    if x < 0:
        print(res)
        exit()
    res += 1

if x == 0:
    print(N)
else:
    print(N - 1)

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

int main() {
  int d,n;cin>>d>>n;
  if(d==0&&n!=100)cout<<n<<endl;
  else if(d==0&&n==100)cout<<101<<endl;
  else if(d==1&&n!=100)cout<<n*100<<endl;
  else if(d==1&&n==100)cout<<10100<<endl;
  else if(d==2&&n!=100)cout<<n*100*100<<endl;
  else if(d==2&&n==100)cout<<1010000<<endl;
}

Measured memory_bytes: 3616
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll a,b,c; cin >> a >> b >> c;
    ll x; cin >> x;
    ll ans = 0;
    rep(i,0,a+1)rep(j,0,b+1)rep(k,0,c+1){
        if(i * 500 + j * 100 + k * 50 == x)ans++;
    }

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    long long n, idx, ans = 0;
    long long a[100001] = {0};
    cin >> n;
    rep(i, n){
        cin >> idx;
        a[idx] += 1;
        ans += idx;
    }
 
    int q;
    cin >> q;
    rep(i, q){
        long long b, c, increment, elements_were_b;
        cin >> b >> c;
        
        ans += (c-b)*a[b];
        a[c] += a[b];
        a[b] = 0;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int n, k, l;
vector<int> edgeS[200010];
vector<int> edgeT[200010];
int ans[200010];

int bfs(int start){
	if(ans[start] != -1) return ans[start];
	queue<int> que;

	que.push(start);
	bool usedS[200010] = {};
	while(que.size()){
		int now = que.front();que.pop();

		if(usedS[now]) continue;
		usedS[now] = true;

		REP(i, edgeS[now].size()){
			que.push(edgeS[now][i]);
		}
	}

	que.push(start);
	bool usedT[200010] = {};
	vector<int> usedAll;
	while(que.size()){
		int now = que.front();que.pop();

		if(usedT[now]) continue;
		usedT[now] = true;
		if(usedS[now]){
			usedAll.push_back(now);
		}

		REP(i, edgeT[now].size()){
			que.push(edgeT[now][i]);
		}
	}

	REP(i, usedAll.size()){
		ans[usedAll[i]] = usedAll.size();
	}

	return ans[start];
}

int main() {
	bool connectS[200010] = {}, connectT[200010] = {};
	REP(i, 200010) ans[i] = -1;
	cin >> n >> k >> l;
	int a, b;
	REP(i, k){
		cin >> a >> b;
		a--;b--;
		connectS[a] = true;
		connectS[b] = true;
		edgeS[a].push_back(b);
		edgeS[b].push_back(a);
	}

	REP(i, l){
		cin >> a >> b;
		a--;b--;
		connectT[a] = true;
		connectT[b] = true;
		edgeT[a].push_back(b);
		edgeT[b].push_back(a);
	}

	REP(i, n){
		if(i != n - 1) {
			if(connectS[i] && connectT[i]) cout << bfs(i) << " ";
			else cout << 1 << " ";
		}else{
			if(connectS[i] && connectT[i]) cout << bfs(i) << endl;
			else cout << 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 18560