akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<algorithm>

using namespace std;

int N, K;

long long int x[55], y[55];

long long int min(long long int a, long long int b, long long int c, long long int d) {
	long long int tmp = a;
	if (tmp > b) { tmp = b; }
	if (tmp > c) { tmp = c; }
	if (tmp > d) { tmp = d; }
	return tmp;
}
long long int max(long long int a, long long int b, long long int c, long long int d) {
	long long int tmp = a;
	if (tmp < b) { tmp = b; }
	if (tmp < c) { tmp = c; }
	if (tmp < d) { tmp = d; }
	return tmp;
}

int main(void) {

	cin >> N >> K;

	long long int tmp;
	for (int i = 1; i <= N; i++) {
		cin >> tmp; x[i] = tmp;
		cin >> tmp; y[i] = tmp;
	}

	long long int  ans=4000000000000000001;

	long long int x1, x2, y1, y2;


	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			for (int k = 1; k <= N; k++) {
				for (int l = 1; l <= N; l++) {
					x1 = min(x[i], x[j], x[k], x[l]);
					x2 = max(x[i], x[j], x[k], x[l]);
					y1 = min(y[i], y[j], y[k], y[l]);
					y2 = max(y[i], y[j], y[k], y[l]);
					int count = 0;
					for (int m = 1; m <= N; m++) {
						if (x1 <= x[m] && x[m] <= x2 && y1 <= y[m] && y[m] <= y2) { count++; }
					}
					if (count >= K) { ans = min(ans, (x2 - x1)*(y2 - y1)); }

				}
			}
		}
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

// problem_A

int main() {
    int x,a;
    cin >> x >> a;
    if (x<a){
        cout << 0 << endl;
    }
    else{
        cout << 10 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 500000
#define banhei 2000000000
typedef long long ll;
 
int L[MAX/2+2];
int R[MAX/2+2];
ll count;
 
ll merge(int A[],int n,int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    count=0;
    for(int i=0;i<n1;i++)L[i]=A[left+i];
    for(int i=0;i<n2;i++)R[i]=A[mid+i];
    L[n1]=R[n2]=banhei;
    int i=0;
    int j=0;
    for(int k=left;k<right;k++){
        if(L[i]<=R[j]){
            A[k]=L[i++];
        }else{
            A[k]=R[j++];
            count+=n1-i;
        }
    }
    return count;
}
 
ll mergesort(int A[],int n,int left,int right){
    ll D,E,F;
    if(left+1<right){
        int mid=(left+right)/2;
    D=mergesort(A,n,left,mid);
    E=mergesort(A,n,mid,right);
    F=merge(A,n,left,mid,right);
    return D+E+F;
    }else return 0;
}
 
int main(){
    int A[MAX],n,i;
    count=0;
 
    cin>>n;
    for(i=0;i<n;i++)cin>>A[i];
    
    ll answer=mergesort(A,n,0,n);
    cout << answer << endl;
 
    return 0;
}


Measured memory_bytes: 4676
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    int n; cin>>n;
    vector<double> p(4000);
    rep(i,n) cin>>p[i];

    vector<vector<double>> dp(n+1,vector<double>(n+1,0));

    dp[0][0]=1;

    for(int i=0; i<=n; i++){
        for(int j=0; j<=n; j++){
            if(i>=1&&j>=1) dp[i][j]+=dp[i-1][j-1]*p[i-1];
            if(i>=1) dp[i][j]+=dp[i-1][j]*(1-p[i-1]);
        }
    }

    double sum=0;
    for(int i=n; i>=n/2 +1; i--){
        sum+=dp[n][i];
    }
    cout<<fixed<<setprecision(10);
    cout<<sum<<endl;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN=2e5+5;
LL a[MAXN];
LL b[MAXN];
int main()
{
    int n;
    cin >>n;
        LL ans=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            b[i]=b[i-1]+a[i];
            ans+=a[i];
        }
        LL cmin=INT_MAX;
        for(int i=1;i<n;i++)
        {
            if(cmin>abs(2*b[i]-ans))
                cmin=abs(2*b[i]-ans);
        }
        cout<<cmin<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main(){
    int n;
    int a[200005];

    int sum[200005];

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

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

    return 0;
}

Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define req(i,a,b) for(ll i=(a);i>=(b);--i)
#define name "a"
#define pb push_back
#define sz size()
#define ff first
#define ss second
#define xd '\n'
#define dc " "
#define Truong_Thanh_Minh ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef pair < ll , ll > ii;
const ll maxn = 2e5+7, oo = 1e18, base = 311, mod = 1e9+7;
const double PI = 3.141592654;
ll t, n, m, x, y, ok[maxn], ngroup, cnt[maxn], group[maxn], res;
vector < ll > a[maxn];
void dfs(int i)
{
    ok[i] = 1;
    group[i] = ngroup;
    ++cnt[ngroup];
    for (int j : a[i])
        if (!ok[j])
            dfs(j);
}
int main()
{
    Truong_Thanh_Minh
    //freopen(name".inp","r",stdin);
    //freopen(name".out","w",stdout);
    cin >> n >> m;
    rep (i, 1, m)
    {
        cin >> x >> y;
        a[x].pb(y);
        a[y].pb(x);
    }
    rep (i, 1, n)
    {
        if (!ok[i])
        {
            ++ngroup;
            dfs(i);
        }
    }
    rep (i, 1, ngroup)
        res = max (res, cnt[i]);
    cout << res;
}


Measured memory_bytes: 23948
n = int(input())
a = list(map(int,input().split()))
MOD = 10**9+7

array_sum = 0
for i in range(n):
  array_sum += a[i]
  array_sum %= MOD

ans = 0
for i in range(n):
  array_sum -= a[i]
  ans += array_sum * a[i]
  ans %= MOD
  
print(ans)

Measured memory_bytes: 94332
N = gets.to_i
W = gets.split(' ').map(&:to_i)

mindif = 0
1.upto(N-1) do |i|
  a = W[0..i-1].inject(:+)
  b = W[i..N-1].inject(:+)
  dif = (a-b).abs
  if mindif == 0 || dif < mindif
    mindif = dif
  end
end

p mindif

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
typedef long long ll;
using namespace std;

const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    int N;
    cin >>N;
    vector<int> A(N+1),B(N);
    for(int i = 0; i < N+1; i++)
    {
        cin >> A[i];
        }
    for(int i = 0; i < N; i++)
    {
        cin >> B[i];
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
    ans += min(A[i], B[i]);
    B[i] -= min(A[i], B[i]);
    A[i] -= min(A[i], B[i]);
    ans += min(A[i + 1], B[i]);
    A[i+1] -= min(A[i + 1], B[i]);
  }
    cout << ans << endl;
}


Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	ans := ""
	for N != 0 {
		if N%2 == 0 {
			ans = "0" + ans
		} else {
			ans = "1" + ans
			N--
		}
		N /= -2
	}

	if ans == "" {
		ans = "0"
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.Scanner;

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

        int N = scanner.nextInt();

        int acc = 0;
        int max = 0;
        for(int i=0; i<N; i++){
            int tmp = scanner.nextInt();
            acc += tmp;
            max = Math.max(max, tmp);
        }

        if(acc - max > max){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (final Scanner sc = new Scanner(System.in)) {
            final List<String> pattern = new ArrayList<>(Arrays.asList("Sunny", "Cloudy", "Rainy"));
            final String weather = sc.nextLine();
            final int newIndex = (pattern.indexOf(weather) + 1) % 3;
            System.out.println(pattern.get(newIndex));
        }
    }
}

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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

const ll MOD = 998244353;

ll n, ops;
string s;
vector<ll> sze;
vector<vector<vector<ll>>> dp;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s >> ops;
    n = sz(s); ckmin(ops, n);
    reverse(s.begin(), s.end());
    for(int i = 0; i < n; ++i){
        sze.pb(0);
        while(i < n && s[i] != '0'){
            sze.back()++;
            i++;
        }
    }
    if(s.back() == '0') sze.pb(0);
    // for(auto i : size) cout << i << " ";
    // cout << "\n";
    dp.assign(sz(sze) + 1, vector<vector<ll>>(ops + 1, vector<ll>(ops + 1, 0)));
    dp[0][0][0] = 1;
    for(ll i = 0; i < sz(sze); ++i){
        for(ll j = 0; j <= ops; ++j){
            for(ll k = 0; k <= j; ++k){
                for(ll x = 0; x + k <= j; ++x){
                    dp[i + 1][j][k] += dp[i][j][x + k];
                    dp[i + 1][j][k] %= MOD;
                }
                for (ll x = 1; x <= min(min(sze[i], j), k); ++x){
					dp[i + 1][j][k] += dp[i][j - x][k - x];
					dp[i + 1][j][k] %= MOD;
				}
            }
        }
    }
    ll res = 0;
    for(int i = 0; i <= ops; ++i){
        res += dp[sz(sze)][i][0];
        res %= MOD;
    }
    cout << res;
    return 0;
}

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

int main(){
	int n,k,x,y;
	cin >> n >> k >> x >> y;

	if(n>k){
		cout << (k*x)+(n-k)*y << endl;
	}else if(n<=k){
		cout << (n*x) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll H, W, N; cin >> H >> W >> N;
    ll p = max(H, W);
    if(N%p==0){cout << N/p;}
    else{cout << N/p+1;}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
long long sum1[100010],sum2[100010],x[100010],v[100010],f[100010],a[100010],b[100010],ff[100010],t,n,c,ans,i,j;
void qt(long long l, long long r)
{
    long long i,j;
    long long m,p;
    i=l; j=r;
    m=x[(l+r)/2];
    while (i<=j)
    {
        while (x[i]<m) i++;
        while (x[j]>m) j--;
        if (i<=j)
        {
            p=x[i]; x[i]=x[j]; x[j]=p;
            p=v[i]; v[i]=v[j]; v[j]=p;
            i++; j--;
        }
    }
if (i<r) qt(i,r);
if (l<j) qt(l,j);
}

int main()
{
    scanf("%lld%lld",&n,&c);
    for (i=1;i<=n;i++)
        scanf("%lld%lld",&x[i],&v[i]);
    qt(1,n);
    ans=0;
    memset(sum1,0,sizeof(sum1));
    for (i=1;i<=n;i++)
        sum1[i]=sum1[i-1]+v[i];
    for (i=1;i<=n;i++)
        if (sum1[i]-x[i]>ans) ans=sum1[i]-x[i];
    memset(sum2,0,sizeof(sum2));
    for (i=n;i>=1;i--)
    sum2[i]=sum2[i+1]+v[i];
    for (i=1;i<=n;i++)
        if (sum2[i]-(c-x[i])>ans) ans=sum2[i]-(c-x[i]);
     memset(a,0,sizeof(a));
    memset(f,0,sizeof(f));
    memset(ff,0,sizeof(ff));
    memset(b,0,sizeof(b));
    for (i=1;i<=n;i++)
    {
      if (sum1[i]-x[i]>f[i-1]) f[i]=sum1[i]-x[i]; else f[i]=f[i-1];
      if ((sum1[i]-x[i])>f[i-1]) a[i]=i; else a[i]=a[i-1];
    }

    for (i=n;i>=1;i--)
    {
      if (sum2[i]-(c-x[i])>ff[i+1]) ff[i]=sum2[i]-(c-x[i]); else ff[i]=ff[i+1];
      if ((sum2[i]-(c-x[i]))>ff[i+1]) b[i]=i; else b[i]=b[i+1];
    }

    for (i=1;i<=n;i++)
    {
      if (sum2[i]-(c-x[i])+f[i-1]-x[a[i-1]]>sum2[i]-(c-x[i])+f[i-1]-(c-x[i])) t=sum2[i]-(c-x[i])+f[i-1]-x[a[i-1]]; else
      t=sum2[i]-(c-x[i])+f[i-1]-(c-x[i]);
      if (t>ans)
      ans=t;
    }

    for (i=n;i>=1;i--)
    {
      if (sum1[i]-x[i]+ff[i+1]-(c-x[b[i+1]])>sum1[i]-x[i]+ff[i+1]-x[i]) t=sum1[i]-x[i]+ff[i+1]-(c-x[b[i+1]]); else
      t=sum1[i]-x[i]+ff[i+1]-x[i];
      if (t>ans)
      ans=t;
    }

    printf("%lld\n",ans);
    return(0);
}


Measured memory_bytes: 6528
W,H,x,y,r=list(map(int,input().split()))

if 0<=x<=W/2 and 0<=y<=H/2:
    if x-r>=0 and y-r>=0:
        print("Yes")
    else:
        print("No")
elif W/2<=x<=W and 0<=y<=H/2:
    if x+r<=H and y-r>=0:
        print("Yes")
    else:
        print("No")
elif 0<=x<=W/2 and H/2<=y<=H:
    if x-r>=0 and y+r<=H:
        print("Yes")
    else:
        print("No")
elif W/2<=x<=W and H/2<=y<=H:
    if x+r>=W and y+r>=H:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 5600
#include <iostream>
    #include <string>
    #include <vector>
    #include <math.h>
    using namespace std;
     
    int main() {
        int N,T;
        cin>>N>>T;
        int P[N];
        int min=10000;
        for(int i=0;i<N;i++){
            int c,t;
            cin>>c>>t;
            if(t<=T){
                P[i]=c;
                if(min>P[i]){
                    min=P[i];
                }
            }
            else{
                P[i]=10000;
            }
        }
        if(min==10000){
            cout<<"TLE"<<endl;
        }
        else {
            cout<<min<<endl;
        }
    }

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

int main(){
      int n;
      cin >> n;
      vector<double> u(n);
      for(int i=0; i<n; i++){
          cin >> u.at(i);

      }
      sort(u.begin(), u.end());

      double ans = u.at(0);

      for(int i=1; i<n; i++){
          ans = (double)((double)u.at(i) + (double)ans) / (double)2.0;


      }

      cout << fixed << setprecision(10) << (double)ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cassert>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<tuple>
#include<numeric>
using namespace std;

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl
// vector
template<class T> ostream& operator << (ostream &os , const vector<T> &v) {
    for(const T &t : v) os << "\t" << t; return os << endl;
}
template<class T> istream& operator >> (istream &is , vector<T> &v) {
    for(T &a : v) is >> a; return is;
}
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) {
    return os << "<" << v.first << " " << v.second << ">";
}

void set_shorter(string &s, const string &s1) {
    if(s == "") s = s1;
    if(s1.size() < s.size()) s = s1;
    else if(s1.size() == s.size()) s = min(s, s1);
}


string merge(const string &s1, const string &s2) {
    rep(i, s1.size()) {
        rep(j, s2.size()) {
            if(i + j < s1.size()) {
                if(s1[i + j] != s2[j]) goto FAIL;
            } else {
                return s1 + s2.substr(j);
            }
        }
        return s1;
  FAIL:;
    }
    return s1 + s2;
}

bool solve() {
    int N; cin >> N;
    if(N == 0) return false;
    vector<string> S(N); cin >> S;
    rep(i, S.size()) rep(j, i) {
        if(merge(S[j], S[i]) == S[j]) {
            S.erase(S.begin() + i);
            i--;
            break;
        }
    }
    N = S.size();
    vector<vector<string>> dp(1 << N, vector<string>(N));
    rep(i, N) dp[1 << i][i] = S[i];
    rep(stat, 1 << N) {
        rep(src, N) {
            if(not (stat & (1 << src))) continue;
            rep(dst, N) {
                if(stat & (1 << dst)) continue;
                set_shorter(dp[stat | (1 << dst)][dst], merge(dp[stat][src], S[dst]));                
            }
        }
    }
    string ans = "";
    rep(i, N) {
        set_shorter(ans, dp[(1 << N) - 1][i]);
    }
    cout << ans << endl;
    return true;
}

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

Measured memory_bytes: 3460
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define BIG 2000000007

#define MOD 1000000007
typedef unsigned long long ull;
typedef   signed long long sll;

typedef struct {
	ull above;
	ull below;
	int index;
} hw;

#define N_MAX 52
#define M_MAX 100000

ull n, m, k;
ull h, w;
// ull a[N_MAX];
// ull b[N_MAX];
// ull dp[N_MAX][M_MAX + 1];
char s[N_MAX + 1];

void swap_adj(ull *a, ull *b){
	ull tmp = *b;
	*b = *a;
	*a = tmp;
	return;
}

int comp(const void *a, const void *b){
	if (*(ull*)a > *(ull*)b) {
		return -1;
	} else if (*(ull*)a < *(ull*)b) {
		return +1;
	} else {
		return 0;
	}
}

ull divide(ull a, ull b){
	ull x = MOD - 2;
	ull ans = 1;
	while (x) {
		if (x & 1) ans = (ans * b) % MOD;
		b = (b * b) % MOD;
		x /= 2;
	}
	return (a * ans) % MOD;
}

int digits(ull x){
	int i = 1;
	while (x >= 10) {
		x /= 10;
		i++;
	}
	return i;
}

int min(ull x, ull y){
	return (x < y) ? x : y;
}

ull gcd(ull x, ull y){
	if (x < y) {
		return gcd(y, x);
	} else if (y == 0) {
		return x;
	} else {
		return gcd(y, x % y);
	}
}

ull bitpow(ull a, ull x){
	ull result = 1;
	while (x) {
		if (x & 1) {
			result *= a;
			result %= MOD;
		}
		x /= 2;
		a = (a * a) % MOD;
	}
	return result;
}

ull solve(){
	int i, j;
	ull mul2 = 0, mul3 = 0;
	int prev = 0;

	i = 0;
	while (i < n) {
		if (i + 1 < n && s[i] == s[i + 1]) {
			switch (prev) {
			case 0:
				mul2 = 1;
				mul3 = 1;
				break;
			case 1:
				mul2++;
				break;
			case 2:
				mul3++;
				break;
			}
			prev = 2;
			i += 2;
		} else {
			switch (prev) {
			case 0:
				mul3 = 1;
				break;
			case 1:
				mul2++;
				break;
			case 2:
				//
				break;
			}
			prev = 1;
			i++;
		}
	}

	printf("%llu\n", bitpow(2, mul2) * bitpow(3, mul3) % MOD);

	return 0;
}

int main(void){
	int i, j;

	scanf("%llu", &n);
	scanf("%s", s);
	scanf("%*s");

	solve();

	return 0;
}


Measured memory_bytes: 128
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
res = []
for i in range(n,0,-1):
    if a[i-1]:
        res.append(i)
        for j in make_divisors(i):
            a[j-1] ^= 1
print(len(res))
if len(res) > 0:
    print(*res)

Measured memory_bytes: 93172
#include <iostream>
#include <string>

using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  string ans = "No";
  for (int c = 0; c <= x; c++) {
    int t = x - c;
    if (c * 2 + t * 4 == y) {
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9+1;
#define MAX_V 301
const bool debug = false;

int main(){
    int cost[MAX_V][MAX_V];
    int n,m,l;
    cin >> n >> m >> l;

    rep(i,MAX_V){
        rep(j,MAX_V){
            cost[i][j] = INF;
        }    
    }

    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        cost[a][b] = c;
        cost[b][a] = c;
    }

    int qnum;
    cin >> qnum;
    vector<vector<int>> q(qnum);
    rep(i,qnum){
        int a,b;
        cin >> a >> b;
        q.at(i).push_back(a);
        q.at(i).push_back(b);
    }

    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    if(debug){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                cout << cost[i][j] << " ";
            }
            cout << endl;
        }
        cout << endl;
    }

    int fuel[MAX_V][MAX_V];
    rep(i,MAX_V){
        rep(j,MAX_V){
            if(cost[i][j] <= l) fuel[i][j] = 1;
            else fuel[i][j] = INF;
        }    
    }

    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                fuel[i][j] = min(fuel[i][j], fuel[i][k] + fuel[k][j]);
            }
        }
    }

    if(debug){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                cout << fuel[i][j] << " ";
            }
            cout << endl;
        }
        cout << endl;
    }

    rep(i,qnum){
        int x = fuel[q.at(i).at(0)][q.at(i).at(1)];
        if(x == INF) cout << -1 << endl;
        else cout << x-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 2e5 + 9;
const ll p = 31;
// const ll m = 1e9 + 7;
const ll inf= 1e14;
const ll mod = 1e9 +7;
#define x first
#define y second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
ll a[N],h[N],b[N],t[4*N];

void build(ll v, ll tl, ll tr) {
    if (tl == tr) {
        t[v] = a[tl];
    } else {
        ll tm = (tl + tr) / 2;
        build( v*2, tl, tm);
        build(v*2+1, tm+1, tr);
        t[v] = max(t[v*2] , t[v*2+1]);
    }
}

ll sum(ll v, ll tl, ll tr, ll l, ll r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    ll tm = (tl + tr) / 2;
    return max(sum(v*2, tl, tm, l, min(r, tm))
           ,sum(v*2+1, tm+1, tr, max(l, tm+1), r));
}

void update(ll v, ll tl, ll tr, ll pos, ll new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        ll tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = max(t[v*2] , t[v*2+1]);
    }
}
int main()
{   
     ios::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);                        
     ll T= 1;
     // cin>>T;

     while(T--){
          ll n;cin>>n;
          for(ll i = 0;i<n;i++){
               cin>>h[i];
          }
          for(ll i = 0;i<n;i++){
               cin>>b[i];
          }
          build(1,0,N);
          for(ll i = 0;i<n;i++){
               ll max_b = sum(1,0,N,0,h[i])+b[i];
               update(1,0,N,h[i],max_b);
          }
          cout<<sum(1,0,N,0,N)<<'\n';

     }
    return 0;
}

Measured memory_bytes: 10496
line = readlines
len = line.length
i = 0

while i < len
    line[i] = line[i].chomp.split(' ')
    i += 1
end

x = line[0][0]
if (x.to_i+1)%27 == 0 || (x.to_i+14)%27==0 then
  puts ":("
elsif (((x.to_f/1.08).to_i+1)*1.08).to_i == x.to_i then
  puts (x.to_f/1.08).to_i+1
else
  puts (x.to_f/1.08).to_i
end

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

int min(int x, int y)
{
	return x>y ? y : x;
}

int main()
{
	std::string str;
	getline(std::cin, str);
	
	int length = str.size();
	int height[20001];
	height[0] = 0;
	for (int i=1; i<=length; i++) {
		if (str[i-1] == '\\') height[i] = height[i-1] - 1;
		else if (str[i-1] == '/') height[i] = height[i-1] + 1;
		else height[i] = height[i-1];
	}
	
	// for (int i=0; i<=length; i++) std::cout << height[i] << " ";
	// std::cout << std::endl;
	
	int left_max[20001];
	int right_max[20001];
	int height_of_hull[20001];
	
	left_max[0] = height[0];
	for (int i=1; i<=length; i++) {
		if (height[i] > left_max[i-1]) left_max[i] = height[i];
		else left_max[i] = left_max[i-1];
	}
	
	right_max[length] = height[length];
	for (int i=length-1; i>=0; i--) {
		if (height[i] > right_max[i+1]) right_max[i] = height[i];
		else right_max[i] = right_max[i+1];
	}
	
	for (int i=0; i<=length; i++) {
		height_of_hull[i] = min(left_max[i], right_max[i]);
	}
	
	std::vector<int> areas;
	int area = 0;
	bool flood = false;
	for (int i=1; i<=length; i++) {
		if (flood) {
			if (height[i-1] - 1 == height[i]) area += 2 * (height_of_hull[i] - height[i]) - 1;
			else if (height[i-1] == height[i]) area += 2 * (height_of_hull[i] - height[i]);
			else {
				if (height_of_hull[i] > height[i]) area += 2 * (height_of_hull[i] - height[i]) + 1;
				else {
					areas.push_back((area+1)/2);
					area = 0;
					flood = false;
				}
			}
		}
		else { // !flood
			if (height_of_hull[i] > height[i]) {
				flood = true;
				area = 1;
			}
		}
	}
	
	int sum_of_areas = 0;
	for (std::vector<int>::iterator it = areas.begin(); it != areas.end(); ++it) sum_of_areas += *it;
	std::cout << sum_of_areas << std::endl;
	
	std::cout << areas.size();
	for (std::vector<int>::iterator it = areas.begin(); it != areas.end(); ++it) {
		std::cout << " " << *it;
	}
	std::cout << std::endl;
	
	return 0;
}




Measured memory_bytes: 3532
#include<bits/stdc++.h>
#define SZ(a) ((int) a.size())
using namespace std;
typedef long long ll;
const int N=55,M=22;
const ll inf=1e18;

int n,v[N][M][2],c[N];
ll f[N][M][2],ans=inf;
string s[N];

ll dp(int x,int y,int d) {//x为串编号,y为位置,d为方向(正反)
    if(y==SZ(s[x])) return 0;
    int &u=v[x][y][d]; 
    ll &v=f[x][y][d];
    if(u) return v;
    u=1; v=inf;
	bool flag=1;
	if(!d) {for(int j=y,k=SZ(s[x])-1;j<k;j++,k--) if(s[x][j]!=s[x][k]) {flag=0; break;}}
	else {for(int j=y,k=0;j>k;j--,k++) if(s[x][j]!=s[x][k]) {flag=0; break;}}
	if(flag) return v=0;
    for(int i=1,j,k;i<=n;i++) {//枚举另一个方向接哪个串
        flag=1;
        if(!d) {
            for(j=y,k=SZ(s[i])-1;j<SZ(s[x])&&k>=0;j++,k--)
                if(s[x][j]!=s[i][k]) {flag=0; break;}
            if(flag) {
                if(k<0) v=min(v,c[i]+dp(x,j,0));
                else v=min(v,c[i]+dp(i,k,1));
            }
        }
        else {
            for(j=y,k=0;j>=0&&k<SZ(s[i]);j--,k++)
                if(s[x][j]!=s[i][k]) {flag=0; break;}
            if(flag) {
                if(j<0) v=min(v,c[i]+dp(i,k,0));
                else v=min(v,c[i]+dp(x,j,1));
            }
        }
    }
    return v;
}

int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) cin>>s[i]>>c[i];
    for(int i=1;i<=n;i++) 
		ans=min(ans,c[i]+dp(i,0,0));
    printf("%lld\n",ans==inf?-1:ans);return 0;
}


Measured memory_bytes: 3872
h,w = [],[]
while True:
	a,b = map(int,input().split())
	if a == 0 and b == 0:
		break
	else:
		h.append(a)
		w.append(b)
for i in range(len(h)):
	for k in range(h[i]):
		print("#"*w[i])
	print("")


Measured memory_bytes: 5628
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

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

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

// End of template.

int dp[200200];

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    string t;
    cin >> t;


    for (int i = 0; i < t.size(); ++i) if (t[i] == '?') {
        t[i] = 'D';
    }

    print(t);

    return 0;
}



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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	string s; cin >> s;
	int ret = 0;
	rep(i, n - 1) {
		string d1 = s.substr(0, i + 1);
		string d2 = s.substr(i + 1);
		set<char> s1, s2;
		for (auto u : d1) s1.insert(u);
		for (auto u : d2) s2.insert(u);
		int ans = 0;
		for (auto u : s1) {
			if (s2.count(u)) ans++;
		}
		ret = max(ans, ret);
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  rep(i,n){
    cin>>a.at(i);
  }
  rep(j,n){
    b.at(a.at(j)-1)=j+1;
  }
  rep(k,n){
    cout<<b.at(k)<<endl;
  }
}



Measured memory_bytes: 1536
import sys
from heapq import heapify, heappop, heappush
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()

seta = set(a)
num = N - len(seta)

if num%2 == 0:
  print(N - num)
else:
  print(N - (num + 1))

Measured memory_bytes: 56172
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>

#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

const int inf = 1 << 30;

struct Edge {
  int next;
  int cost;
  int id;
  Edge(int n, int c, int id) : next(n), cost(c), id(id){}
};

bool operator> (Edge e1, Edge e2) {
  return e1.cost > e2.cost;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<Edge> > G(N);
  REP(i, 0, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].push_back(Edge(b, c, i));
    G[b].push_back(Edge(a, c, i));
  }

  vector<int> ans(M + 1, 0);
  
  REP (start, 0, N) {
    set<int> s;
    priority_queue<Edge, vector<Edge>, greater<Edge> > pq;
    vector<int> isAccess(N, 0);
    vector<int> cost(N, inf);
    cost[start] = 0;

    pq.emplace(start, 0, M);

    while (pq.size()) {
      Edge e = pq.top();
      pq.pop();
      if (isAccess[e.next]) continue;
      isAccess[e.next] = 1;
      s.insert(e.id);

      REP (i, 0, G[e.next].size()) {
	Edge ne = G[e.next][i];
	if (cost[ne.next] > cost[e.next] + ne.cost) {
	  cost[ne.next] = cost[e.next] + ne.cost;
	  pq.emplace(ne.next, cost[ne.next], ne.id);
	}
      }      
    }

    for (auto it = s.begin(); it != s.end(); it++) {
      ans[*it]++;
    }
  }

  int a = 0;
  REP (i, 0, ans.size()) {
    if (ans[i] == 0) a++;  
  }

  cout << a << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int x=0;
	int s = m;
	while(s>0)
	{
		s=s/10;
		x++;
	}
	int flag = 0;
	int sum = n*pow(10,x)+m;
	for(int i=1;i*i<=sum;i++)
	{
		if(i*i==sum){
			flag = 1;
		}
	}
	if(flag==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>


using namespace std;



int main() {

	int A, B, count = 0;

	cin >> A >> B;
	
	for (int i = A; i <= B; i++) {
		string S = to_string(i);
		if (S[0] == S[4] && S[1] == S[3]) {
			count++;
		}
	}

	cout << count;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
using namespace std;
 
const ll N =(2e5+5);
const ll MOD = 1e9+7;
const ll INF = 1e16;
const ll LOG = 29;

long long binpow(long long a, long long b) {
     a %= MOD;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%MOD ;
        a = (a * a)%MOD ;

        
        b >>= 1;
    }
    res%=MOD;
    return res;
}
vll adj[N];
vll adj2[N];
ll col[N];
ll col2[N];
bool vis[N];
bool vis2[N];
map<pll,ll> gg;
    void dfs(ll x,ll c)
        {
            vis[x]=true;    
            col[x]=c; 
            for(auto i : adj[x])
            {
                if(vis[i]==false)
                {
                    dfs(i,c);
                }
            }
        }    

    void dfs2(ll x,ll c)
        {
            vis2[x]=true;    
            col2[x]=c; 
            for(auto i : adj2[x])
            {
                if(vis2[i]==false)
                {
                    dfs2(i,c);
                }
            }
        }    

void solve(){
    ll n,k,l;
    cin>>n>>k>>l;
    for(int i =1;i<=k;i++){
        ll u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int i = 1;i<=l;i++){
        ll u,v;
        cin>>u>>v;
        adj2[u].pb(v);
        adj2[v].pb(u);
    }
    ll cur = 1;
    for(int i =1;i<=n;i++){
        if(!vis[i]){
            dfs(i,cur);
            cur++;
        }
    }
    cur =1;
    for(int i =1;i<=n;i++){
        if(!vis2[i]){
            dfs2(i,cur);
            cur++;
        }
    }

    for(int i =1;i<=n;i++){
        gg[mp(col[i],col2[i])]++;
    }
    for(int i =1;i<=n;i++){
        cout<<gg[mp(col[i],col2[i])]<<" ";
    }
    cout<<endl;

}






int main()
{
    ios_base::sync_with_stdio(0);
     cin.tie(NULL);
     
    ll t=1;
    while(t--){
        solve();
    }
     
 
 
    return 0;     
    
        
}

Measured memory_bytes: 30848
use std::collections::BinaryHeap;

fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let (_, m) = {
        let mut ws = s.split_whitespace();
        let _n: i64 = ws.next().unwrap().parse().unwrap();
        let m: i64 = ws.next().unwrap().parse().unwrap();
        (_n, m)
    };

    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let a: Vec<i64> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();

    // ソートする
    // 最大値を取り、Vecから削除
    // それを /2 して、挿入ソート
    // くりかえし

    let mut heap = BinaryHeap::from(a);
    // println!("{:?}", a);

    for _ in 0..m {
        let max = heap.pop().unwrap();
        let max = max / 2;
        heap.push(max);
        // println!("{:?}", a);
    }

    println!("{}", heap.iter().sum::<i64>());
}


Measured memory_bytes: 8444
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;
 
void solve(){
	int n;
	cin>>n;
	vector<ll>a(n),b(n),sub(n);
	ll sum=0,sub_sum=0;
	int cnt=0;
	rep(i,n){
		cin>>a[i];
	}
	rep(i,n){
		cin>>b[i];
	}
	rep(i,n){
		sum+=a[i]-b[i];
		sub[i]=a[i]-b[i];
		if(sub[i]<0){
			++cnt;
			sub_sum+=sub[i];
		}
	}
	if(sum<0){
		cout<<-1<<"\n";
		return ;
	}
	sort(begin(sub),end(sub));
	for(int i=n-1;i>=0;--i){
		if(sub_sum>=0)break;
		sub_sum+=sub[i];
		++cnt;
	}
	cout<<cnt<<"\n";
}
 
signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 2560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        APayment solver = new APayment();
        solver.solve(1, in, out);
        out.close();
    }

    static class APayment {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            out.println(n % 1000 == 0 ? 0 : 1000 - n % 1000);
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.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 byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public int nextInt() {
            if (!hasNext()) throw new NoSuchElementException();
            int n = 0;
            boolean minus = false;
            byte 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();
            }
        }

    }
}



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

using namespace std;
using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int N, D;
  cin >> N >> D;
  auto X = make_v< int >(N, D);
  cin >> X;

  int ret = 0;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < i; j++) {
      int64 q = 0;
      for(int k = 0; k < D; k++) {
        q += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      int64 sq = sqrt(q);
      for(int64 p = sq - 3; p <= sq + 3; p++) {
        if(p * p == q) {
          ++ret;
          break;
        }
      }
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ff;
int n,m,col[500100],blo,tot,le,ri,ans[500100],cnt[500100];
pair<pair<int,int>,int> que[500100];
bool pp(pair<pair<int,int>,int> x,pair<pair<int,int>,int> y){
	return x.first.second<y.first.second;
}
inline void inser(int val){cnt[val]++;if(cnt[val]==1) ff++;}
inline void eras(int val){cnt[val]--;if(cnt[val]==0) ff--;}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&col[i]);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&que[i].first.first,&que[i].first.second);
		que[i].second=i;
	}
	sort(que+1,que+m+1);
	blo=max(1,(int)(sqrt(m)));
	tot=(m+blo-1)/blo;
	for(int i=1;i<=tot;i++){
		le=blo*(i-1)+1;
		ri=min(blo*i,m);
		sort(que+le,que+ri+1,pp); 
		for(int j=1;j<=n;j++) cnt[j]=0;
		ff=0;
		for(int j=que[le].first.first;j<=que[le].first.second;j++)
			inser(col[j]);
		ans[que[le].second]=ff;
		for(int j=le+1;j<=ri;j++){
			for(int kk=que[j-1].first.first;kk<que[j].first.first;kk++)
				eras(col[kk]);
			for(int kk=que[j].first.first;kk<que[j-1].first.first;kk++)
				inser(col[kk]);
			for(int kk=que[j-1].first.second+1;kk<=que[j].first.second;kk++)
				inser(col[kk]);
			ans[que[j].second]=ff;
		}
	}
	for(int i=1;i<=m;i++) printf("%d\n",ans[i]);
	return 0;
}


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

int main()
{
	int minn;
	int maxx=-2000000000;
	int n;
	cin>>n;
	int num=0;
	cin>>num;
	minn=num;
	for(int i=1;i<n;i++)
	{
		cin>>num;
		if(num-minn>=maxx)
			//maxx=max(num-minn,maxx);
			maxx=num-minn;
		if(num<=minn)
			minn=num;
			//minn=min(num,minn);
		
	}
	cout<<maxx<<endl;
	
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a+b)*c/2 << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <cmath>
#include <cassert>
typedef long long ll;
using namespace std;
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
const ll inf = 1e18+9;
int main() {
    ll n, a; cin >> n >> a;
    ll ans = inf;
    for (int k = 1; ; ++ k) {
        ll l = 0, r = n;
        while (l + 1 < r) {
            ll m = (l + r) / 2;
            (pow(m, k) < n ? l : r) = m;
        }
        assert (pow(l, k)  < n);
        assert (pow(r, k) >= n);
        int m = 0; while (pow(l,k-m) * pow(r,m) < n) ++ m;
        setmin(ans, l*k+m + a*(k-1));
        if (l <= 1) break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
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 pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF =1e18;

int main() {
    V vec(26);
    string s;cin>>s;
    rep(i,s.size())vec[s[i]-'a']++;
    ll res=s.size()*(s.size()-1)/2;
    rep(i,26){
        if(vec[i]>=2){
            res-=vec[i]*(vec[i]-1)/2;
        }
    }
    cout<<res+1<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{

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

        int debt = 100000;
        final int n = scanner.nextInt();

        debt = calculateDebt(debt, n);

        System.out.println(debt);
    }

    static int calculateDebt (int debt) {
        final double INTEREST = 0.05;
        final int ROUNUD_UP_MONEY = 1000;

        debt *= 1 + INTEREST;
        final int fraction = debt % ROUNUD_UP_MONEY;
        if (fraction > 0) {
            debt = debt - fraction + ROUNUD_UP_MONEY ;
        }

        return debt;
    }

    static int calculateDebt (int debt, int time) {
        for (int i = 0; i < time; i++) {
            debt = calculateDebt(debt);
        }

        return debt;
    }

}

Measured memory_bytes: 25844
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
using namespace std;
int n,a[101],b[101];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
	for(int i=1;i<=n-2;i++){
		if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
}

Measured memory_bytes: 3760