akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
typedef long long ll;

ll count(vector<ll>& A, ll amount) {
    ll N = A.size();
    ll cnt = 0;
    for (ll i = 0; i < N; i++) {
        ll left = A[i];
        ll right = amount - left;
        // bsearch smallest index s.t. A[j] >= right
        ll lo = 0, hi = N-1;
        while (lo < hi) {
            ll mid = (lo + hi) / 2;
            if (A[mid] >= right) hi = mid;
            else lo = mid+1;
        }
        ll lo2 = lower_bound(begin(A), end(A), right) - begin(A);
        if (A[i] + A[lo] < amount) lo = N;
        cnt += (N - lo2);
    }
    return cnt;
}

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    sort(begin(A), end(A));
    ll lo = 0, hi = A.back() * 2;

    // bsearch largest amount s.t. count(A, amount) >= M
    while (lo < hi) {
        ll mid = (lo + hi + 1) / 2;
        // printf("%lld %lld\n", mid, count(A, mid));
        if (count(A, mid) >= M) {
            lo = mid;
        }
        else {
            hi = mid - 1;
        }
    }

    // cout << lo << endl;

    vector<ll> pfs = {0};
    for (auto& x : A) {
        pfs.push_back(pfs.back() + x);
    }

    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ll left = A[i];
        ll right = lo - left;
        ll j = lower_bound(begin(A), end(A), right) - begin(A);
        ans += (left * (N - j));
        ans += (pfs[N] - pfs[j]);
    }
    ans -= (count(A, lo) - M) * lo;

    cout << ans << endl;
}


Measured memory_bytes: 2168
N, P = list(map(int, input().split()))

prime = [2, 3, 5]
numL = [i for i in range(2, 1000001) if i % 2 != 0 and i % 3 != 0 and i % 5 != 0]
while True:
	p = numL[0]
	if p >= 1000:
		prime += numL
		break
	prime.append(p)
	numL = [i for i in numL if i % p != 0]

if N == 1:
	print(P)

else:
	ans = 1
	for i in prime:
		c = 0
		while True:
			if P % i == 0:
				c += 1
				P = int(P // i)
			else:
				break
		if c >= N:
			ans = ans * (i ** int(c // N))
	print(ans)

Measured memory_bytes: 15508
import math

def findsum(n):
  all_num=0
  while n>0:
    all_num += n%10
    n=math.floor(n/10)
  return all_num
  
n,a,b = map(int, input().split())

sum_num=0
for i in range(n):
  if(a<=findsum(i+1)<=b):
    sum_num+=i+1
print(sum_num)

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

int main() {
  int N, keta = 1, keta_cnt = 1, cnt = 0;
  cin >> N;

  for (int i = 1; i <= N; i++) {
    keta = i;
    while (keta >= 10) {      
      keta /= 10;      
      keta_cnt++;
    }
    if(keta_cnt % 2 == 1) {
      cnt++;
    }
    keta_cnt = 1;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
using namespace std;
const ll N = 1e7 + 5;
const ll maxn = 5005;
ll m, n, t, T, k, a[N], b[N], ans, tong;
string s, ss;
struct dang
{
    ll pos, val, mn, mx, vtri;
};
bool so(const dang& x, const dang& y)
{
    return (x.val < y.val) || (x.val == y.val && x.pos < y.pos);
}
void sol()
{
    cin >> n;
    ans = 1;
    m = 7;
    if(m % n == 0)
    {
        cout << ans;return;
    }
    while(m % n > 0)
    {
        ++ans;
        m = m * 10 + 7;
        if(m % n == 0)
        {
            cout << ans;
            return;
        }
        m %= n;
        if(ans > N)
        {
            cout << -1;
            return;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cin >> T; while(T -- > 0)
    sol();
}


Measured memory_bytes: 3632
x,y = map(int,input().split())

ans = 0
if x == 1:
  ans += 300000
elif x == 2:
  ans += 200000
elif x == 3:
  ans += 100000

if y == 1:
  ans += 300000
elif y == 2:
  ans += 200000
elif y == 3:
  ans += 100000

if x == 1 and y == 1:
  ans += 400000
print(ans)

Measured memory_bytes: 3064
def main():
    N, M, K = map(int, input().split())
    *A, = map(int, input().split())
    *B, = map(int, input().split())

    s = 0
    j = 0
    while j < len(B) and s + B[j] <= K:
        s += B[j]
        j += 1

    ans = cnt = j

    j -= 1
    for x in A:
        while j >= 0 and s + x > K:
            s -= B[j]
            j -= 1
            cnt -= 1
        if s + x > K:
            break
        s += x
        cnt += 1
        if ans < cnt:
            ans = cnt
    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

ll dp[7][2];
ll solve(int N, int head, int tail) {
  if (head == 0 || tail == 0) return 0;

  ll res = 0;
  if (head == tail && head <= N) {
    res++;
  }
  if (tail * 10 + head <= N) {
    res++;
  }

  for (int K = 3; K <= 6; K++) {
    CLR(dp, 0);
    dp[0][0] = 1;

    vector<int> v;
    int n = N;
    REP(i, K-1) {
      v.push_back(n % 10);
      n /= 10;
    }
    v.push_back(n);
    reverse(ALL(v));
    for (int i = 0; i < K; i++) {
      for (int d = 0; d < 10; d++) {
        if (i == 0 && d != tail) continue;
        if (i == K-1 && d != head) continue;
        dp[i+1][1] += dp[i][1];
        if (v[i] > d) {
          dp[i+1][1] += dp[i][0];
        } else if (v[i] == d) {
          dp[i+1][0] += dp[i][0];
        }
      }
    }
    res += dp[K][0] + dp[K][1];
  }
  return res;
}

int main2() {
  int N = nextInt();
  ll ans = 0;
  for (int a = 1; a <= N; a++) {
    int x = a;
    int tail = x % 10;
    int head = 0;
    while (x > 0) {
      head = x % 10;
      x /= 10;
    }
    ans += solve(N, head, tail);
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int Q;
    cin >> Q;
    rep(j, Q){
        ll A[2];
        cin >> A[0] >> A[1];
        ll l[2], r[2];
        rep(i, 2){
            l[i] = 0, r[i] = A[i];
            while(r[i]-l[i] > 1){
                ll n = (l[i]+r[i])/2;
                bool able = true;
                if(n >= A[i^1]+1){
                    ll x = n+A[i^1]+1;
                    if((x/2) * ((x+1)/2) >= A[0]*A[1]) able = false;
                }
                else{
                    if(n*(A[i^1]+1) >= A[0]*A[1]) able = false;
                }
                if(able) l[i] = n;
                else r[i] = n;
            }
        }
        cout << min(A[0]+l[1], A[1]+l[0]) -1 << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Sample01
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Trim().Split(" ").Select(int.Parse).ToArray();
            var hill = Console.ReadLine().Trim().Split(" ").Select(int.Parse).ToArray();
            Hill[] hills = new Hill[s[0]];

            for (int i = 0; i < hill.Length; i++)
            {
                hills[i] = new Hill();
                hills[i].setHigh(hill[i]);
            }

            for (int i = 0; i < s[1]; i++)
            {
                var road = Console.ReadLine().Split(" ").Select(x => int.Parse(x) - 1).ToArray();
                if (hills[road[0]].around < hills[road[0]].High)
                    hills[road[0]].around = hills[road[1]].High;
                if (hills[road[1]].around < hills[road[1]].High)
                    hills[road[1]].around = hills[road[0]].High;
            }

            int count = 0;
            for (int i = 0; i < s[0]; i++)
            {
                if (hills[i].around < hills[i].High)
                    count++;
            }

            Console.WriteLine(count);
        }

        class Hill
        {
            public int around { get; set; } = 0;
            public int High { get; set; }


            public void setHigh(int high)
            {
                High = high;
            }
        }
    }
}

Measured memory_bytes: 52268
#include<iostream>//入出力
#include<vector>//可変長配列
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<deque>//両端アクセスのキュー
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REPS(i,a,b) for(ll i=(a);i<(b);i++)
#define RREPS(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int N,M;

vector<int> g[100010];
map<pair<int,int>,int> mp;
vector<int> ans;

vector<int> treeEdges;
vector<int> A,B;
bool used[100010];

int num[100010];

void dfs(int now){
  used[now]=true;
  for(int i=0;i<g[now].size();i++){
    int nex=g[now][i];
    int a=min(now,nex),b=max(now,nex);
    if(used[nex]) continue;
    treeEdges[mp[mkp(a,b)]]=1;
    dfs(nex);
  }
}

int solve(int now){
  used[now]=true;
  for(int i=0;i<g[now].size();i++){
    int nex=g[now][i];
    int a=min(now,nex);
    int b=max(now,nex);
    if(used[nex]) continue;
    if(treeEdges[mp[mkp(a,b)]]==false) continue;
    int x=solve(nex);
    int c=-1;
    if(now>nex) c=1;
    if(x==1){
      num[now]^=1;
      ans[mp[mkp(a,b)]]=-c;
    }else ans[mp[mkp(a,b)]]=c;
  }

  if(num[now]==1){
    return 0;
  }else{
    return 1;
  }
}

int main(){
  cin>>N>>M;
  A.resize(M+1,0);
  B.resize(M+1,0);
  ans.resize(M+1,0);
  treeEdges.resize(M+1,0);
  for(int i=1;i<=M;i++){
    int a,b;
    cin>>a>>b;
    if(a>b) swap(a,b);
    A[i]=a;B[i]=b;
    mp[mkp(a,b)]=i;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  if(M%2){
    cout<<-1<<endl;
    return 0;
  }

  dfs(1);
  for(int i=1;i<=N;i++) used[i]=false;

  for(int i=1;i<=M;i++){
    if(treeEdges[i]) continue;
    num[A[i]]^=1;
    ans[i]=1;
  }

  int a=solve(1);

  for(int i=1;i<=M;i++){
    if(ans[i]==1) cout<<A[i]<<" "<<B[i]<<endl;
    else cout<<B[i]<<" "<<A[i]<<endl;
  }
  

  return 0;
}


Measured memory_bytes: 27648
// SeeAlso: https://atcoder.jp/contests/abc156/tasks/abc156_b

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

class Radix {
private:
  const char* s;
  int a[128];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;
    for(i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  std::string to(long long p, int q) {
    int i;
    if(!p)
      return "0";
    char t[64] = { };
    for(i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};

int main() {

    Radix r;

    ll n;
    int k;
    cin >> n >> k;

    string s = r.to(n, k);
    print(s.size());
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b){if (a > b) a = b;}
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b){if (a < b) a = b;}
const long long INF = 1LL << 60;

//初期値も初期条件も0
int dp[3100][3100] = { 0 };

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

	int n, m;
	n = s.size(); m = t.size();

	//DP
	rep(i, n) {
		rep(j, m) {
			if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j]+1);
			chmax(dp[i + 1][j + 1], dp[i][j+1] );
			chmax(dp[i + 1][j + 1], dp[i+1][j]);
			//cout << dp[i + 1][j + 1] << " ";
		}
		//cout << endl;
	}

	//復元
	int i = n;
	int j = m;

	//空文字列で初期化
	string res = "";

	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i][j-1]) {
			j--;
		}
		else if (dp[i][j] == dp[i-1][j]) {
			i--;
		}
		else {
			res = s[i - 1] + res;
			i--;
			j--;
		}
	}

	cout << res << endl;

}

Measured memory_bytes: 37120
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N,M; cin>>N>>M;
    vec A(N),B(N);
    pairs p(N);
    REP(i,N){
        cin>>A[i]>>B[i];
        p[i]= Pii(A[i],B[i]);
    }
    Sort(p);
    int ans = 0;
    REP(i,N){
        ans += min(M,p[i].second)*p[i].first;
        M -= min(M,p[i].second);
    }
    Out(ans);
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

class Node {
public:
    vector<int> neighbors;
    vector<int> weights;

    Node(){}

    Node(vector<int> neighbors, vector<int> weights) {
        int s = neighbors.size();
        this->neighbors.resize(s);
        this->weights.resize(s);
        for(int i = 0;i < s;i++) {
            this->neighbors[i] = neighbors[i];
            this->weights[i] = weights[i];
        }
    }
};

// nodesは頂点数+1のvector
// nodes[start]からの距離を求める
vector<int> dijkstra(vector<Node> nodes, int start) {
    vector<int> cost;
    vector<bool> visited;
    cost.resize(nodes.size());
    visited.resize(nodes.size());

    fill(ALL(cost), IINF);
    fill(ALL(visited), false);

    cost[start] = 0;
    visited[start] = true;

    int size = nodes[start].neighbors.size();
    for(int i = 0;i < size;i++) {
        int v = nodes[start].neighbors[i];
        int w = nodes[start].weights[i];
        cost[v] = w;
    }
    for(int i = 0;i < nodes.size() - 2;i++) {
        int min_cost = IINF + 1;
        int min_index = -1;
        for(int j = 1;j <= nodes.size() - 1;j++) {
            if(!visited[j] && cost[j] < min_cost) {
                min_index = j;
                min_cost = cost[j];
            }
        }

        cost[min_index] = min_cost;
        visited[min_index] = true;
        int size = nodes[min_index].neighbors.size();
        for(int j = 0;j < size;j++) {
            int v = nodes[min_index].neighbors[j];
            int w = nodes[min_index].weights[j];
            cost[v] = min(cost[v], cost[min_index] + w);
        }
    }
    return cost;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<Node> nodes;
    nodes.resize(N + 1);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        nodes[a].neighbors.push_back(b);
        nodes[a].weights.push_back(1);
        nodes[b].neighbors.push_back(a);
        nodes[b].weights.push_back(1);
    }

    int count = 0;
    FOR(i, 1, N + 1) {
        FOR(j, i + 1, N + 1) {
            auto fndi = find(ALL(nodes[i].neighbors), j);
            auto fndj = find(ALL(nodes[j].neighbors), i);
            bool p = fndi != nodes[i].neighbors.end();
            int ii = distance(nodes[i].neighbors.begin(), fndi);
            int ji = distance(nodes[j].neighbors.begin(), fndj);
            if(!p)continue;
            nodes[i].weights[ii] = IINF;
            nodes[j].weights[ji] = IINF;
            vector<int> cost = dijkstra(nodes, i);
            if(100 < cost[j]) {
                count++;
            }
            nodes[i].weights[ii] = 1;
            nodes[j].weights[ji] = 1;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n, p;
    cin >> n >> p;
    cout << (n*3+p)/2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<bitset>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;

typedef long long LL;
typedef long double LD;
const int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int ans = 0;
    if(h1 <= h2){
        ans += (h2 - h1) * 60;
    }else{
        ans += (h2 - h1 + 24) * 60;
    }
    ans -= m1;
    ans += m2;
    cout << ans - k << endl;
}

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

int n = 0;
int k = 0;
int a[100020] = {0};
int table[100020] = {0};

bool input() {
  cin >> n >> k;
  if (!n && !k) return false;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    table[i+1] = a[i] + table[i];
  }
  return true;
}

int solve() {
  int Max = -1001001001;
  for (int i = 0; i < n-k; i++) {
    Max = max(Max, table[i+k]-table[i]);
  }
  return Max;
}

int main() {
  while(input()) {
    printf("%d\n", solve());
  }
  return 0;
}



Measured memory_bytes: 3992
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    ans = 0
    for i in range(1,N+1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i
    
    print(ans)




if __name__ == "__main__":
    main()

Measured memory_bytes: 72876
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 301
int num[4], n;
double p[N][N][N];
double P(int x, int y, int z) {
    if (p[x][y][z] >= 0) return p[x][y][z];
    double sum = (double)n / (x + y + z);
    if (x) sum += P(x - 1, y, z) * x / (x + y + z);
    if (y) sum += P(x + 1, y - 1, z) * y / (x + y + z);
    if (z) sum += P(x, y + 1, z - 1) * z / (x + y + z);
    return p[x][y][z] = sum;
}
int main() {
    scanf("%d", &n);
    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= n; j++)
            for (int k = 0; k <= n; k++) p[i][j][k] = -1;
    p[0][0][0] = 0;
    for (int i = 1, x; i <= n; i++) {
        scanf("%d", &x);
        num[x]++;
    }
    printf("%.10lf\n", P(num[1], num[2], num[3]));
    return 0;
}

Measured memory_bytes: 213376
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int > A,pair<long long int,long long int> B)
{
    if(A.second == B.second)
    {
        return B.first > A.first;
    }
    else
        return A.second < B.second;
}
   
int main()
{
    long int n;
    cin>>n;
    vector<pair<long long int,long long int>> v;
    for(long int i=0;i<n;i++){
        long long int a,b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    long long int sum=0;
    sort(v.begin(),v.end(),comp);
    bool flag = false;
    for(long int i=0;i<n;i++)
        //cout<<v[i].first<<" "<<v[i].second<<endl;
    {
        sum+=v[i].first;
        if(sum>v[i].second)
            {
                flag= true;
                break;
            }
    }    
    if(flag)
        cout<<"No";
    else
        cout<<"Yes";
    
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e6+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll cnta[MAXn],cntb[MAXn];
ll mul(ll x,ll y){
  return (x*y)%MOD;
}
int main(){
  IOS();
  ll n,m;
  cin >> n >> m;
  REP (i,n) {
    ll x;
    cin >> x;
    cnta[x]++;
  }
  REP (i,m) {
    ll x;
    cin >> x;
    cntb[x]++;
  }

  ll ans = 1;
  ll ta = 0, tb = 0;
  for (ll cur=n*m;cur>=1;cur--) {
    if (cnta[cur] && cntb[cur]) {
      ta++, tb++;
      continue;
    }
    else if (cnta[cur]) {
      ta++;
      ans = mul(ans,tb);
    }
    else if (cntb[cur]) {
      tb++;
      ans = mul(ans,ta);
    }
    else ans = mul(ans,ta*tb - (n*m-cur));
    debug(ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef pair<int, int> P;
//typedef pair<int, pair<int, int> > PP;

int main(){
  	int N;
	cin>>N;
	int A[300][300], B[300][300];
	rep(i,N)rep(j,N){
		cin>>A[i][j];
		B[i][j]=A[i][j];
	}
	
	rep(k,N)rep(i,N)rep(j,N)B[i][j]=min(B[i][j], B[i][k]+B[k][j]);
	
	bool rex=true;
	rep(i,N)rep(j,N)if(A[i][j]!=B[i][j])rex=false;
	if(!rex){
		cout<<-1<<endl;
		return 0;
	}
  	
	ll ans=0;
	rep(i,N)rep(j,N)if(i<j){
		bool nd=true;
		rep(k,N)if(k!=i && k!=j){
          	if(B[i][j]==B[i][k]+B[k][j])nd=false;
        }
		if(nd)ans+=(ll)B[i][j];
	}
	cout<<ans<<endl;
}

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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  vector<ll> sum(n);
  ll a; std::cin >> a;
  sum[0] = a;
  srep(i, 1, n) {
    std::cin >> a;
    sum[i] = sum[i-1] + a;
  }
  ll diff = 1e10;
  rep(i, n-1) {
    chmin(diff, abs(sum[n-1]-sum[i]*2));
  }
  std::cout << diff << "\n";
}


Measured memory_bytes: 1792
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
size = a.size
a = a.sort 
i = 1
while true
    if a[i] == a[i-1]
        puts "NO"
        break
    else
        i += 1
    end
    if size  == i - 1
        puts "YES"
        break
    end
end

Measured memory_bytes: 33032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main(){
  string s;
  cin>>s;
  int cnt=0,ans=0;
  rep(i,s.size()){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      cnt++;
      ans=max(ans,cnt);}
    else cnt=0;
  }
  cout << ans <<endl;
}

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

//#define rep(i,n) for(int i=0;i<(n);i++)
//#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    for(int i=0;i<a;i++){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	    for(int i=0;i<t;i++){ fact[i+1]=fact[i]*(i+1)%MOD;}
	fact_inv[t]=power(fact[t], MOD-2);
	for(int i=0;i<t;i++){ fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;}
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
	cin.tie(0);	ios::sync_with_stdio(false);

  int i,j;
  int N; cin >> N;
  ll X; cin >> X;
  vector<ll>A(N,0);
  for(i=0;i<N;i++){
      cin >> A[i];
  }
  sort(ALL(A));
  int ans = 0;
  ll sum = 0;
  for(i=0;i<N;i++){
      sum += A[i];
      if(i < N-1 && sum < X){ans++;}
      if(sum == X){ans++;break;}
      if(sum > X){break;}
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int a,b,c;
    int count=0;
    cin>>a>>b>>c;
    for(int i=a;i<=b;i+=a){
        count++;
    }
    if(count<=c){
        cout<<count<<"\n";
    }else{
        cout<<c<<"\n";
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashSet set = new HashSet();
		set.add(sc.nextInt());
		set.add(sc.nextInt());
		set.add(sc.nextInt());
		System.out.println(set.size());
	}
}

Measured memory_bytes: 10192
N, M = map(int, input().split())
foods_likes = [0] * M
for _ in range(N):
    survey_result = list(map(int, input().split()))
    k = survey_result[0]
    a = survey_result[1:]
    for i in range(k):
        foods_likes[a[i] - 1] += 1
ans = 0
for likes in foods_likes:
    if likes == N:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

int main()
{
    int A, B, C;

    cin >> A >> B >> C;

    bool isThereOnWay = false;

    if (A < B)
    {
        if (A <= C && C <= B)
        {
            isThereOnWay = true;
        }
    }
    else
    {
        if (B <= C && C <= A)
        {
            isThereOnWay = true;
        }
    }

    cout << (isThereOnWay ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int n;
cin>>n;
ll a[n];
ll sum=0;
for(auto &x:a)
{
	cin>>x;
	sum+=x;
}
ll ans=0;
for(int i=0;i<n;i++)
{
	sum-=a[i];
	ans=(ans+((a[i]%chotu)*(sum%chotu))%chotu)%chotu;
}
cout<<ans;
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
solve();
cout<<endl;
}
}


Measured memory_bytes: 5212
N = int(input())
V = [int(line) for line in input().split()]
C = [int(line) for line in input().split()]

dif = [(V[i]-C[i]) for i in range(N)]
ans = 0
for i in range(N):
    if dif[i] > 0:
        ans += dif[i]
print(ans)

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i,m){
    cin >> a.at(i);
  }

  int days = n;
  rep(i,m){
    days -= a.at(i);
  }
  if(days >= 0){
    cout << days << endl;
  }else{
    cout << "-1" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	int i,j,k;
	int h,w;
	char a[10][10];
	int m,s=0;
	cin>>h>>w;
	for(i=0;i<h;i++){
		cin>>a[i];
	}
	for(i=0;i<h-1;i++){
		m=0;
		for(j=0;j<w;j++){
			if(a[i][j]=='#' && a[i+1][j]=='#')m++;
		}
		if(m>1)s++;
	}
	for(i=0;i<w-1;i++){
		m=0;
		for(j=0;j<h;j++){
			if(a[j][i]=='#' && a[j][i+1]=='#')m++;
		}
		if(m>1)s++;
	}
	if(s==0){
		cout<<"Possible"<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll a,b,t;
    cin >> a >> b >> t;
    cout << (t/a)*b << endl;;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, c=0;
    cin>>n;
    for(int i=1; i<=9; i++)
    {
        if((n/i)<=9 && (n%i) == 0)
        {
            c = 1;
            break;
        }
    }
    if(c==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef pair<int, int> P;

P func(int x) {
        P p;
        p.first = x % 10;
        p.second = 0;
        while(x > 0) {
                p.second = x;
                x /= 10;
        }
        return p;
}

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

        map<P, int> mp;
        for(int i = 1; i <= n; i++) {
                P p = func(i);
                mp[p]++;
        }

        int ans = 0;
        for(int i = 1; i <= n; i++) {
                P p = func(i);
                P q;
                q.first = p.second;
                q.second = p.first;
                ans += mp[q];
        }

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

Measured memory_bytes: 256
/*
 * a.cc: A: ABC Edition
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n5 = 0, n7 = 0;
  for (int i = 0; i < 3; i++) {
    int a;
    cin >> a;
    if (a == 5) n5++;
    else if (a == 7) n7++;
  }

  cout << ((n5 == 2 && n7 == 1) ? "YES" : "NO") << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) {
    cin >> a[i];
  }
  vector<ll> sum(n, 0);
  sum[0] = a[0];
  for (ll i = 1; i < n; i++) {
    sum[i] = (sum[i - 1] + a[i]) % MOD;
  }
  ll ans = 0;

  for (ll i = 0; i < n; i++) {
    ans += (a[i] * ((sum[n - 1] - sum[i]+MOD) % MOD)) % MOD;
    ans %= MOD;
  }

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


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

int main(){
    int n ;
    cin >> n ;
    vector<vector<int> > a(n,vector<int>(2)) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i).at(0) ;
        a.at(i).at(1) = i+1 ;
    }
    sort(a.begin() ,a.end()) ;
    if (n > 1)
    {
       for (size_t i = 0; i < n-1; i++)
        {
            cout << a.at(i).at(1) << " " ;
        }

    }
    
    cout << a.at(n-1).at(1) << endl ;
    
}

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

int main(void){
    int n;cin >> n;
    int max = 0;

    for (int i=n;i>=0;i--){
        if (n >= pow(i, 2)){
            if (pow(i, 2) >= max){
                max = pow(i,2);
            }
        }
    }

    cout << max<< endl;
    return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
#define INF 1e9
int gcd(int a,int b){
    if(b==0)return a;
    int res=gcd(b,a%b);
    return res;
}
int gcd(int i,int j,int k){
    int res=0;
    res=gcd(gcd(i,j),gcd(i,k));
    return res;
}
int main(){
    int n;
    
    cin>>n;
    int ans=0;
    for(int i=1;i<n+1;i++){
        for(int j=1;j<n+1;j++){
            for(int k=1;k<n+1;k++){
                ans+=gcd(i,j,k);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
def main():
    S = list(input())
    T = list(input())
    S.reverse()
    T.reverse()
    SL = list(S)
    f = False
    for i in range(len(S) - len(T) + 1):
        SL = list(S)
        for j in range(len(T)):
            if S[i + j] == '?' or S[i + j] == T[j]:
                SL[i + j] = T[j]
            else:
                break
        else:
            f = True
            break
    if f is False:
        print('UNRESTORABLE')
    else:
        SL.reverse()
        print(''.join(SL).replace('?', 'a'))


main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 100005;
vector<int> g[N];
int dp[N];
bool val[N];

inline int g_dp(int x){
	if(!val[x]){
		val[x] = true;
		for(int a:g[x]){
			dp[x] = max(dp[x], 1 + g_dp(a));		
		}
	}
	return dp[x];
}

int main(){
	fast_io();
	int n, m;
	cin >> n >> m;
	cu(i,0,m){
		int x,y;
		cin >> x >> y;
		g[x].pb(y);
	}
	int ans = 0;
	fu(i,1,n){
		ans = max(ans, g_dp(i));
	}
	cout << ans << endl;
}


Measured memory_bytes: 7424
sentence = input()
ab = sentence.split()
A = int(ab[0])
B = int(ab[1])
if A == B:
    print(0)
    exit()
else:
    sum_ab = A + B
    if sum_ab % 2 == 0:
        print(sum_ab // 2)
        exit()
ans = "IMPOSSIBLE"
print(ans)


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

int main()
{
    string s;
    cin >> s;
    string ans = "No";
    rep(i, s.length()) if (s[i] == '7') ans = "Yes";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, i;
    cin >> n >> i;
    cout << (n - i + 1) << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		char[] wk;

		try {
			scanner = new Scanner(System.in);
			wk = scanner.nextLine().toCharArray();

			int res = 0;
			for (int i = 0; i < wk.length; i++) {
				if (wk[i] == '1') {
					res++;
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22612
import math
import itertools
from itertools import combinations
N = int(input())
A = input().split()
list = [int(n) for n in A]
a = 0
for v in itertools.combinations(list, 3):
    u = sorted(v)
    if u[0] != u[1] != u[2]:
        if u[2] < u[1]+u[0] and u[1]-u[0] < u[2]:
            a = a+1
        else:
            continue
    else:
        continue
print(a)

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

int gcd(int a, int b) {
  int r;
  while (r = a % b) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << gcd(a, b) << endl;
}

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

using namespace std;

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

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

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

  int ans = INT_MAX;
  for (int i=0; i<=(n-k); i++) {
    if ((h[i+k-1] - h[i]) < ans) {
      ans = h[i+k-1] - h[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640