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

struct edge{
	edge(){}
	edge(ll from, ll to, ll cost, ll id) :from(from), to(to), cost(cost), id(id){}
	ll from, to, cost, id;
};

edge es[100000];
using Graph = vector<vector<edge>>;

int N, M;

const ll INF = 1LL << 55;

void dijkstra(int s, const Graph& g, vector<ll>& dist){
	using P = pair<ll, int>;
	dist = vector<ll>(N, INF);
	dist[s] = 0;
	priority_queue<P, vector<P>, greater<P>> q;
	q.push({ 0, s });
	while(q.size()){
		ll d = q.top().first, v = q.top().second;
		q.pop();
		for(auto e : g[v]){
			if(dist[e.to] > d + e.cost){
				dist[e.to] = d + e.cost;
				q.push({ d + e.cost, e.to });
			}
		}
	}
}

int use[100000];
int bri[100000];

using Pii = pair<int, int>;

std::pair<std::vector<int>, vector<Pii>> bridge(const Graph& g){
	const int n = g.size();
	int idx = 0, s = 0, t = 0, k = 0;
	std::vector<int> ord(n, -1), onS(n), stk(n), roots(n), cmp(n);
	vector<Pii> brdg;
	std::function<void(int, int)> dfs = [&](int v, int u){
		ord[v] = idx++;
		stk[s++] = v;
		onS[v] = true;
		roots[t++] = v;
		for(auto& e : g[v]){
			int w = e.to;
			if(ord[w] == -1)
				dfs(w, v);
			else if(u != w && onS[w])
				while(ord[roots[t - 1]] > ord[w]) --t;
		}
		if(v == roots[t - 1]){
			brdg.emplace_back(u, v);
			while(1){
				int w = stk[--s];
				onS[w] = false;
				cmp[w] = k;
				if(v == w) break;
			}
			--t;
			++k;
		}
	};
	for(int u = 0; u < n; u++){
		if(ord[u] == -1){
			dfs(u, n);
			brdg.pop_back();
		}
	}
	return std::make_pair(cmp, brdg);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	cin >> N >> M;

	Graph G(N), Gr(N);
	for(int i = 0; i < M; i++){
		ll u, v, cost;
		cin >> u >> v >> cost;
		u--, v--;
		es[i] = edge(u, v, cost, i);
		G[u].push_back(edge(u, v, cost, i));
		Gr[v].push_back(edge(v, u, cost, i));
	}

	vector<ll> d(N), dr(N);
	dijkstra(0, G, d);
	dijkstra(1, Gr, dr);

	ll dist = d[1];
	Graph G2(N);
	map<Pii, int> idmap;
	for(int i = 0; i < M; i++){
		edge e = es[i];
		ll dd = d[e.from] + e.cost + dr[e.to];
		if(dist == dd){
			use[i] = 1;
			for(int loop = 0; loop < 2; loop++){
				G2[e.from].push_back(e);
				idmap[{e.from, e.to}] = i;
				swap(e.from, e.to);
			}
		}
	}

	auto res = bridge(G2);
	for(auto p : res.second){
		for(int i = 0; i < 2; i++){
			if(idmap.count(p)){
				bri[idmap[p]] = 1;
			}
			swap(p.first, p.second);
		}
	}

	for(int i = 0; i < M; i++){
		if(!use[i]){
			edge e = es[i];
			ll dd = d[e.to] + e.cost + dr[e.from];
			if(dist > dd){
				cout << "HAPPY" << endl;
			}
			else{
				cout << "SOSO" << endl;
			}
		}
		else{
			if(bri[i]){
				cout << "SAD" << endl;
			}
			else{
				cout << "SOSO" << endl;
			}
		}
	}
}

Measured memory_bytes: 55440
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;


#define ll long long
#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];



int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	int t = -1;
	int f = vec.size();
	while (f - t > 1) {
		int m = (t + f) / 2;

		if (vec[m] < xx) {
			t = m;
		}
		else {
			f = m;
		}
	}
	return f;
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx == 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}





signed main() {
	int a,n, k,q;
	cin >> n >> k >> q;
	vector<int>vec(n);
	rep(i, q) {
		cin >> a;
		vec[a - 1]++;
	}
	rep(i, n) {
		if (k - q + vec[i] > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 1408
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>
#include <bits/stdc++.h>

#define int long long

struct edge {
    int to;
    int cost;
};

using namespace std;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vb = vector<bool>;
using qi = queue<int>;
using P = pair<int, int>;
using graph = vector<vector<edge>>;
// using graph = vector<vector<int>>;


#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define delim(i, n) cout << (i == n-1 ? "\n" : " ");
#define pv(v, n) REP(ii, n) { cout << v[ii]; delim(ii, n); }

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

const int inf = 1LL << 60;
// const int inf = 100000000;
const int mod = 1000000007;

const int maxn = 300;
int n;
vii dist(maxn, vi(maxn));
vii init_dist(maxn, vi(maxn));
vii flag(maxn, vi(maxn));

vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};

void warshall_floyd() {
    REP(i, n) {
        REP(j, n) {
            REP(k, n) {
                if (dist[j][i] == inf || dist[i][k] == inf) continue;
                // min(inf, inf + (N<0)) should be inf but not
                if (dist[j][k] >= dist[j][i] + dist[i][k]) {
                    dist[j][k] = dist[j][i] + dist[i][k];
                    if (j != i && i != k) flag[j][k] = 1;
                }
            }
        }
    }
}

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

    cin >> n;
    REP(i, n) {
        REP(j, n) {
            cin >> dist[i][j];
            init_dist[i][j] = dist[i][j];
        }
    }
    
    warshall_floyd();

    int ret = 0;
    REP(i, n) {
        REP(j, n) {
            if (init_dist[i][j] != dist[i][j]) {
                ret = -2;
                break;
            }
            ret += (1-flag[i][j])*init_dist[i][j];
        }
        if (ret == -2) break;
    }
    ret /= 2;
    
    cout << std::fixed << std::setprecision(10) << ret << "\n";
}

Measured memory_bytes: 5724
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	int n, i, j, k, c, d, x;
	char s[1025], t[10][6] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> s;
		for (j = x = d = 0; j < strlen(s); j++, d = c)
		{
			c = s[j] - '0';
			if (c == 0 && d != 0)
				cout << t[d-1][x%strlen(t[d-1])];
			else if (d == c)
				x++;
			else
				x = 0;
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
using System;

class Program
{
    static Int64[] n = new Int64[6];
    static Int64 sum()
    {
        Int64 sum = 0;
        for (Int64 i = 0; i < 5; i++)
            sum += n[i];
        return sum;
    }
    static int Main()
    {
        var n = Int64.Parse(Console.ReadLine());
        Int64 min = Int64.MaxValue,a;
        for(var i=0; i<5; i++)
        {
            a = Int64.Parse(Console.ReadLine());
            if (min > a)
                min = a;
        }
        if (n % min == 0)
            n /= min;
        else
            n = (n / min) + 1;
        Console.WriteLine((n + 4).ToString("d"));
        return 0;
    }
    static int Main2()
    {
        Int64 t = 0;
        n[0] = Int64.Parse(Console.ReadLine());
        Int64[] a = new Int64[5];
        for(Int64 i=0; i<5; i++)
            a[i]= Int64.Parse(Console.ReadLine());
        for (; sum()>0;t++)
        {
            /*
            for (Int64 i = 0; i < 6; i++)
                Console.Write(n[i].ToString("d"));
            Console.WriteLine();
            */
            for(Int64 i=4; i>=0; i--)
            {
                if (n[i] > 0)
                {
                    n[i] -= a[i];
                    n[i + 1] += a[i];
                    if (n[i] < 0)
                    {
                        n[i + 1] += n[i];
                        n[i] = 0;
                    }
                }
            }
        }
        Console.WriteLine(t.ToString("d"));
        return 0;
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using vi = vector<int>;
using vv = vector<vi>;
//const int MOD = 1000000007;
const int MOD = 998244353;
const ll INF = 1001001001001;

int main(){
    int x;
    cin>>x;
    
    if(x>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3616
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
//作者:中国江苏南京丁天行
using namespace std;
//数组不要开小了
//数组不要开反了
int n,f[100015],ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
            int x;
            scanf("%d",&x);
            f[x]++,f[x+1]++,f[x+2]++;
    }
    for(int i=0;i<=100010;i++)ans=max(ans,f[i]);
    printf("%d\n",ans);
	//system("pause");
	return 0;
}


Measured memory_bytes: 640
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents = [i for i in range(n+1)]
        self.size = [1]*(n+1)
    def find(self,x):
        if self.parents[x]==x:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        xRoot = self.find(x)
        yRoot = self.find(y)
        if xRoot == yRoot:
            return
        if self.size[xRoot]>self.size[yRoot]:
            self.parents[yRoot] = xRoot
        else:
            self.parents[xRoot] = yRoot
            if self.size[xRoot] == self.size[yRoot]:
                self.size[yRoot]+=1
N = int(input())
tree = UnionFind(N)
nodes = []
for i in range(1,N+1):
    x,y = map(int,input().split())
    nodes.append((i,x,y))
edges = []
nodes.sort(key=lambda x: x[1])
for i in range(1,N):
    edges.append((nodes[i][1]-nodes[i-1][1],nodes[i][0],nodes[i-1][0]))
nodes.sort(key=lambda x: x[2])
for i in range(1,N):
    edges.append((nodes[i][2]-nodes[i-1][2],nodes[i][0],nodes[i-1][0]))
edges.sort()
cost = 0
for w,s,t in edges:
    if tree.find(s)!=tree.find(t):
        tree.unite(s,t)
        cost += w
print(cost)

Measured memory_bytes: 124524
import scala.io.StdIn
import scala.annotation.tailrec

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    val house = Array.ofDim[Int](House.building, House.floor, House.room)
    for (_ <- 1 to StdIn.readInt()) {
      val in = StdIn.readLine().split(" ").map(_.toInt)
      house(in(0) - 1)(in(1) - 1)(in(2) - 1) += in(3)
    }
    for(i <- 0 to House.building - 1; j <- 0 to House.floor - 1){
      println(" " + house(i)(j).mkString(" "))
      if(i < House.building - 1 && j == House.floor - 1){println("#" * 20)}
    }
  }
}

object House {
  val building = 4
  val floor = 3
  val room = 10
}

Measured memory_bytes: 44020
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Numerics;

class Myon
{
    //chokudaiさんのコードをコピペ
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        //Console.SetOut(new Printer(Console.OpenStandardOutput()));
        cin = new Scanner();
        new Myon().calc();
        Console.Read();

        return 0;
    }


    public void calc()
    {
        int anycolor = 8;
        int n = cin.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = cin.nextInt();

        int[] found = new int[anycolor +1];
        for (int i = 0; i < n; i++)
        {
            int i2 = (a[i] / 400 >= anycolor) ? anycolor : a[i] / 400;
            found[i2]++;
        }
        int count = 0;
        for (int i = 0; i < anycolor; i++) if (found[i] > 0) count++;
        int min = (count == 0) ? 1 : 0;
        int max = found[anycolor];
        showL($"{min + count} {max + count}");
    }

    

    public void backetSort(ref int[] a)
    {
        //max a << a.len に対して有効なソート
        //よってa = int[] とする
        long n = a.Length;
        var count = new int[n];
        var loc = new long[n];//loc[i] は i が終わる 位置 max index where c[index] = loc[i]
        for (long i = 0; i < n; i++) count[a[i]]++;
        loc[0] = count[0] - 1;
        for (long i = 0; i < n-1; i++) loc[i+1] = loc[i] + count[i+1]; 
        long index = 0;

        for(int i = 0; i < n; i++)
        {
            while (index <= loc[i]) a[index++] = i; //incex <= loc[i] == index < loc[i] + 1
        }
    }

    public static void showL(long n) { Console.WriteLine(n); }
    public static void showL(string s) { Console.WriteLine(s); }
}

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

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        while (i >= s.Length)
        {
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
        }
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 11220
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
//#include<queue>
//#define d double
#define ll long long
#define ull unsigned long long
using namespace std;
const int maxn=1e5+233;
int a[maxn];
int i,j,k,n,m;int p;

int ra,fh;char rx;
inline int read(){
	rx=getchar(),ra=0,fh=1;
	while(rx<48)rx=='-'&&(fh=-1),rx=getchar();
	while(rx>47)ra=ra*10+rx-48,rx=getchar();return ra*fh;
}



int main(){
	int n=read(),c=read(),k=read();
	for(i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+1+n);
	
	/*int l,r,mid,ans=0;
	for(i=1;i<=n;i=l+1){
		l=i,r=i+c-1;
		while(l<r)if(a[mid=(l+r+1)>>1]-a[i]>k)r=mid-1;else l=mid;
		ans++;
	}printf("%d\n",ans);*/
	int ans=0,now=0;
	for(i=1;i<=n;i=j+1){
		for(j=i,now=0;j<=n;j++)if(a[j]-a[i]>k||now++==c)break;
		j--,ans++;
	}printf("%d\n",ans);
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  for (int i = 0; i < N; i++) {
    if (A[i] % 2 == 0) {
      if (A[i] % 3 == 0 || A[i] % 5 == 0) {
        continue;
      } else {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int N,p,sum=0,flag=0;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&p);
    sum+=p;
    if(p>flag){
      flag=p;
    }
  }
  printf("%d\n",sum-flag/2);
  return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!
N,M=map(int,input().split())

l=[0]*N


ans=[0,0]
for _ in range(M):
    num,judge=input().split()
    num=int(num)
    num-=1
    if l[num]==-1:
        continue
    else:
        if judge=="AC":
            ans[0]+=1
            ans[1]+=l[num]
            l[num]=-1
        else:
            l[num]+=1
    

print(*ans)    

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 40) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r, g, b, n;
    cin >> r >> g >> b >> n;
    ll ans = 0;
    for(ll i = 0; i <= n; i++) {
        for(ll j = 0; j <= n; j++) {
            if(n - i * r - j * g >= 0 && (n - i * r - j * g) % b == 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define re(n) for (int i = 0; i < (n); ++i)
#define rej(n) for (int j = 0; j < (n); ++j)

using namespace std;

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

const ld PI = acos((ld)-1);

int main() {
    #ifndef LOCALDEBUG
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #endif  // LOCALDEBUG
    int n;
    cin >> n;
    vii a(n);
    re(n) {
        cin >> a[i].fi;
        a[i].se = i + 1;
    }
    sort(all(a));
    re(n) {
        cout << a[i].se << " ";
    }
    return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(std::string C){
    char c=C[0]+1;
    cout<<c<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    std::string C;
    std::cin >> C;
    solve(C);
    return 0;
}


Measured memory_bytes: 256
import numpy as np
A = np.array([int(input()) for _ in range(5)]).reshape(-1,1)
A = np.array(A).reshape(-1,1)
A = np.c_[A, (10 - A % 10) * (A % 10 != 0)]
print(sum(A.reshape(-1))-max(A[:,1]))

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t a, b, c, d;
    cin >> a >> b >> c >> d;

    auto e = c - a;
    auto f = d - b;

    constexpr auto M = 998244353L;

    vector dp(f + 1, 0L);
    dp[0] = 1;
    for (auto i : irange(1L, f + 1)) {
        dp[i] = dp[i - 1] * a % M;
    }

    for (auto i : irange(a, c)) {
        for (auto j : irange(0L, f + 1)) {
            dp[j] *= b + j;
            dp[j] %= M;
        }

        vector dp2(f + 1, 0L);
        for (auto j : irange(1L, f + 1)) {
            dp2[j] = dp[j - 1];
        }

        for (auto j : irange(1L, f + 1)) {
            dp2[j] += dp2[j - 1] * (i + 1) % M;
            dp2[j] %= M;
        }

        for (auto j : irange(0L, f + 1)) {
            dp[j] += dp2[j];
            dp[j] %= M;
        }
    }

    cout << dp[f] << endl;
}

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

int main()
{
	int sum = 0, a = 100, b = 100;
	for (int i = 0; i < 4; i++) {
		int tmp;
		cin >> tmp;
		a = min(a, tmp);
		sum += tmp;
	}
	for (int i = 0; i < 2; i++) {
		int tmp;
		cin >> tmp;
		b = min(b, tmp);
		sum += tmp;
	}
	cout << sum - a - b << endl;
	return 0;
}



Measured memory_bytes: 3092
import itertools
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


# 色のパターン 30*29*28 == 24360
# 全部試すだけ

N, C = list(map(int, sys.stdin.buffer.readline().split()))
D = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(C)]
S = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]

D = np.array(D, dtype=int)
S = np.array(S, dtype=int) - 1

md = np.zeros((N, N), dtype=int)
md += np.arange(N, dtype=int)
md += np.arange(N, dtype=int)[:, None]
md %= 3

# s += D[S[md == 0], colors[0]].sum()
# s += D[S[md == 1], colors[1]].sum()
# s += D[S[md == 2], colors[2]].sum()

# costs[d][c]: md == d の場所を c に変えるときのコスト
costs = [[0] * C for _ in range(3)]
for d in range(3):
    for c in range(C):
        # md == d の場所を c に変えるときのコスト
        costs[d][c] = D[S[md == d], c].sum()

ans = INF
for colors in itertools.permutations(range(C), r=3):
    ans = min(ans, costs[0][colors[0]] + costs[1][colors[1]] + costs[2][colors[2]])
print(ans)


Measured memory_bytes: 18560
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  rep (i, n-1) {
    if (s.substr(i, 2) == "AC") {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 888
import copy

def j(n):
    if n:print("yes")
    else:print("no")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

n = ip()
a = iprow()
s = 0
for i in range(n-1):
    for k in range(i+1,n):
        s+=a[i]*a[k]
print(s)

Measured memory_bytes: 3444
N, M = map(int, input().split())
A, B, C = [], [], []
for i in range(M):
    a, b, c = map(int, input().split())
    A.append(a - 1)
    B.append(b - 1)
    C.append(c)

d = [[float('inf') if i != j else 0 for i in range(N)] for j in range(N)]

for i in range(M):
    d[A[i]][B[i]] = min(d[A[i]][B[i]], C[i])
    d[B[i]][A[i]] = min(d[B[i]][A[i]], C[i])

for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = M
for i in range(M):
    flag = False
    for j in range(N):
        if d[j][A[i]] + C[i] == d[j][B[i]]:
            flag = True
    if flag:
        ans -= 1

print(ans)


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

signed main(void)
{
	vector<int> v(5), s(5);
	pair<int, int> tmp;
	int now;

	tmp.first = 9;
	tmp.second = 4;
	rep(i, 5)
	{
		cin >> v.at(i);
		if (v[i] % 10 != 0)
		{
			if (tmp.first > v[i] % 10)
			{
				tmp.first = v[i] % 10;
				tmp.second = i;
			}
		}
	}
	swap(v.at(tmp.second),v.at(4));
	now = v.at(0);
	rep(i, 4)
	{
		if (now % 10 != 0)
			now += (10 - now % 10);
		now += v.at(i + 1);
	}
	cout << now << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input().strip())
    L = list(map(int, input().strip().split()))
    
    rem=sum(L)
    cur=1
    ans=0
    for i in range(n+1):
        ans+=cur
        rem-=L[i]
        cur-=L[i]
        if cur<0 or cur==0 and i!=n:
            print(-1)
            return
        if cur<rem:
            cur=min(cur*2,rem)
            
    print(ans)

if '__main__' == __name__:
    main()


Measured memory_bytes: 20144
A,B,C = map(int, input().split())

list_iroha = [A,B,C]

#print(list_iroha)
if [5,7,5] == list_iroha or [7,5,5] == list_iroha or [5,5,7] == list_iroha:
  print("YES")
else:
  print("NO")

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

map<int, int>mp;
int n, m, k;
void solve(int p, int s) {
	if (p == n) {
		mp[max(1, s - k)]++; return;
	}
	for (int i = 1; i <= m; i++)solve(p + 1, s + i);
}
int main() {
	while (scanf("%d%d%d", &n, &m, &k), n) {
		mp.clear(); solve(0, 0);
		int sum = 0;
		for (auto p : mp)sum += p.second;
		double ans = 0;
		for (auto p : mp)ans += p.first*p.second / (double)sum;
		printf("%.10lf\n", ans);
	}
}

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

int main(){
	int N,L;
	cin>>N>>L;
	
	string S[N];
	for(int i=0;i<N;i++)
		cin>>S[i];
	
	sort(S,S+N);
	
	for(int i=0;i<N;i++){
		cout<<S[i];
	}
	
	return 0;
	
}

Measured memory_bytes: 256
#include <stdio.h>

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

Measured memory_bytes: 580
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let s: String = scan(tokens);
    let s = s.into_bytes();
    let mut ans = 0;
    let mut z: Vec<usize> = vec![0; n + 1];
    for i in 0..n {
        let mut j = i;
        let mut k = i + 1;
        z[k] = j - i;
        while k < n {
            if s[j] == s[k] {
                j += 1;
                k += 1;
                z[k] = j - i;
            } else if j == i {
                k += 1;
                z[k] = 0;
            } else {
                j = i + z[j];
            }
        }
        j = i;
        k = i + 1;
        while k < n {
            if j == k - j + i {
                j = i + z[j];
            } else if s[j] == s[k] {
                j += 1;
                k += 1;
                ans = std::cmp::max(ans, j - i);
            } else if j == i {
                k += 1;
            } else {
                j = i + z[j];
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long int
#define ull unsigned long long
#define pb push_back
#define mk make_pair
#define flp(i, k, n) for(int i=k; i<n; i++)
#define F first
#define S second


int32_t main(void)
{
    
    ull n, k;
    cin>>n>>k;
    cout<<min(n%k, k-(n%k))<<"\n";
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::max;
use std::io;

fn main() {
    let input = input_number();
    let n = input[0] as usize;
    let w = input[1] as usize;
    let input = (0..n).map(|_| input_number()).collect::<Vec<Vec<i64>>>();
    let ws: Vec<i64> = input.iter().map(|x| x[0]).collect();
    let vs: Vec<i64> = input.iter().map(|x| x[1]).collect();

    let mut dp = vec![vec![0; 100100]; 110];

    for i in 0..n {
        for j in 0..w + 1 {
            if j >= ws[i] as usize {
                let right = dp[i][j - ws[i] as usize] + vs[i];
                update(&mut dp[i + 1][j], right);
            }
            let right = dp[i][j];
            update(&mut dp[i + 1][j], right);
        }
    }
    println!("{}", dp[n][w]);
}

#[allow(dead_code)]
fn update<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn input_number() -> Vec<i64> {
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<i64> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap_or(0))
        .collect();
    vec
}

#[allow(dead_code)]
fn input() -> (char, usize) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: char = iter.next().unwrap().chars().nth(0).unwrap();
    let n: usize = iter.next().unwrap().parse().unwrap();
    (c, n)
}


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

typedef long long ll;
int n;
ll a[100005],x,Out;

int main(){
	cin>>n>>x;
	for(int i = 1; i <= n; i++) cin>>a[i];
	for(int i = 1; i <= n; i++){
		if(a[i] + a[i - 1] > x){
			ll t = a[i] + a[i - 1] - x;
			Out += t;
			a[i] -= t;
		}
	}
	cout<<Out<<endl;
	return 0;
} 

Measured memory_bytes: 1024
use std::cmp::min;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let nt:Vec<i64> = read_vec();
    let tn:Vec<i64> = read_vec();
    let ans = (0..nt[0]-1).fold(nt[1],|x,y| {
        let sub = (tn[(y+1) as usize]- tn[y as usize]).abs();
        x + min(nt[1],sub)
    });
    println!("{}",ans);
}

Measured memory_bytes: 8444
#include<bits/stdc++.h>
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define su(x) scanf("%u",&x)
#define sl(x) scanf("%ld",&x)
#define sli(x) scanf("%lld",&x)
#define slii(x,y) scanf("%lld %lld",&x,&y)
#define sliii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define slu(x) scanf("%llu",&x)
#define sf(x) scanf("%f",&x)
#define slf(x) scanf("%lf",&x)
#define slff(x,y) scanf("%lf %lf",&x,&y)
#define slfff(x,y,z) scanf("%lf %lf %lf",&x,&y,&z)
#define sc(x) scanf("%c",&x)
#define ss(x) scanf("%s",x)
#define pf printf
#define fpf fprintf
#define pb push_back
#define f(i,x,y,z) for(int i=x;i<y;i=i+z)
#define f1(i,x,y,z) for(int i=x;i>y;i=i-z)
#define MAX (int)(1e9)
#define pi 2*acos(0)
#define mp make_pair
#define M 1000000007
#define xx first
#define yy second
#define N (int)(2e5 + 5)
#define vc vector
#define pq priority_queue
#define Q queue
#define E 100005
#define logn 16

using namespace std;

typedef long long int ll;

int a[N];

int main(){
    int n, i;
    scanf("%d",&n);
    for(i = 0; i<n; i++){
        scanf("%d",&a[i]);
        if(a[i]>i || (i>0 && a[i]>a[i-1]+1)){
            printf("-1\n");
            return 0;
        }
    }
    ll ans = 0;
    for(i = n-1; i>=0; i--){
        if(a[i]+1==a[i+1]) continue;
        ans += a[i];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
int n,m,num;
vector<int>s[105];
void work(int n)
{
	for(int i=1;i<=n/2;i++)
	{
		s[++num].push_back(i);
		s[num].push_back(n-i+1);
	}
}
int main()
{
	scanf("%d",&n);
	if(n&1)
	{
		work(n-1);
		s[++num].push_back(n);
		printf("%d\n",(n-1)*(n-3)/2+n-1);
	}
	else
	{
		work(n);
		printf("%d\n",n*(n-2)/2);
	}
	for(int i=1;i<=num;i++)
	for(int j=0;j<s[i].size();j++)
	{
		for(int k=i+1;k<=num;k++)
		for(int l=0;l<s[k].size();l++)
		  printf("%d %d\n",s[i][j],s[k][l]);
	}
	return 0;
}

Measured memory_bytes: 256
// D - Digits Parade

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

const int MOD = 1e9 + 7;

// dp[i][j]: 左からi文字で構成される整数を13で割った余りがjであるものの数
ll dp[100005][13];

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}

	return -1;
}

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

	int N = S.size();

	// 左からi+1文字で構成される整数 % 13
	// = （左からi文字で構成される整数を13で割った余り * 10 + 左からi+1文字目の数字） % 13
	// 参考） http://9871225.blog.fc2.com/blog-entry-310.html

	dp[0][0] = 1;
	for (int i=0; i<N; i++) {
		if (S[i] != '?') {
			int c = ctoi(S[i]);

			for (int j=0; j<13; j++) {
				dp[i+1][(j * 10 + c) % 13] += dp[i][j];
			}
		} else {
			// S[i] == '?' の時は0-9全ての数字の場合を考える
			for (int c=0; c<10; c++) {
				for (int j=0; j<13; j++) {
					dp[i+1][(j * 10 + c) % 13] += dp[i][j];
				}
			}
		}

		for (int j=0; j<13; j++) {
			dp[i+1][j] %= MOD;
		}
	}

	int ans = dp[N][5];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10624
a = [[]]*3
for i in range(3):
  a[i] = list(map(int, input().split()))

cnt = 0
for i in range(1,5):
  tmp = 0
  for j in range(3):
    tmp += a[j].count(i) 
  if tmp == 2:
    cnt += 1

if cnt == 2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
	int i = 1;
	int j;
	while(1){
		scanf("%d",&j);
		if(j == 0){
			break;
		}
		printf("Case %d: %d\n", i, j);
		i = 1+i;
	}
	
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

	vector<int> d(N);
	rep(i, N)
	{
		cin >> d[i];
	}

	ll ans = 0;
	rep(i, N)
	{
		for (auto j = i + 1; j < N; j++)
		{
			ans += (ll)d[i] * d[j];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){

int i,n,t=0,h=0;
string tc,hc;

cin>>n;

for(i=0; i<n; i++){

cin>>tc>>hc;

if(tc>hc)t+=3;
else if(tc<hc)h+=3;
else{
t++;
h++;
}

}

cout<<t<<" "<<h<<"\n";

}

Measured memory_bytes: 1208
//fifer a tak luboin
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;

#define pb push_back
#define endl "\n"

// using namespace __gnu_pbds;
using namespace std;
// template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
    // freopen("input.in.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    int k = (n + 999) / 1000;
    cout << k * 1000 - n << endl; 
    return 0;  
}


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

int main(){
    int n, m, x, y; cin >> n >> m >> x >> y;
    vector<int>X(n), Y(m);
    for(int i=0;i<n;i++){
        cin >> X.at(i);
    }
    for(int j=0;j<m;j++){
        cin >> Y.at(j);
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    bool isWar = false;
    for(int i=x+1;i<=y;i++){
        if(X.at(n-1) < i){
            isWar = false;
            if(Y.at(0) >= i){
                isWar = false;
            }
            else{
                isWar = true;
            }
        }
        else{
            isWar = true;
        }
        if(!isWar){
            break;
        }
    }

    if(!isWar) cout << "No War" << endl;
    else cout << "War" << endl;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

const int mod = 1e9+7;

template< int mod >
struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int) (1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

void solve() {
    using mi = ModInt<mod>;
    int N; cin >> N;

    mi  sum;
    vector<int> inp(N);
    REP(i,N) {
        cin >> inp[i];
        sum += mi(inp[i]);
    }

    mi ans;
    REP(i,N-1) {
        sum -= mi(inp[i]);
        ans += mi(sum*mi(inp[i]));
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 4012
#include<stdio.h>
#include<stdlib.h>
#define mymalloc(p,n) {p = malloc((n)*sizeof(*p));if ((p)==NULL) {printf("not enough memory?\n"); exit(1);};}

typedef struct {
	int key;
	char suits;
}obj;

obj *readObj(int *num){
	int i;
	obj *A;
	scanf("%d",num);
	mymalloc(A,*num);
	for(i=0;i<*num;i++){
		scanf(" %c%d ",&A[i].suits,&A[i].key); //scanf???????§????????????\???????????¨????????????
	}
	return A;
}

void printObj(obj *A,int num){
	int i;
	for(i=0;i<num;i++){
		printf("%c%d",A[i].suits,A[i].key);
		if(i<num-1){printf(" ");}
	}
	printf("\n");
}

obj *duplicate(obj *A,int num){
	int i;
	obj *B;
	mymalloc(B,num);
	for(i=0;i<num;i++){
		B[i]=A[i];
	}
	return B;
}

void swapIJ(obj *a, obj *b){
	obj temp;
	temp=*a;
	*a=*b;
	*b=temp;
}

void bubbleSort(obj *A,int num){
	int i,j;
	for(i=0;i<num;i++){
		for(j=num-1;j>i;j--){
			if(A[j].key<A[j-1].key){
				swapIJ(&A[j],&A[j-1]);
			}
		}
	}
}

int selecSort(obj *A,int num){
	int i,j,k,mini,idx,frag;
	char seq[10][4];
	int count[10];
	for(i=1;i<10;i++){
		count[i]=0;
		for(j=0;j<4;j++){
			seq[i][j]='a';
		}
	}
	for(i=0;i<num;i++){
		mini=i;
		for(j=i+1;j<num;j++){
			if(A[j].key<A[mini].key){mini=j;}
			if(A[j].key==A[i].key&&count[A[j].key]!=-1){
				idx=A[j].key;
				if(count[idx]==0){seq[idx][0]=A[i].suits;count[idx]++;}
				seq[idx][count[idx]]=A[j].suits;count[idx]++;
			}
		}
		for(j=0;j<10;j++){
			if(count[j]>0){count[j]=-1;}
		}
		if(i!=mini){
			swapIJ(&A[i],&A[mini]);
		}
	}
	
	frag=0;
	for(i=1;i<10;i++){
		if(count[i]==-1){
			j=0;k=0;
			while(A[j].key!=i&&j<num){
				j++;
			}
			while(seq[i][k]!='a'&&k<4){
				if(seq[i][k]!=A[j+k].suits){
					frag=1;break;
				}
				k++;
			}
		}
		if(frag==1){break;}
	}
	return frag;
}

main(){
	obj *A,*B;
	int i,j,k,num,frag;
	A=readObj(&num);
	B=duplicate(A,num);
	
	bubbleSort(A,num);
	printObj(A,num);
	printf("Stable\n");
	
	frag=selecSort(B,num);
	printObj(B,num);
	if(frag==0){
		printf("Stable\n");
	}
	else{
		printf("Not stable\n");
	}
	
	return 0;
}

Measured memory_bytes: 616
s=input()
n=int(input())
ss=[]
for i in range(len(s)):
  for j in range(5):
    ss.append(s[i:i+j+1])
ss.sort()

kk=1
for i in range(len(ss)):
  if kk==n:
    print(ss[i])
    break
  if ss[i]!=ss[i+1]:
    kk+=1

Measured memory_bytes: 4340
#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}, {-1,1}, {-1,-1} };

int n,k;
int liczby[555];
LL sum = 0;

vector<LL> ans;
LL acc = 0;
bool compare_me(int i1, int i2) 
{ 
    return ((i1%acc) < (i2%acc)); 
} 

void licz(LL liczba) {
	//cout<<"liczba : "<<liczba<<endl;
	acc = liczba;
	//sortuj wedle pozostalosci
	sort(liczby, liczby+n, compare_me);
	//policz roznice
	LL roznica = 0;
	F(i,0,n) {
		roznica += (liczby[i] % liczba);
	}
	LL brak = 0;
	F(i,0,n) {
		brak += liczba - (liczby[i] % liczba);
	}

	//cout<<"BRAK " <<brak<<endl;
	int idx = 0;
	LL ile = 0;
	while(brak > 0) {
		ile += (liczby[idx]%liczba);
		brak -= liczba-(liczby[idx]%liczba);
		brak -= liczby[idx++]%liczba;
		//cout<<"BRAK " <<brak<<endl;
	}

	if(ile <= k && brak == 0) {
		ans.push_back(liczba);
	}

}

void dane() {
	cin>>n>>k;
	F(i,0,n) {
		cin>>liczby[i];
		sum+=liczby[i];
	}

	for(int i = 1; i*i <= sum ; i++) {
		if(sum % i == 0) {
			//znajdz dla I oraz sum/I;
			licz(i);
			licz(sum/i);
		}
	}

	// F(i,0,ans.size()) {
	// 	cout<<"ANS : "<<ans[i]<<endl;
	// }
	sort(ALL(ans));
	cout<<ans[ans.size()-1]<<endl;

}

int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
if a+b-1>n:exit(print(-1))
if a*b<n:exit(print(-1))
ans=[]
c=0
nn=n
for i in range(a):
  ans.append([])
  t=0--nn//(a-i)
  if i==0:
    t=b
  nn-=min(t,b)
  for j in range(min(b,t)):
    ans[-1].append((i+1)*b-j)
    c+=1
    if c==n:break
  if c==n:break
anss=[]
for i in ans:anss+=i
def position_zip(a,flag):
  j=1
  d={}
  for i in sorted(a):
    if i in d:continue
    d[i]=j
    j+=1
  if flag==1:return d
  return [d[i] for i in a]
print(*position_zip(anss,0))

Measured memory_bytes: 198880