akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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


vector<lli> dp;
vector<lli> G[200100];
lli N;
vector<lli> a,u,v;

map<lli,lli> ans;

void dfs(lli from,lli now){

    lli updateMethod;
    lli updateIndex;
    lli prevNum;

    auto itr = lower_bound(dp.begin(),dp.end(),a[now]);

    if(itr==dp.end()){
        dp.push_back(a[now]);
        updateMethod = 1;
    }
    else{
        updateMethod = 2;
        updateIndex = (itr)-dp.begin();
        prevNum = *itr;
        *itr = a[now];
    }
    ans[now]=dp.size();

    for(auto e:G[now]){
        if(e==from)continue;
        dfs(now,e);
    }

    if(updateMethod==1){
        dp.pop_back();
    }
    else{
        dp[updateIndex]=prevNum;
    }
}


void func(){

    REP(i,0,N)dp[i]=INF;
    dfs(-1,0);

    for(auto e:ans)cout<<e.second<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    a.resize(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    u.resize(N-1);
    v.resize(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&u[i]);
        scanf("%lld",&v[i]);
        u[i]--,v[i]--;
        G[u[i]].push_back(v[i]);
        G[v[i]].push_back(u[i]);
    }
    func();
    return 0;
}


Measured memory_bytes: 48600
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()

    fun f(a: Long, b: Long): Int {
        return Math.max(a.toString().length, b.toString().length)
    }

    var ans = Int.MAX_VALUE
    var i = 1L
    while (i * i <= n) {
        if (n % i == 0L) {
            val a = i
            val b = n / a
            ans = Math.min(ans, f(a, b))
        }
        i++
    }
    println(ans)
}


Measured memory_bytes: 33816
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int K=stdIn.nextInt();
		int C=stdIn.nextInt();
		String a=stdIn.next();
		boolean work[]=new boolean[N];
		int L[]=new int[K];
		int R[]=new int[K];
		int x=0;
		for(int i=0;i<N;i++){
			if(a.charAt(i)=='o')
				work[i]=true;
			else
				work[i]=false;
		}
		for(int i=0;i<N;i++){
			if(work[i]){
				L[x]=i;x++;
				i+=C;
			}
			if(x==K)
				break;
		}x--;
		for(int i=N-1;i>=0;i--){
			if(work[i]){
				R[x]=i;x--;
				i-=C;
			}
			if(x==-1)
				break;
		}
		for(int i=0;i<K;i++){
			if(L[i]==R[i])
				System.out.println(L[i]+1);
		}
	}
}


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

int main(){
	int n,x;
	cin>>n>>x;
	
	int a[100],min=1000;
	for(int i=0;i<n;i++){
		cin>>a[i];
		x-=a[i];
		if(min>a[i]) min=a[i];
	}
	
	
	cout<<n+x/min<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int n =s.nextInt();

        String str=Integer.toString(n);
        if((str.charAt(0)=='7')||(str.charAt(1)=='7')||(str.charAt(2)=='7'))
            System.out.println("Yes");
        else
            System.out.println("No");
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

}


Measured memory_bytes: 32768
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }

void solve(long long A, long long B, long long C, long long K){
    ll ans = 0;
    if(K > 0){
        ll tmp = min(K, A);
        K -= tmp;
        ans += tmp;
    }
    if(K > 0){
        ll tmp = min(K, B);
        K -= tmp;
    }
    if(K > 0){
        ll tmp = min(K, C);
        K -= tmp;
        ans -= tmp;
    }
    cout<<ans<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n; cin >> n;
  vector<int> a(n); REP (i, n) cin >> a[i];
  vector<int> accl(n, a[0]), accr(n, a[n - 1]);
  REP (i, n - 1) accl[i + 1] = __gcd(accl[i], a[i + 1]);
  for (int i = n - 2; i >= 0; i--) accr[i] = __gcd(accr[i + 1], a[i]);
  int ans = max(accl[n - 2], accr[1]);
  REPI (i, 1, n - 1) {
    chmax(ans, __gcd(accl[i - 1], accr[i + 1]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    ll n;
    cin>>n;
    vll a(n+1),b(n);
    rep(i,n+1)cin>>a[i];
    rep(i,n)cin>>b[i];
    ll ans=0;
    for(int i=0;i<n;i++){
        ll t=min(a[i],b[i]);
        ans+=t;
        a[i]-=t;
        b[i]-=t;
        t=min(a[i+1],b[i]);
        ans+=t;
        a[i+1]-=t;
    }
    fin(ans);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 1792
#include <cstdio>

int N, Ans;

int main() {
	scanf("%d", &N);
	int lst = 0, sgn = 0;
	for (int i = 1; i <= N; ++i) {
		int x;
		scanf("%d", &x);
		if (!lst) ++Ans;
		else if (!sgn) sgn = x > lst ? 1 : x < lst ? -1 : 0;
		else if (sgn == 1) {
			if (x < lst) ++Ans, sgn = 0;
		} else {
			if (x > lst) ++Ans, sgn = 0;
		}
		lst = x;
	}
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 1708
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pii pair<long long,long long>
#define ppii pair<long long,pair<long long,long long>>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<vector<long long>> vii;
typedef unsigned long long lint;
typedef unsigned long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
//int dx[4] = { 1,0,-1,0 };
//int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;
const int MAX_N = 1 << 17;
const int cf = 100010;
///////////////////////////////////////////////////////////////////////////////

int main(void) {
	lint n; cin >> n;
	vector<int> a(n);
	rep(n) cin >> a[i];
	if (n == 2) {
		sort(all(a));
		printf("%d %d", a[1], a[0]);
		return 0;
	}
	sort(all(a));
	//reverse(all(a));
	double k = (double)a[n-1] / 2;
	int j = n-2;
	for (int i = 0; i < n-1; i++)
	{
		if ((double)a[i] > k) {
			j = i;
			break;
		}
	}
	if ((double)a[j] - k < k - (double)a[j - 1]) {
		printf("%d %d", a[n - 1], a[j]);
	}
	else {
		printf("%d %d", a[n - 1], a[j-1]);
	}
	return 0;

}

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

int main() {
    int N;
    cin >> N;

    int negative = 0, min_num = 1000000000;
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;

        if (a < 0) {
            negative++;
            a *= -1;
        }
        min_num = min(min_num, a);
        sum += a;
    }

    if (negative % 2 == 0) {
        cout << sum << endl;
    } else {
        cout << sum - 2 * min_num << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

H,W = MI()
S = [['.']*(W+2)]
for i in range(H):
    S.append(['.'] + LS2() + ['.'])
S.append(['.']*(W+2))

ANS = [[] for i in range(H+1)]
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j] == '#':
            ANS[i].append('#')
        else:
            ANS[i].append(str([S[i-1][j-1],S[i-1][j],S[i-1][j+1],S[i][j-1],S[i][j+1],S[i+1][j-1],S[i+1][j],S[i+1][j+1]].count('#')))

for i in range(1,H+1):
    print(''.join(ANS[i]))


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

constexpr size_t n = 1000;

template<size_t maxN>
class PascalTri{
public:
    uint_fast64_t val[maxN][maxN];

    constexpr PascalTri() : val(){
        for(size_t i = 0; i < maxN; ++i)
            for(size_t j = 0; j < maxN; ++j)
                val[i][j] = 0;
        val[0][0] = 1;
        for(size_t i = 1; i < maxN; ++i)
            for(size_t j = 0; j < maxN; ++j)
                val[i][j] = val[i - 1][j] + (j ? val[i - 1][j - 1] : 0);
    }
};

constexpr PascalTri<n> C = PascalTri<n>();

constexpr long long binom(int a, int b){
    if(a < 0 || b < 0 || a < b)return 0;
    return C.val[a][b];
}

long long int N, A, B, a, b;
vector<long long> v;

int main(){
    scanf("%lld%lld%lld", &N, &A, &B);
    for(int i = 0; i < N; ++i){
        scanf("%lld", &a);
        v.push_back(a);
    }
    sort(v.rbegin(), v.rend());
    a = 0;
    for(int i = 0; i < A; ++i)a += v[i];
    printf("%.20Lf\n", static_cast<long double>(a) / A);
    if(v[0] != v[A - 1]){
        a = v.rend() - A - lower_bound(v.rbegin(), v.rend(), v[A - 1]);
        b = upper_bound(v.rbegin(), v.rend(), v[A - 1]) - lower_bound(v.rbegin(), v.rend(), v[A - 1]);
        cout << binom(b, a) << endl;
    }else{
        a = v.rend() - lower_bound(v.rbegin(), v.rend(), v[A - 1]);
        b = 0;
        for(; A <= B; ++A)b += binom(a, A);
        cout << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// ABC132-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

ll mod=pow(10,9)+7;
ll num=3*pow(10,3);
vector<ll> fact(num);
vector<ll> invfact(num);

ll modpow(ll x,ll y,ll mod){ //x^y
    if(y==0) return 1;
    if(y==1) return x%mod;
    if(y%2==1) return x*modpow(x,y-1,mod)%mod;
    ll t=modpow(x,y/2,mod);
    return (t*t)%mod;
}
ll nck(ll n,ll k,ll mod){
    return fact[n]*invfact[k]%mod*invfact[n-k]%mod;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    ll n,k;
    cin>>n>>k;
    //if(k==1) cout<<n-k+1<<endl;
//else{
    fact[0]=1;
    for(int i=1;i<num;i++){
        fact[i]=fact[i-1]*i%mod;
    }
    invfact[num-1]=modpow(fact[num-1],mod-2,mod);
    for(int i=num-2;i>-1;i=i-1){
        invfact[i]=invfact[i+1]*(i+1)%mod;
    }
    for(int i=1;i<=k;i++){
        ll ans=0;
        if(i<=n-k+1) ans=nck(n-k+1,i,mod)*nck(k-1,i-1,mod)%mod;
        cout<<ans<<endl;
    }
//}
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
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); }

int app() {
  int n,k;
  cin>>n>>k;

  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }

  auto f = [&](lint l)->bool{
    lint c=0;
    rep(i,n){
      c+=(a[i]-1)/l+1;
    }
    return c<=n+k;
  };

  int low=0,mid,high=1e9+1;
  while(high>low+1){
    mid=(low+high)/2;
    if(f(mid)) high=mid;
    else low=mid;
  }

  return high;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 4052
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    ll n, m; cin >> n >> m;

    ll sum = 0;
    if(m-2*n>=0){
        sum += n;
        sum += (m-2*n)/4LL;
    }
    else{
        sum += m/2;
    }

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


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

using namespace std;

typedef long long ui;

int cn[500005];
int a[500005];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]),
		cn[a[i]]++;
	ui ans = 0;
	for (int i = 1; i <= n; i++)
		ans += ((ui)cn[i] * (cn[i] - 1)) / 2ll;
	for (int i = 1; i <= n; i++)
		printf("%lld\n", ans - cn[a[i]] + 1);
	return 0;
}

Measured memory_bytes: 3712
import sys

MAX_N = 1000000
prime = []
is_prime = [True for i in xrange(MAX_N)]

for i in xrange(2, MAX_N):
    if is_prime[i] == True:
        prime.append(i)
        for j in xrange(i, MAX_N, i):
            is_prime[j] = False

LEN = len(prime)

for line in sys.stdin:
    n = int(line)
    cnt = 0
    for i in xrange(LEN):
        if prime[i] <= n:
            cnt += 1
        else:
            break
    print cnt

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

int main() {
    int n;
    cin >> n;
    int f = 0;
    int x = n;
    while (n/10 != 0) {
        f += n % 10;
        n = n / 10;
    }
    f += n % 10;
    if(x % f == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<62;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;

    vector<int> x(n), y(n);
    vector<int> xary, yary;

    rep(i, n) {
        cin >> x[i] >> y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }

    sort(xary.begin(), xary.end());
    sort(yary.begin(), yary.end());

    ll ans = LINF;
    for (int xi = 0; xi < n; ++xi) {
        for (int xj = xi+1; xj < n; ++xj) {
            for (int yi = 0; yi < n; ++yi) {
                for (int yj = 0; yj < n; ++yj) {
                    int num = 0;
                    ll lx = xary[xi], rx = xary[xj];
                    ll by = yary[yi], uy = yary[yj];

                    for (int i = 0; i < n; ++i) {
                        if (lx <= x[i] and x[i] <= rx and by <= y[i] and y[i] <= uy) {
                            num++;
                        }
                    }
                    if (num >= k) chmin(ans, 1LL * (rx - lx) * (uy - by));
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

#入力
# s = list(input()[0:-1])
# n = int(input())
A,B,M = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
# w = [int(input()) for i in range(n)]

xyc=[]
for i in range(M):
    x,y,c = map(int, input().split())
    xyc.append((x,y,c))
     
def main():
    mn = sorted(a)[0]+sorted(b)[0]
    for x, y, c in xyc:
        mn = min(mn, a[x-1]+b[y-1] - c)

    print(mn)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 30008
# エラトステネスの篩
def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(2, int(n ** 0.5) + 1):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


X = int(input())

N = 10 ** 6
prime_table = make_prime_table(N)
for i in range(X, N + 1):
    if prime_table[i] == i:
        print(i)
        break


Measured memory_bytes: 48540
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
void main()
{
    readln;
    auto a = Solver(readln.chomp.split.to!(int[]));
    immutable q = readln.chomp.to!size_t;
    foreach (_; 0..q)
    {
        auto buf = readln.chomp.split.to!(int[]);
        a.query(buf[0], buf[1]).writeln;
    }
}

private:

struct Solver
{
    this (int[] _a)
    {
        this.a = new long[10001];
        foreach (e; _a)
        {
            this.a[e] += 1;
            this.s += e;
        }
    }
    long query(in int b, in int c)
    {
        a[c] += a[b];
        s += (c - b) * a[b];
        a[b] = 0;
        return s;
    }
    invariant
    {
        assert (s == _s);
    }
    long[] a;
    long s;
    private long _s() @property const
    {
        long ret;
        foreach (i, e; a)
            ret += i * e;
        return ret;
    }
}


Measured memory_bytes: 7092
#include<cstdio>
#include<algorithm>

using namespace std;

int masu[14][14];
int cont;

void saiki(int x,int y){
	masu[x][y]=0;
	if(masu[x+1][y]==1){
		saiki(x+1,y);
	}
	if(masu[x-1][y]==1){
		saiki(x-1,y);
	}
	if(masu[x][y+1]==1){
		saiki(x,y+1);
	}
	if(masu[x][y-1]==1){
		saiki(x,y-1);
	}
}

int main()
{
	while(1){
		for(int i=0;i<14;i++){
			for(int j=0;j<14;j++)
			masu[i][j]=0;
		}
		cont=0;
		
		char str[100];
		for(int i=1;i<=12;i++){
			if(scanf("%s",str)==EOF){
				goto A;
			}
			for(int j=1;j<=12;j++){
				if(str[j-1]=='1'){
					masu[i][j]=1;
				}
			}
		}
		
		for(int i=1;i<=12;i++){
			for(int j=1;j<=12;j++){
				if(masu[i][j]==1){
					saiki(i,j);
					cont++;
				}
			}
		}
		printf("%d\n",cont);
	}
	A:;
	
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;

int main(int argc, char *argv[])
{
	int n,k;
	int cnt=0;
	cin >> n >> k;

	for (int i=0; i<n; i++)
	{
		int h;
		cin >> h;
		cnt+=(h>=k);

	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n, a, b, c;
  scanf("%d %d %d %d", &n, &a, &b, &c);
  int l[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
  }
  int ans = 10000;
  for (int i = 0; i < 1U << n * 2; i++) {
    int mp = 0;
    int bamboo[4] = {};
    for (int m = 0; m < n; m++) {
      int ix = i >> m * 2 & 3;
      if (ix != 0) {
        bamboo[ix] += l[m];
        mp += 10;
      }
    }
    if (bamboo[1] == 0 || bamboo[2] == 0 || bamboo[3] == 0) continue;
    mp += bamboo[1] > a ? bamboo[1] - a : a - bamboo[1];
    mp += bamboo[2] > b ? bamboo[2] - b : b - bamboo[2];
    mp += bamboo[3] > c ? bamboo[3] - c : c - bamboo[3];
    mp -= 30;
    if (ans > mp) ans = mp;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
using System;

namespace ABC086_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var aaa = Console.ReadLine().Split(' ');
            var a = aaa[0];
            var b = aaa[1];
            var c = a + b;
            var n = int.Parse(c);

            for (var i=1;i<n/2;i++)
            {
                if(i*i == n)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using static System.Math;
using Number = System.Int32;

namespace Program {
	public class Solver {
		Random rnd = new Random();
		public void Solve() {
			Console.WriteLine((ri + 1) / 2);
		}

		const long INF = 1L << 60;
		static int[] dx = { -1, 0, 1, 0 };
		static int[] dy = { 0, 1, 0, -1 };
		int ri { get { return sc.Integer(); } }
		long rl { get { return sc.Long(); } }
		double rd { get { return sc.Double(); } }
		string rs { get { return sc.Scan(); } }
		public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

		static T[] Enumerate<T>(int n, Func<int, T> f) {
			var a = new T[n];
			for (int i = 0; i < a.Length; ++i) a[i] = f(i);
			return a;
		}
		static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
	}
}

#region main
static class Ex {
	static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
	static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
		return string.Join(st, ie);
	}
	static public void Main() {
		Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = true });
		var solver = new Program.Solver();
		//* 
		var t = new System.Threading.Thread(solver.Solve, 50000000);
		t.Start();
		t.Join();
		//*/
		// solver.Solve();
		Console.Out.Flush();
	}
}
#endregion
#region Ex
namespace Program.IO {
	using System.IO;
	using System.Text;
	using System.Globalization;

	public class Printer : StreamWriter {
		public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
		public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
	}

	public class StreamScanner {
		public StreamScanner(Stream stream) { str = stream; }

		public readonly Stream str;
		private readonly byte[] buf = new byte[1024];
		private int len, ptr;
		public bool isEof = false;
		public bool IsEndOfStream { get { return isEof; } }

		private byte read() {
			if (isEof) return 0;
			if (ptr >= len) {
				ptr = 0;
				if ((len = str.Read(buf, 0, 1024)) <= 0) {
					isEof = true;
					return 0;
				}
			}
			return buf[ptr++];
		}

		public char Char() {
			byte b = 0;
			do b = read(); while ((b < 33 || 126 < b) && !isEof);
			return (char)b;
		}
		public string Scan() {
			var sb = new StringBuilder();
			for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);
			return sb.ToString();
		}
		public string ScanLine() {
			var sb = new StringBuilder();
			for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b);
			return sb.ToString();
		}
		public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
		public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
		public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }
	}
}

#endregion


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

using namespace std;

int main(){

	char comma;
	int l1,l2,l3;

	int rect=0;
	int rhombus=0;

	while(cin>>l1>>comma>>l2>>comma>>l3){
		if(l1==l2){
			if(l1*l1+l2*l2==l3*l3)
				rect++;
			else
				rhombus++;
		}
		else{
			if(l1*l1+l2*l2==l3*l3)
				rect++;
		}
	}
	cout<<rect<<endl;
	cout<<rhombus<<endl;

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define li long long int
#define mod 1000000000+7
li n;
double p[3005];
double dp[3005][3005];
double f(li i,li j)
{
    if(j==0)
        return 1;
    if(i==0)
        return 0;


    if(dp[i][j]>-0.9)
        return dp[i][j];
    return dp[i][j]= p[i]*f(i-1,j-1)+(1-p[i])*f(i-1,j);

}
int main()
{
    cin>>n;
    memset(dp,-1.0,sizeof(dp));
    li i;
    for(i=1;i<=n;i++)
        cin>>p[i];
    cout<<fixed<<setprecision(10)<<f(n,(n+1)/2);
    return 0;
}


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

int n,maxi;
int Ea[81],dp[81][321][321];

int rec(int idx,int prev,int now){
  if(idx == n-1) return now;
  if(dp[idx][prev][now]) return dp[idx][prev][now];
  int res = 0;
  res = max(res,rec(idx+1,now,Ea[idx+1]));
  if(now > 0) res = max(res,rec(idx+1,now-1,prev + Ea[idx+1]));
  return dp[idx][prev][now] = res;
}


int main(){
  int N;
  cin >> N;
  while(N--){
    memset(dp,0,sizeof(dp));
    cin >> n;
    for(int i=0;i<n;i++) cin >> Ea[i];
    cout << ((n == 1)? Ea[0] : rec(1,Ea[0],Ea[1])) << endl;
  }
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var list = input.Split(" ").Select(s => Int32.Parse(s)).ToList();

            string ans = list[0] <= list[1] * list[2] ? "Yes" : "No";  
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28288
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 100000007;
const int inf = 100000005;
const int N = 200005, M = N;
int i,j,n,m;

ll cnt , idx;
vi temp;



void solve() {
   string s;
   cin>>s;

   int n = s.length();
   fo(i,0,n) {
    if(i & 1) {
        if(s[i] == 'R') break;
    }
    else if(s[i] == 'L') break;
   }
   if(i == n) cout<<"Yes\n";
   else cout<<"No\n";
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




Measured memory_bytes: 3632
<?php
fscanf(STDIN,'%d%d',$A,$B);
$Barray=str_split($B);
$count=count($Barray);
for ($i=1; $i <=$count ; $i++) {
  // code...
  $A*=10;
}
$C= $A+$B;
$sq=strval(sqrt($C));
if(ctype_digit($sq)){
  echo 'Yes';
}else{
  echo 'No';
}
 ?>


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <queue>
#include <vector>

using namespace std;

typedef pair<int, int> P;
typedef pair<P, string> Q;

int main() {
	int n, q;
	while (cin >> n >> q) {
		if (n == 0 && q == 0) {
			break;
		}
		priority_queue<Q> pq;
		string era;
		int base;
		int west;
		for (int i = 0; i < n; i++) {
			cin >> era >> base >> west;
			Q p;
			(p.first).first = west-base+1;
			(p.first).second = west;
			p.second = era;
			pq.push(p);
		}
		vector<Q> hyou(n);
		for (int i = 0; i < n; i++) {
			hyou[i] = pq.top();
			pq.pop();
		}
		int a;
		for (int i = 0; i < q; i++) {
			cin >> a;
			bool hantei = true;
			for (int j = 0; j < n; j++) {
				if ((hyou[j].first).first <= a && a <= (hyou[j].first).second) {
					hantei = false;
					cout << hyou[j].second << ' ' << a-(hyou[j].first).first+1 << endl;
					break;
				}
			}
			if (hantei) {
				cout << "Unknown" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
#define int long long 
const int mod=1e9+7;
int power(int a,int b)
{
    if(a==1 || b==0)
        return 1;
    if(b==1)
        return a;
    int x=power(a,b/2);
    if(b%2==0)
        return ((x%mod)*(x%mod))%mod;
    return (((x%mod)*(x%mod))%mod * a)%mod;
}
void solve()
{
    int n, k, sum = 0;
    cin >> n >> k;
    vector<int> dp(k + 1, 0);
    for (int i = k; i >= 1; i--)
    {
        dp[i] = power(k / i, n);
        for (int j = i + i; j <= k; j+=i)
        {
            dp[i] = dp[i] - dp[j] + mod;
            if (dp[i] >= mod)
                dp[i] -= mod;
        }
        sum += dp[i]*i;
        if (sum >= mod)
            sum -= mod;
    }
    cout<<sum%mod;
}

int32_t main()
{
    solve();
    return 0;
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;int a[100],n,i,j,k,g;int main(){cin>>n;for(i=0;i<n;i++)cin>>a[i];for(i=0;i<n-2;i++){for(j=i+1;j<n-1;j++){for(k=j+1;k<n;k++)if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i])g++;}}cout<<g;return 0;}

Measured memory_bytes: 3600
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin>>n;
	cout<<fixed<<setprecision(10)<<2*M_PI*n<<endl;
	return 0;
}



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

//ABC124C
int main(void) {
  int n, k, i, cou=0, tmp;
  char s[100000];
  scanf("%s", s);
  for(i=0; s[i]!='\0'; i++){
    if(i%2==0&&s[i]=='1') cou++;
    else if(i%2==1&&s[i]=='0') cou++;
    //printf("s[%d]=%c\n",i,s[i]);
  }
  cou=cou>i-cou ? i-cou : cou;
  printf("%d", cou);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		String[] strtest = new String[26 * 3];
		String[] ts = {"the", "this", "that"};
		
		for (int i = 0; i < 26; i++) {
			for (int j = 0; j < 3; j++) {
				strtest[i * 3 + j] = "";
				for (int k = 0; k < ts[j].length(); k++) {
					char tmp = (char)((ts[j].charAt(k) + i - 'a') % 26);
					strtest[i * 3 + j] = strtest[i * 3 + j] + (char)(tmp + 'a');
				}
			}
		}
		
		String str = "";
		String ans = "";
		while (sc.hasNextLine() == true) {
			str = sc.nextLine();
			ans = "";
			
			String[] words = str.split(" ");
			
			int d = 0;
			boolean flag = false;
			for (int i = 0; i < words.length; i++) {
				String tmp = words[i];
				if ((tmp.length() != 3) && (tmp.length() != 4)) continue;
				
				for (int j = 0; j < strtest.length; j++) {
					if (i == (words.length - 1)) {
						tmp.substring(0, (tmp.length() - 1));
					}
					
					if (tmp.equals(strtest[j])) {
						d = j / 3;
						flag = true;
						break;
					}
				}
				if (flag) break;
			}
			

			for (int i = 0; i < str.length(); i++) {
				if ((str.charAt(i) != ' ') && (str.charAt(i) != '.')) {
					int tmp = (char)((str.charAt(i) - d - 'a' + 26) % 26);
					ans = ans + (char)(tmp + 'a');
				} else {
					ans = ans + str.charAt(i);
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 26024
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str,str2;
    ll x;
    cin>>n>>x;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    sort(v.begin(),v.end());
    rep(i,n){
        sum+=v[i];
        if(sum<=x) f++;
    }
    if(sum<x) f--; 
    cout<<f<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
import java.util.Collections;

class Main {

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    public static final long gcd(final long... param) {
        final long len = param.length;
        long g = gcd(param[0], param[1]);
        for (int i = 1; i < len - 1; i++) {
            g = gcd(g, param[i + 1]);
        }
        return g;
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];

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

        int[] ans = new int[N + 1];

        for (int i = 1; i < N; i++) {
            ans[A[i]]++;
        }

        for (int i = 1; i <= N; i++) {
            System.out.println(ans[i]);
        }

    }

}


Measured memory_bytes: 62644
import sys
input = sys.stdin.readline

H, W = list(map(int, input().split()))
A = []
DP = []

for _ in range(H):
    a = list(input().strip())
    A.append(a)
    DP.append([0] * W)


MOD = 10 ** 9 + 7
DP[0][0] = 1

for x in range(W):
    for y in range(H):
        if y + 1 < H and A[y+1][x] == ".":
            DP[y+1][x] = (DP[y+1][x] + DP[y][x]) % MOD
        if x + 1 < W and A[y][x+1] == ".":
            DP[y][x+1] = (DP[y][x+1] + DP[y][x]) % MOD

print(DP[H-1][W-1])


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

int main(){
    int n; cin >> n;
    vector<int>rate(n);
    for(int i=0;i<n;i++) cin >> rate[i];
    sort(rate.begin() ,rate.end());

    int under = 0 ,upper = 399;
    vector<int>color(9 ,0);
    for(int i=0;i<8;i++){
        for(int j=0;j<n;j++){
            if(under<=rate[j] && rate[j]<=upper)color[i]++;
        } 
        under += 400;
        upper += 400;
    }
    for(int i=0;i<n;i++){
        if(rate[i]>= 3200)color[8]++;
    }

    int ans = 0;
    for(int i=0;i<8;i++){
        if(color[i] > 0)ans++;
    }
    if(ans>0){
        cout <<ans << " "<< ans + color[8] <<endl;
    }else {
        cout << "1" << " " << color[8] << endl;
    }
}

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

using namespace std;

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    if (s.length() <= n)
    {
        cout << s;
    }
    else
    {
        cout << s.substr(0, n) << "...";
    }
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

int main()
{
    int64_t N;

    std::cin >> N;
    std::vector<int64_t> A;
    std::vector<int64_t> B;
    for (int64_t n = 0; n < N; ++n)
    {
        int64_t a;
        std::cin >> a;
        A.emplace_back(a);
    }

    int64_t v = 0;
    for (int64_t n = N - 1; n >= 1; --n)
    {
        v += A[n];
        v = v % 1000000007ull;
        B.emplace_back(v);
    }
    
    std::reverse(B.begin(), B.end());

    v = 0;
    for (int64_t n = 0; n < N - 1; ++n)
    {
        v += A[n] * B[n];
        v = v % 1000000007ull;
    }
    std::cout << v << std::endl;
    
    return 0;
}



Measured memory_bytes: 7984
import collections
import itertools
N = int(input())
balls =[list(map(int, input().split())) for _ in range(N)]
pq = collections.defaultdict(int)
for a, b in itertools.combinations(balls, 2):
    x1, y1 = a
    x2, y2 = b
    p = x1-x2
    q = y1-y2
    pq[(p, q)] += 1
    pq[(-p, -q)] += 1
cnt = 0
for c in pq.values():
    if c > cnt:
        cnt = c
ans = N-cnt
print(ans)

Measured memory_bytes: 3828
a=int(input())
b=int(input())
c=int(input())
X=input()
X=int(X)//50
count=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if (10*i+2*j+k)==X:
        count+=1
        
print(count)

Measured memory_bytes: 3188
#include <iostream>


struct Answer {
    int yen_10000;
    int yen_5000;
    int yen_1000;
    
    bool is_valid() { 
        return yen_10000 != -1;
    }
    
    void print() {
        std::printf(
            "%d %d %d\n",
            yen_10000, yen_5000, yen_1000
        );
    }
};


// n枚で1000*y円作る組み合わせを返す
Answer solve(
  	const int n, const int ky, bool use_10000=true, bool use_5000=true) 
{
    //
    if(n == 0 && ky == 0) {
        return {0, 0, 0};
    }
    if(ky == 0) {
        return {-1, -1, -1};
    }
    if(ky == n) {
        return {0, 0, n};
    }
    
    //
    if(use_10000) {
        for(int num = ky / 10; num >= 0; --num) {
            auto ans = solve(
                n - num, ky - num*10, false
            );
            if(ans.is_valid()) {
                ans.yen_10000 += num;
                return ans;
            }
        }
    }
    if(use_5000) {
        for(int num = ky / 5; num >= 0; --num) {
            auto ans = solve(
                n - num, ky - num*5, false, false
            );
            if(ans.is_valid()) {
                ans.yen_5000 += num;
                return ans;
            }
        }
    }
    
    return {-1, -1, -1};
}

int main(void) {
    int N, Y;
    std::cin >> N >> Y;

    solve(N, Y/1000).print();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
using namespace std;
const int maxn = 1e5+5;

int main(){
	int k, a, b; cin >> k >> a >> b;
	for(int i = a; i <= b; i++){
		if(i % k == 0){
			puts("OK");
			return 0;
		}
	}
	puts("NG");
	return 0;
}

Measured memory_bytes: 3596
N, M = list(map(int,input().split())) # N:node数，M:edge数
h = list(map(int,input().split()))


edges = [[] for _ in range(N)]

heighest = [True] * N

for i in range(M):
	a_temp, b_temp = list(map(int,input().split()))
	a_temp -= 1
	b_temp -= 1
	if h[a_temp] <= h[b_temp]:
		heighest[a_temp] = False
	if h[b_temp] <= h[a_temp]:
		heighest[b_temp] = False
print(sum(heighest))


Measured memory_bytes: 20920
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

bool is_cat(string&S)
{
    int idx = 0;
    int depth = 0;

    do {
        if (S[idx] == 'm') {
            depth++;
        } else if (S[idx] == 'w') {
            depth--;
        }

        idx++;
    } while (depth && idx < S.size());

    return (depth == 0) and (idx == S.size());
}

signed main()
{
    string S; cin >> S;

    cout << (is_cat(S) ? "Cat" : "Rabbit") << '\n';
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
int N, A, B;

void solve(int a, int b, int fix) {
    if(a == b) {
        if(a == A) printf("%d", a);
        else printf(" %d", a);
        return;
    }
    int c = a ^ b;
    for(int i = 0; i < N; ++i) {
        if(fix & (1 << i)) continue;
        if(c & (1 << i)) {
            int d = a;
            for(int j = 0; j < N; ++j) {
                if(i == j)continue;
                if(fix & (1 << j)) continue;
                d ^= (1 << j);
                break;
            }
            solve(a, d, fix ^ (1 << i)), solve(d ^ (1 << i), b, fix ^ (1 << i));
            break;
        }
    }
}

int main() {
    scanf("%d %d %d", &N, &A, &B);
    if(__builtin_popcount(A ^ B) % 2 == 0) puts("NO");
    else puts("YES"), solve(A, B, 0), puts("");
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;

    vector<int> r;
    for (int i = 0; i < n; i++) {
        int ri;
        cin >> ri;
        r.push_back(ri);
    }

    int diffmax = r[1] - r[0];
    int rmin = r[0];
    for (int i = 1; i < n; i++) {
        diffmax = max(diffmax, r[i] - rmin);
        rmin = min(rmin, r[i]);
    }

    cout << diffmax << endl;

    return 0;
}



Measured memory_bytes: 3948
#include<stdio.h>
#define max 100000
int a[max],n;
int partition(int p,int r)
{
	int x,i,j,t;
	x=a[r];
	i=p-1;
	for(j=p; j<r; j++)
	{
		if(a[j]<=x){
			i++;
			t=a[i];
			a[i]=a[j];
			a[j]=t;
		}
	}
	t=a[i+1];
	a[i+1]=a[r];
	a[r]=t;
	return i+1;
}

int main(void){
	int i,q;
	scanf("%d",&n);
		for(i=0; i<n; i++){
			scanf("%d", &a[i]);
		}
			q=partition(0,n-1);
			for(i=0; i<n; i++){
					if(i){printf(" ");}
					if(i==q){printf("[");}
					printf("%d",a[i]);
					if(i==q){printf("]");}
			}
			printf("\n");
		return 0;
}


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

using namespace std;

const int N = 1e5 + 2;

int n, m;
vector < pair <int, int> > v;

int main(){
      cin >> n >> m;

      for(int i = 1; i <= m; i ++){
            int x, y;
            cin >> x >> y;
            v.push_back({x, y});
      }

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

      int ans = 1, mn = 1e9, mx = 0;

      for(int i = 0; i < v.size(); i ++){
            mx = max(mx, v[i].first);
            mn = min(mn, v[i].second);
            if(mx >= mn){
                  ans ++;
                  mx = v[i].first, mn = v[i].second;
            }
      }

      cout << ans << endl;
}


Measured memory_bytes: 1400