akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MAX_N (100000+10)
#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

Int N;
const double inf = 1e18;
double X[MAX_N],Y[MAX_N],Dx[MAX_N],Dy[MAX_N];

double func(double a) {
    double minx = inf,maxx = -inf, miny = inf,maxy = -inf;

    for(int i = 0;i < N;i++) {
        double nx = X[i] + a * Dx[i];
        double ny = Y[i] + a * Dy[i];

        minx = min(minx,nx);
        maxx = max(maxx,nx);
        miny = min(miny,ny);
        maxy = max(maxy,ny);
    }
    
    return (maxx - minx) * (maxy - miny);
}

double solve(double l, double r) {
    double ans = inf;
    int num = 300;
    while(num--) {
        double left = l + (r - l) / 3;
        double right = r - (r - l) / 3;

        double f1 = func(left);
        double f2 = func(right);

        ans = min(ans,min(f1,f2));

        if(f1 < f2)
            r = right;
        else
            l = left;
    }

    return ans;
}

int main(void) {
    cin>>N;
    char s;

    for(int i = 0;i < N;i++) {
        cin>>X[i]>>Y[i]>>s;
        if(s == 'R')
            Dx[i] = 1;
        else if(s == 'L')
            Dx[i] = -1;
        else if(s == 'U')
            Dy[i] = 1;
        else
            Dy[i] = -1;
    }

    printf("%f\n",solve(0, 1e9));

    return 0;
}


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

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

        int x = n;


        int num = 0;
        while(x > 0){
            num += x % 10;
            x /= 10;
        }
        
        if(n % num == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

        sc.close();
    }
}

Measured memory_bytes: 23892
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main() {
	int s;
	cin >> s;
	int a = s % 100;
	int b = s / 100;
	bool c = (a <= 12 && a > 0);
	bool d = (b <= 12 && b > 0);
	if ((!c) && (!d)) {
		cout << "NA";
	}
	else if (c&&d) {
		cout << "AMBIGUOUS";
	}
	else if (c) {
		cout << "YYMM";
	}
	else {
		cout << "MMYY";
	}
	cout << endl;
}
/*

int main() {
	int n,k;
	cin >> n >> k;
	string s;
	cin>> s;
	s.at(k-1) = tolower(s.at(k-1));
	cout << s;

}
*/

Measured memory_bytes: 256
import copy

N = int(input())

A = [int(input()) for _ in range(N)]
B = sorted(A)
max_1 = B[-1]
max_2 = B[-2]

for i in range(N):
    if(A[i]==max_1):
        print(max_2)
    else:
        print(max_1)

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

#define MOD 1000000007LL 
#define MODMOD MOD*MOD
const int matrix_size = 4;
struct matrix{
	int mat[matrix_size][matrix_size];  //caution!
	matrix(){
		memset(mat, 0, sizeof(mat));
	}
};
matrix operator *(const matrix &a, const matrix &b){
	matrix r;
	long long int tmp;
	for (int i = 0; i < matrix_size; i++){
		for (int j = 0; j < matrix_size; j++){
			tmp = 0;
			for (int k = 0; k < matrix_size; k++){
				tmp += (long long int)(a.mat[i][k]) * b.mat[k][j];
				if (tmp >= MODMOD)tmp -= MODMOD;
			}
			if (tmp >= MOD)tmp %= MOD;
			r.mat[i][j] = tmp;
		}
	}
	return r;
}
matrix operator +(const matrix &a, const matrix &b){
	matrix r;
	for (int i = 0; i < matrix_size; i++){
		for (int j = 0; j < matrix_size; j++){
			r.mat[i][j] += a.mat[i][j] + b.mat[i][j];
			if (r.mat[i][j] >= MOD){
				r.mat[i][j] -= MOD;
			}
		}
	}
	return r;
}
matrix ppow(matrix i, long long int j){
	if (j == 0){
		for (int i1 = 0; i1<matrix_size; i1++){
			for (int j = 0; j<matrix_size; j++){
				i.mat[i1][j] = (i1 == j);
			}
		}
		return i;
	}
	if (j == 1LL){
		return i;
	}
	j--;
	matrix r = i;
	while (j){
		if ((j & 1LL)){
			r = r*i;
		}
		i = i*i;
		j >>= 1LL;
	}
	return r;
}
int n;
int m;

vector<int> x;
matrix base;
matrix base2;
int main(){
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		int a;
		scanf("%d", &a);
		x.push_back(a);
	}
	//zero
	//one
	//two
	//all
	base.mat[3][0] = 1;
	base.mat[1][3] = 1;
	base.mat[2][3] = 1;
	base.mat[0][1] = base.mat[0][2] = base.mat[0][3] = 1;
	base.mat[0][0] = base.mat[1][1] = base.mat[2][2] = base.mat[3][3] = 1;
	base2 = base;
	base2.mat[3][0] = base2.mat[3][1] = base2.mat[3][2] = 0;
	base.mat[0][0]++;
	base.mat[1][0] = base.mat[2][0] = 1;
	matrix base3;
	base3.mat[0][0] = base3.mat[1][1] = base3.mat[2][2] = base3.mat[3][3] = 1;
	int cur = n;
	for (int i = (int)(x.size()) - 1; i >= 0; i--){
		base3 = base3*ppow(base, cur-x[i]-1);
		base3 = base3*base2;
		cur = x[i];
	}
	base3 = base3*ppow(base, cur);
	long long int ans = base3.mat[0][3];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 892
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a), end(a)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
template<typename K, typename V> using umap = unordered_map<K, V>;
template<typename K, typename V> using uset = unordered_set<K, V>;

//func
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void bOUT(bool c, string s, string t) { OUT(c ? s : t); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

template<typename V, typename H> void resize(vector<V>& v, const H h) { v.resize(h); }
template<typename V, typename H, typename ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
template<typename V, typename T> void fill(V& x, const T& val) { x = val; }
template<typename V, typename T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

int main(void) {
	ll A, B, K;
	cin >> A >> B >> K;
	set<ll> s;
	K = min(K, B - A + 1);
	REP(i, K) {
		s.insert(A + i);
		s.insert(B - i);
	}
	for (auto _s : s) {
		OUT(_s);
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created on 16/09/24.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i=0; i<N; i++) {
            a[i] = sc.nextInt();
        }

        int result = solve(N, a);

        System.out.println(result);
    }


    private static int solve(int N, int[] a) {
        int num = 0;

        for (int i=0; i<N; i++) {
            if(a[i] > (i+1) && a[a[i]-1] == i+1) {
                num++;
            }
        }

        return num;
    }
}


Measured memory_bytes: 32132
#include<stdio.h>

int main(){
    int a, b;
    
    scanf("%d %d", &a, &b);
    
    if(a == b){
        printf("a == b\n");
    }
    else if(a > b){
        printf("a > b\n");
    }
    else{
        printf("a < b\n");
    }
    
    return 0;
    
}


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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    long n;
    cin >> n;
    vector<string> vec(n);
    rep(i, n) cin >> vec[i];
    sort(vec.begin(), vec.end());
    long ans = 1;
    for (int i = 1; i < n; i++) {
        if (vec[i] != vec[i-1]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9584
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<algorithm>
#include<list>
#include<cstring>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define pop pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 10000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout); 
using namespace std;
int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
int main()
{
    jaldi
    #ifndef _DEBUG 
    //TakeInput
    #endif
    ll n,i,j,k;
    cin>>n>>k;
    ll a[n];
    in(i,n){
        cin>>a[i];
    }   
    ll dp[n];
    ininf(dp);
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    fon(i,2,n){
        fon(j,1,k+1){
            if(i-j>=0){
                dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
            }
        }
        //cout<<dp[i]<<" ";
    }
    cout<<dp[n-1];
    

    
}
 
 








 

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define N 202100
const ll mod = 1e9 + 7;

int n, m;
int a[N];
ll sum[N];

ll solve(int x, int in1, int in2) {
	if(in1 < 0 || in2 < 0) return 1e18;
	ll l1 = sum[in1], r1 = sum[x] - sum[in1];
	ll l2 = sum[in2] - sum[x], r2 = sum[n] - sum[in2];
	ll ans = 0;
	ans = max(ans, abs(l1 - r1));
	ans = max(ans, abs(l2 - r2));
	ans = max(ans, abs(l1 - l2));
	ans = max(ans, abs(r1 - r2));
	ans = max(ans, abs(r1 - l2));
	ans = max(ans, abs(r2 - l1));
	return ans;
}

ll solve(int x) {
	ll l1, r1, l2, r2;
	int ind = lower_bound(sum, sum + x, sum[x] / 2) - sum;
	int ind2 = lower_bound(sum, sum + n, (sum[n] - sum[x])/ 2 + sum[x]) - sum;
	ll ans = 1e18;
	ans = min(ans, solve(x, ind, ind2));
	ans = min(ans, solve(x, ind - 1, ind2));
	ans = min(ans, solve(x, ind, ind2 - 1));
	ans = min(ans, solve(x, ind - 1, ind2 - 1));
	return ans;
}

int main() {
	ios::sync_with_stdio(0);
	while(cin >> n){
		sum[0] = 0;
		for(int i = 1; i <= n; i++) cin >> a[i], sum[i] = sum[i - 1] + a[i];
		ll ans = 1e18;
		for(int i = 2; i < n; i++) {
			ans = min(ans, solve(i));
		}
		cout << ans << endl;
	}
	return 0;
}


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

int main() {
  int N, A, B, sum = 0;
  cin >> N >> A >> B;

  for (int i = 1; i <= N; i++) {
    int c = 0;
    int j = i;
    while (j > 0) {
      c += j % 10;
      j /= 10;
    }
    if (A <= c && c <= B) {
      sum += i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
	int N;
	scanf("%d", &N) + 1;

	int tmp;
	int nextNumber = 1;
	int kudakuCount = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &tmp) + 1;
		if (tmp == nextNumber) {
			nextNumber++;
		} else {
			kudakuCount++;
		}
	}

	if (nextNumber == 1) printf("-1\n");
	else printf("%d\n", kudakuCount);

	return 0;
}

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


int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  int sum = 0;

  if(A>=K){
    sum = K;
  }else if(A<=K){
    if((K-A)<=B){
      sum = A;
    }else{
      sum = A+(-1)*(K-A-B);
    }
  }

  cout << sum;
  return 0;
}

Measured memory_bytes: 3624
// ConsoleApplication3.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    int count = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	cout<<(1000 - n%1000) % 1000<<endl;
	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793


   
int main(){
   int n,k;
   cin >> n >> k;
   ll ans=1;
   rep(i,n){
     if(ans<=k)ans*=2;
     else if(ans>k)ans+=k;
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _dbg(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _dbg(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_dbg(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
const int N=11;
int g[N][N];
int val[N];
int32_t main() {
    val[0]=1;
    int n;
    cin>>n;
    for(int i=1;i<n;++i){
        for(int pot=val[i-1]+1;;++pot){
            set<int> s;
            int cnt=1;
            s.insert(pot);
            forn(x,i){forn(y,x){cnt++;s.insert(val[x]+val[y]);}cnt++;s.insert(val[x]+pot);s.insert(val[x]);cnt++;}
            if(s.size()==cnt){
                val[i]=pot;
                break;
            }
        }
    }
    memset(g,-1,sizeof g);
    for(int i=1;i<=n;++i){
        vector<int> v(i-1);
        int mx=0;
        iota(v.begin(), v.end(),1);
        do{
            int c=0;
            for(int j=1;j<v.size();++j)c+=g[v[j-1]][v[j]];
            upx(mx,c);
        }while(next_permutation(v.begin(), v.end()));
        mx++;
        for(int j=1;j<i;++j)g[j][i]=g[i][j]=mx*val[j-1];
        g[i][i]=0;
    }
    for(int i=1;i<=n;++i){for(int j=1;j<=n;++j)cout<<g[i][j]<<' ';cout<<'\n';}

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005

using namespace std;

int solve(){
    ll n;
    cin>>n;
    ll p=sqrt(n);
    ll ans;
	rep(i,1,p+2){
		if((i*(n/i))==n)ans=i+(n/i);
	}
	cout<<ans-2<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		
		long sum = 0;
		for(long i=1; i<=K; i++) {
			if((i+i)%K != 0) {
				continue;
			}
			if(i<K) {
				long c = (N+i)/K;
				sum += c*c*c;
			}else {
				long d = N/K;
				sum += d*d*d;
			}
		}
	
		System.out.println(sum);
		in.close();
	}
}


Measured memory_bytes: 23380
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    long long g,t,d;
    int n;
    cin>>n;
    cin>>g;
    for(int i=0 ; i<n-1 ; i++){
        cin>>t;
        d=__gcd(g,t);
        g=g*(t/d);
    }
    cout<<g;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool solve(long long i,long long j){
	while(i%j == 0){
		i/=j;
	}
	return i%j == 1;
}
int main() {
	long long n;
	cin >> n;
	if(n == 2) {
		cout << 1 << '\n';
		return 0;
	}
	long long res = 0;
	for (long long i = 2; i*1LL*i <= n-1; i++){
		if((n-1)%i==0){
			if(i * i == n-1) res++;
			else res += 2;
			// cout << i << " " << n/i << "\n";
		}
	}
	// cout << "dfdsf\n";
	for (long long i = 2; i*1LL*i <= n; i++){
		if(n%i == 0){
			if(i*i == n  and solve(n,i)) {
				res += 1;
				// cout << i << '\n';
			}
			else{
				if(solve(n,i)) {res++;
					// cout << i << " ";
				}
				if(solve(n,n/i)) {res++;
					// cout << n/i ;
				} 
				// cout << '\n';
			}
			
		}
	}
	res++;
	res++;
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
double EPS=1e-8;
int cnt[3];
int main(){
	string s;
	cin>>s;
	int f=0,ans=0;
	REP(i,s.size()){
		if(f==0){
			if(s[i]=='J'){
				memset(cnt,0,sizeof(cnt));
				cnt[0]++;
				f=1;
			}
		}else if(f==1){
			if(s[i]=='J'){
				cnt[0]++;
			}else if(s[i]=='O'){
				cnt[1]++;
				f=2;
			}else{
				f=0;
			}
		}else if(f==2){
			if(s[i]=='J'){
				memset(cnt,0,sizeof(cnt));
				cnt[0]++;
				f=1;
			}else if(s[i]=='O'){
				cnt[1]++;
			}else{
				f=3;
				cnt[2]++;
			}
		}else{
			if(s[i]=='J'){
				if(cnt[0]>=cnt[1]&&cnt[1]<=cnt[2])ans=max(ans,cnt[1]);
				memset(cnt,0,sizeof(cnt));
				cnt[0]++;
				f=1;
			}else if(s[i]=='O'){
				if(cnt[0]>=cnt[1]&&cnt[1]<=cnt[2])ans=max(ans,cnt[1]);
				f=0;
			}else{
				cnt[2]++;
			}
		}
	}
	if(cnt[0]>=cnt[1]&&cnt[1]<=cnt[2])ans=max(ans,cnt[1]);
	cout<<ans<<endl;
}

Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();

        int H = in.intNext();
        int A = in.intNext();

        int mod = H % A;
        int res = H / A;
        if (mod > 0) res++;
        out.println(res);

        out.close();
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 22100
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    int main(){
       int n;cin>>n;
       vector<double>a(n);
       rep(i,n)cin>>a[i];
       double res = 0;
       rep(i,n){
           res += 1/a[i];
       }
       res = 1/res;
       cout << std::fixed << std::setprecision(8);
       cout<<res;
    }
    


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

public class Main {

	public static boolean isLeapYear (int y) {
		if (y % 400 == 0)
			return true;
		else if (y % 100 == 0)
			return false;
		else
			return y % 4 == 0;
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		ArrayList<String> out = new ArrayList<String>();

		int a = sc.nextInt();
		int b = sc.nextInt();
		while (true) {
			boolean naFlg = true;
			for (int i = a; i <= b; i++) {
				if (isLeapYear(i)) {
					out.add(i + "");
					naFlg = false;
				}
			}
			if (naFlg) out.add("NA");
			a = sc.nextInt();
			b = sc.nextInt();
			if (a == 0 && b == 0) break;
			out.add("");
		}

		for (String s : out)
			System.out.println(s);

	}

}

Measured memory_bytes: 20928
#include <iostream>
#include <algorithm>

using namespace std;

double cross(double,double,double,double);

int main(void){
	double xa,ya,xb,yb,xc,yc,xp,yp;
	while(1){
		cin >> xa;
		if (cin.eof())
			break;
		cin >> ya >> xb >> yb >> xc >> yc >> xp >> yp;
		double abx , aby , bcx , bcy , cax , cay , apx , apy , bpx , bpy , cpx , cpy;
		abx = xb - xa;
		aby = yb - ya;
		bcx = xc - xb;
		bcy = yc - yb;
		cax = xa - xc;
		cay = ya - yc;
		apx = xp - xa;
		apy = yp - ya;
		bpx = xp - xb;
		bpy = yp - yb;
		cpx = xp - xc;
		cpy = yp - yc;
		double fa,fb,fc;
		fa = cross(abx,aby,apx,apy);
		fb = cross(bcx,bcy,bpx,bpy);
		fc = cross(cax,cay,cpx,cpy);
		if ( (fa>0 && fb>0 && fc>0) || (fa<0 && fb<0 && fc<0) )
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}


	return 0;
}

double cross(double ax,double ay,double bx,double by){
	return ax*by-ay*bx;
}

Measured memory_bytes: 1216
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    final int N;

    AtCoder(FastScanner sc) {
        N = sc.nextInt();
    }

    void solve(PrintWriter out) {
        for (int i = 0; i <= N / 4; i++) {
            for (int j = 0; j <= N / 7; j++) {
                if (4 * i + 7 * j == N) {
                    out.println("Yes");
                    return;
                }
            }
        }
        out.println("No");
    }

}

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


Measured memory_bytes: 21460
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();

		if (s[5] == '0' && s[6] <= '4') {
			pr.println("Heisei");
		} else {
			pr.println("TBD");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

long m(long a,long b){
  while(true){
  if(b%a==0){
    return a;
  }
  else{
    long q=b;
    b=a;
    a=q%a;
  }
  }
}


long M(vector<long> a){
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  while(a.size()!=1){
    auto itr1=a.begin();
    auto itr2=itr1+1;
    a.at(0)=m(*itr1,*itr2);
    a.erase(itr2);
  }
  return a.at(0);
}


int main() {
  long N;
  cin>>N;
  vector <long> a(N+1);
  vector <long> b(N);
  for(int i=0;i<N+1;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  for(int i=0;i<N;i++){
    b.at(i)=a.at(i+1)-a.at(i);
  }
  
  cout<<M(b);
}

Measured memory_bytes: 2560
h,w = map(int,input().split())
block = [input() for _ in range(h)]
ok = [[False] * w for _ in range(h)]

for y in range(h):
    for x in range(w):
        if block[y][x] == '.':
            #print(y,x)
            nowy = 0
            nowx = 0
            flag = True
            while nowy < h:
                if block[nowy][x] == '.':
                    nowy += 1
                else:
                    flag = False
                    break
            if flag:
                for y_ in range(h):
                    ok[y_][x] = True
            flag = True
            while nowx < w:
                #print(nowx)
                if block[y][nowx] == '.':
                    nowx += 1
                else:
                    flag = False
                    break
            if flag:
                for x_ in range(w):
                    ok[y][x_] = True
ans = []
for y in range(h):
    a = ""
    for x in range(w):
        if ok[y][x] != True:
            a += block[y][x]
    if len(a) != 0:
        ans.append(a)
print(*ans,sep='\n')


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int N,M,K,Q,L[100010],R[100010];
int A[400][400];
int X[100010],Y[100010],D[100010];

int main(){
	cin>>N>>M>>K;
	REP(i,N)REP(j,M){
		cin>>A[i][j];
		X[A[i][j]]=i,Y[A[i][j]]=j;
	}
	cin>>Q;
	for(int i=K+1;i<=N*M;i++){
		D[i]=D[i-K]+abs(X[i]-X[i-K])+abs(Y[i]-Y[i-K]);
		DEB(D[i])END
	}
	REP(i,Q){
		cin>>L[i]>>R[i];
		cout<<D[R[i]]-D[L[i]]<<endl;
	}
	return 0;
}
//1=7

Measured memory_bytes: 3456
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) int __VA_ARGS__; in(__VA_ARGS__)
//オーバーフロー対策
#define INL(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define next asdnext
#define prev asdprev
#pragma endregion RegionDefs

void solve()
{
    IN(h, w);
    auto s = new int[2000][2000];
    auto t = new int[2000][2000];
    auto u = new int[2000][2000];
    rep(i, h)
    {
        rep(j, w)
        {
            char c; cin >> c;
            s[i][j] = c == '.';
        }
    }
    rep(i, h)
    {
        t[i][0] = s[i][0];
        reps(j, 1, w)
        {
            t[i][j] = (t[i][j-1] + s[i][j]) * s[i][j];
        }
        int a = 0;
        repr(j, w-1)
        {
            if (t[i][j] == 0) a = 0;
            else if (a == 0) a = t[i][j];
            else t[i][j] = a;
        }
    }
    rep(j, w)
    {
        u[0][j] = s[0][j];
        reps(i, 1, h)
        {
            u[i][j] = (u[i-1][j] + s[i][j]) * s[i][j];
        }
        int a = 0;
        repr(i, h-1)
        {
            if (u[i][j] == 0) a = 0;
            else if (a == 0) a = u[i][j];
            else u[i][j] = a;
        }
    }
    int m = 0;
    rep(i, h)
    {
        rep(j, w)
        {
            chmax(m, t[i][j]+u[i][j]-1);
        }
    }
    cout << m << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 47104
/*
 * Author       : YangDavid
 * Created Time : 2019年07月12日 星期五 20时51分56秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 555555;
int mx[maxn << 1], n, k, p[maxn], q[maxn], ans[maxn];
#define lson (o << 1)
#define rson (o << 1 | 1)

void modify(int o, int l, int r, int d, int v) {
    if(l == r) { mx[o] = v; return; }
    int mid = (l + r) >> 1;
    if(d <= mid) modify(lson, l, mid, d, v);
    else modify(rson, mid + 1, r, d, v);
    mx[o] = max(mx[lson], mx[rson]);
}
int query(int o, int l, int r, int ql, int qr) {
    if(ql <= l && r <= qr) return mx[o];
    int mid = (l + r) >> 1, res = 0;
    if(ql <= mid) res = max(res, query(lson, l, mid, ql, qr));
    if(qr > mid) res = max(res, query(rson, mid + 1, r, ql, qr));
    return res;
}
vector<int> G[maxn];
int indeg[maxn];
void add(int from, int to) { 
    indeg[to]++;
    G[from].push_back(to); 
}

void toposort() {
    int cnt = 0;
    priority_queue<int, vector<int>, greater<int> > pq;
    for(int i = 1; i <= n; ++i) if(indeg[i] == 0)
        pq.push(i);
    while(!pq.empty()) {
        int f = pq.top(); pq.pop();
        ans[f] = ++cnt;
        for(auto g : G[f]) if(--indeg[g] == 0)
            pq.push(g);
    }
}
int main() {
    scanf("%d%d", &n, &k);
    rep(i, n) scanf("%d", &p[i]), q[p[i]] = i;
    for(int i = 1; i <= n; ++i) {
        int small = query(1, 1, n, max(1, q[i]-k+1), q[i]);
        if(small) add(q[small], q[i]);
        int big = query(1, 1, n, q[i], min(n, q[i] + k - 1));
        if(big) add(q[big], q[i]);
        modify(1, 1, n, q[i], i);
    }
    toposort();
    rep(i, n) printf("%d\n", ans[i]);

    return 0;
}


Measured memory_bytes: 45440
#include<stdio.h>
int main(void){
  long N;
  long num[5];
  int i;
  long min;
  int soezi;
  long sum = 0;
  long kazu;
  int tosi;
  
  scanf("%ld", &N);
  scanf("%ld %ld %ld %ld %ld", &num[0], &num[1], &num[2], &num[3], &num[4]);
  
  min = num[0];
  soezi = 0;
  for(i = 1; i < 5; i++){
    if(min > num[i]){
      min = num[i];
      soezi = i;
    }
  }
  
  if(min < N){
  	sum += soezi;
  	if(N % min != 0){
    	kazu = (N / min) + 1;
  	}
  	else{
    	kazu = N / min;
  	}
  
  	tosi = 5 - sum;
  	sum += tosi + (kazu - 1);
  }
  else{
    sum = 5;
  }
  
  printf("%ld\n", sum);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  long long n,a;
  scanf("%lld",&n);
  a=n/11;
  a*=2;
  n%=11;
  if(n){
    a++;
    if(n>6)a++;
  }
  printf("%lld\n",a);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

void str_replace(string &s, string target, string replacement) {
    if (!target.empty()) {
        string::size_type pos = 0;
        while ((pos = s.find(target, pos)) != string::npos) {
            s.replace(pos, target.length(), replacement);
            pos += replacement.length();
        }
    }
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    string t = s;
    while (t.find("()") != string::npos) {
        str_replace(t, "()", "");
    }
    string lef = "";
    string rig = "";
    rep(i,t.size()) {
        if (t[i] == ')') lef += '(';
        else rig += ')';
    }
    cout << lef + s + rig << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
strToInt s = (read :: String -> Int) s

main = do

a <- readLn :: IO Int
b <- readLn :: IO Int
c <- readLn :: IO Int
w <- readLn :: IO Int

let ans = [(x,y,z)|x<-[0..a],y<-[0..b],z<-[0..c] , 500*x + 100*y + 50*z ==w]

print $  length ans

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;
const int MAXH = 1e9;
const int MAXW = 1e9;

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

	ll H, W, N;
	cin >> H >> W >> N;

	set<pair<ll, ll> > s, s2;
	rep(i, 0, N) {
		int x, y;
		cin >> x >> y;
		s.insert(make_pair(x, y));
		rep(j, 0, 3) rep(k, 0, 3) s2.insert(make_pair(x - j, y - k));
	}

	ll A[10];
	memset(A, 0, sizeof(A));
	A[0] = (H - 2) * (W - 2);
	for(set<pair<ll, ll> >::iterator it = s2.begin(); it != s2.end(); it++) {
		ll x = it->first, y = it->second;
		if(x <= 0 or x + 2 > H) continue;
		if(y <= 0 or y + 2 > W) continue;
		ll ret = 0;
		rep(j, 0, 3) rep(k, 0, 3) ret += s.count(make_pair(x + j, y + k));
		
		A[ret]++;
		A[0]--;
	}
	rep(i, 0, 10) cout << A[i] << endl;

}


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

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

int main(int argc, char **argv)
{
    int n;
    vector<int> a, b, c;

    cin >> n;
    a.resize(n);
    b.resize(n);
    c.resize(n);

    for (int i = 0; i < n * 3; i++)
    {
        int tmp;
        cin >> tmp;
        if (i < n)
            a[i] = tmp;
        else if (i < n * 2)
            b[i % n] = tmp;
        else
            c[i % n] = tmp;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        vector<int>::iterator ia = lower_bound(a.begin(), a.end(), b[i]);
        vector<int>::iterator ic = upper_bound(c.begin(), c.end(), b[i]);
        // sum += (distance(a.begin(), ia)) * distance(ic, c.end());
        sum += (ia - a.begin()) * (c.end() - ic);
    }
    cout << sum << endl;
   return 0;
}

Measured memory_bytes: 1532
N, Y = map(int, input().split())

ans = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1):
        # tmp_sum = 10000 * i + 5000 * j
        # x = Y - tmp_sum
        # if x >= 0:
        #     k = int(x//1000)
        #     if i + j + k == N:
        #         ans = [i, j, k]
        k = N - i - j
        if k >= 0:
            if 10000 * i + 5000 * j + 1000 * k == Y:
                ans = [i, j, k]


print(" ".join([str(i) for i in ans]))


Measured memory_bytes: 2940
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

int main()
{
	char n[4];
	cin >> n;
	if (n[1] == '7' || n[2] == '7' || n[0] == '7')
		cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

using namespace std;

auto solve (vector<int64_t> const & nums) {
    int64_t const sum = accumulate (nums.begin (), nums.end (), 0);
    int64_t ans = INT64_MAX;
    int64_t parsum = 0;

    for (int i = 0; i < nums.size () - 1; ++i) {
        parsum += nums[i];
        ans = min (ans, abs(sum - 2 * parsum));
    }

    return ans;
}

int main() {
    int n;
    long long X=0,x=0,ans=1000000000000000000LL;
    cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;i++) {
        cin>>a[i];
        X+=a[i];
    }
    for(int i=0;i<n;i++) {
        x+=a[i];
        if(i+1<n)ans=min(ans,abs(X-2*x));
    }
    cout << ans << endl;
}

// int main () {
//     int n;
//     cin >> n;
//     std::vector<int64_t> nums (n);

//     for (auto & num : nums)
//         cin >> num;

//     cout << solve (nums) << endl;

//     return 0;
// }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n; cin >> n;
    VL d(n); cin >> d;

    ll ans = 0;
    FOR(i, 0, n)FOR(j, i + 1, n)ans += d[i] * d[j];
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
int f[5007];
int min(int a,int b){return a<b? a:b;}
int main()
{
    int n,p,ans=0;
    scanf("%d%d",&n,&p),f[0]=1;
    for(int i=1;i<n;++i) for(int k=min(i,n-i+1),j=k;j<n;++j) (f[j]+=f[j-k])%=p;
    for(int i=0;i<n;++i) (ans+=1ll*(n-i)*f[i]%p)%=p;
    printf("%d",ans);
}


Measured memory_bytes: 256
while 1:
    n, x = map(int, input().split())
    if n == x == 0:
        break

    count = 0

    for i in range(1, x // 3):
        for j in range(i + 1, x // 2):
            k = x - i - j
            if j < k <= n:
                count += 1

    print(count)


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

int main(){
  ll n;cin>>n;
  cout<<n+n*n+n*n*n;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; ll t;
	cin>>n>>t;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	vector<int> mn(n);
	for(int i = 0; i < n; i++){
		mn[i] = a[i];
		if(i)mn[i] = min(mn[i - 1], a[i]);
	}
	int dx = 0, cnt = 0;
	for(int i = 1; i < n; i++){
		if(dx == a[i] - mn[i - 1])cnt++;
		else if(dx < a[i] - mn[i - 1])dx = a[i] - mn[i - 1], cnt = 1;
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define pll pair<ll, ll>

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.resize(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, K, L, p, q;
    cin >> N >> K >> L;
    vector<ll> res(N, 1);
    UnionFind Road(N), Rail(N);
    REP(i, K) {
        cin >> p >> q; --p; --q;
        Road.merge(p, q);
    }

    REP(i, L) {
        cin >> p >> q; --p; --q;
        Rail.merge(p, q);
    }

    // 道路でも電車でも連結してる
    // 根が同じ
    map<pll, ll> mp;
    REP(i, N) mp[{Road.root(i), Rail.root(i)}]++;
    REP(i, N) cout << mp[{Road.root(i), Rail.root(i)}] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 19584
import Control.Applicative

data YesNo = YES | NO deriving(Show)
type Coord = (Double, Double)


sub :: Coord -> Coord -> Coord
sub a b = (fst a - fst b, snd a - snd b)

oProduct :: Coord -> Coord -> Double
oProduct x y = fst x * snd y - snd x * fst y

reshape :: [Double] -> [Coord]
reshape [] = []
reshape [_] = []
reshape (x:y:rs) = (x, y) : reshape rs


isInside :: [Coord] -> YesNo
isInside [] = NO
isInside [_] = NO
isInside [_, _] = NO
isInside [_, _, _] = NO
isInside (a:b:c:p:_) =
  let cand1 = oProduct (b `sub` a) (p `sub` a)
      cand2 = oProduct (c `sub` b) (p `sub` b)
      cand3 = oProduct (a `sub` c) (p `sub` c)
  in
    if (cand1 < 0 && cand2 < 0 && cand3 < 0)
      || (cand1 > 0 && cand2 > 0 && cand3 > 0)
      then YES
      else NO


solver :: [[Coord]] -> [YesNo]
solver = map isInside

main :: IO()
main = do
  contents <- map (map (read :: String -> Double) . words) . lines <$> getContents
  mapM_ print $ solver $ map reshape contents

Measured memory_bytes: 4340