akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll ar[5];
    for(ll i=0;i<5;i++)
    {
        cin>>ar[i];
    }
    ll cnt=0;

    for(ll i=0;i<5;i++)
    {
        if(ar[i]==0)
        {
            cout<<i+1<<endl;
            break;

        }
    }
   // cout<<f<<endl;
    return 0;

}


Measured memory_bytes: 3548
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<queue>
#include<utility>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	a=a*a;
	a=a*3;
	cout<<a;
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll X,K,D;
    cin >> X >> K >> D;
    X = abs(X);
    ll minX = X % D;
    ll tc = X / D;
    ll cnt = min(tc,K);
    ll nowX = X - cnt*D;
    ll d = K - cnt;
    if(d % 2 == 0){
        cout << abs(nowX) << endl;
    } else {
        cout << abs(nowX - D) << endl;
    }
}

Measured memory_bytes: 3600
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace abc144
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_abc144C();
        }

        public static void solve_abc144C()
        {
            long n = Convert.ToInt64(Console.ReadLine());

            long t = n;
            long min = long.MaxValue;
            for (long i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    long d = n / i;
                    min = Math.Min(min, d - 1 + i - 1);
                }
            }

            Console.WriteLine(min == long.MaxValue ? n - 1 : min);
        }

        public static long gcd(long a, long b)
        {
            if (b == 0)
            {
                return a;
            }
            else
            {
                return gcd(b, a % b);
            }
        }

        public static void solve_abc144B()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= 9; j++)
                {
                    if (i * j == n)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }
            Console.WriteLine("No");
        }

        public static void solve_abc144A()
        {
            int[] ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            int a = ab[0];
            int b = ab[1];

            Console.WriteLine(a < 10 && b < 10 ? a * b : -1);
        }

        /*
            BinarySearchIterativeLeft
         */
        public static int binarySearchIterativeLeft(long[] haystack, long needle)
        {
            int left = -1;
            int right = haystack.Length;
            while (left < right - 1)
            {
                int middle = left + (right - left) / 2;
 
                if (haystack[middle] < needle)
                {
                    left = middle;
                }
                else
                {
                    right = middle;
                }
            }
 
            return right;
        }
        
        public static int binSearch(int[] haystack, int needle)
        {
            int l = -1;
            int r = haystack.Length;
            while(l < r - 1)
            {
                int mid = (r + l) / 2;
                if (haystack[mid] <= needle)
                {
                    l = mid;
                }
                else 
                {
                    r = mid;
                }
            }
 
            return r;
        }                        
    }
}


Measured memory_bytes: 11220
import numpy as np
h, w = list(map(int, input().split()))
loc_array = [list(input().replace("#", "1").replace(".", "0")) for _ in range(h)]
loc_array = np.array([list(map(int, l)) for l in loc_array])
row_sum = loc_array.sum(axis=1)
col_sum = loc_array.sum(axis=0)
while 0 in row_sum or 0 in col_sum:
  row_rm = [i for i, r in enumerate(row_sum) if r == 0]
  loc_array = np.delete(loc_array, row_rm, axis=0)
  col_rm = [i for i, c in enumerate(col_sum) if c == 0]
  loc_array = np.delete(loc_array, col_rm, axis=1)
  row_sum = loc_array.sum(axis=1)
  col_sum = loc_array.sum(axis=0)

loc_str = [list(map(str, loc_array[i,:])) for i in range(loc_array.shape[0])]
loc_str = ["".join(l).replace("1", "#").replace("0", ".") for l in loc_str]
for l in loc_str:
  print(l)


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

#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e7;
const int maxn = 2e3 + 5;
ll mod = 1e9 + 7;

map<ll,ll> f;

int main()
{
	int n; ll sum = 0, ans = 0, x;
	scanf("%d", &n);
	f[0] = 1;
	while (n--)
	{
		scanf("%lld", &x);
		sum += x;
		ans += f[sum];
		++f[sum];
	}
	printf("%lld", ans);
}

Measured memory_bytes: 12800
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,m;
	cin>>n>>m;
	string s(n,' ');
	while(m--){
		int a,b;
		cin>>a>>b;
		if(s[a-1]!=' '&&s[a-1]-'0'-b){
			cout<<-1<<endl;
			return 0;
		}
		s[a-1]='0'+b;
	}
	if(n-1&&s[0]=='0'){
		cout<<-1<<endl;
		return 0;
	}
	if(s[0]==' '){
		if(n==1)s[0]='0';
		else s[0]='1';
	}
	rep(i,n)if(s[i]==' ')s[i]='0';
	cout<<s<<endl;
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second
using ll = long long;
using P = pair<ll ,ll>;
//using Tu = tuple<ll, ll, ll>;
const ll INF = 1LL<<61LL;
const ll MOD = 1e9+7;



using ld = long double;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

int main(){
  ll N, M;
  cin >> N >> M;
  vector<vector<ll> > dp(N+100, vector<ll>(10, -INF));
  dp[0] = vector<ll>(10, 0);
  vector<ll> a(M);
  vector<ll> cost{0,2,5,5,4,5,6,3,7,6};
  for(int i=0;i<M;i++)
    cin >> a[i];
  for(int f=0;f<N;f++){
    for(int i=0;i<M;i++){
      auto tmp = dp[f];
      tmp[0]++;
      tmp[10-a[i]]++;
      dp[f + cost[a[i]]] = max(dp[f + cost[a[i]]], tmp);
    }
  }
  for(int i=1;i<10;i++)
    cout << string(dp[N][i], '0' + 10 - i);
  cout << endl;
}


Measured memory_bytes: 1408
def solve(string):
    n, s = string.split()
    num_e = s.count("E")
    count_e = count_w = 0
    ans = int(n)
    for _s in s:
        tmp = count_w
        if _s == "E":
            count_e += 1
        else:
            count_w += 1
        tmp += num_e - count_e
        ans = min(ans, tmp)
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define ll long long
#define int ll
#define rgi register int
#define rgl register ll
#define maxn 1000005
#define mod 1000000003
#define inf 1000000007
namespace lib
{
	using namespace std;
	
	
	class fastio
	{
		private:
			#define _NUMLEN 111
			char _num[_NUMLEN],_ch;
			int _f,_head;
			bool _useSTD;
		public:
			inline void ioSTD()
			{
				_useSTD=1;
				ios::sync_with_stdio(false);
				cin.tie(0),cout.tie(0);
			}
			inline void gc(char & _c)
			{
				if(_useSTD)cin>>_c;
				else _c=getchar();
			}
			inline void pc(char _c)
			{
				if(_useSTD)cout<<_c;
				else putchar(_c);
			}
			template<typename _T> inline fastio & operator - (_T & _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_x=0;
					while(!isdigit(_ch)) _f|=_ch=='-',gc(_ch);
					while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),gc(_ch);
					_f&&(_x=-_x,_f=0);
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator + (_T _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_T _k;
					if(_x==0) {pc('0'),pc(' ');return *this;}
					if(_x<0) pc('-'),_x=-_x;
					while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
					while(_head>0) pc(_num[_head]),--_head;
					pc(' ');
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator >> (_T & _x) {cin>>_x;return *this;}
			template<typename _T> inline fastio & operator << (_T _x) {cout<<_x;return *this;}
			#define endln pc('\n')
		fastio() {_f=0,_head=0,_useSTD=0,_ch=' ';}
	}io;
	
	
	inline void fileio(string _r,string _w)
	{
		if(_r[0]!='-')freopen(_r.c_str(),"r",stdin);
		if(_w[0]!='-')freopen(_w.c_str(),"w",stdout);
	}
}using namespace lib;

signed main()
{
//	fileio("tt.in","tt.out");
//	io.ioSTD();
	ll a,ans=0;
	io-a;
	if(a&1)io+0;
	else
	{
		for(rgl t=10;t<=a;t*=5)ans+=(a/t);
		io+ans;
	}
	return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

def lcm(a, b):
    return a * b // gcd(a, b)

n = int(input())
t = [int(input()) for i in range(n)]

ans = 1

for i in range(n):
  ans = lcm(ans, t[i])
  
print(ans)

Measured memory_bytes: 3188
/*---------------------------------------------*/
/*
    ABC174 D
 */
/*---------------------------------------------*/

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

int main() {
    int64_t n;
    cin >> n;
    string s;
    cin >> s;
    
    int64_t ans = 0;
    int64_t r = n-1;
    rep(i, s.length()) {
        if ( s[i] == 'R' ) continue;
        while( r>=0 && s[r]=='W' ) {
            r--;
        }
        if(i<r){
            swap(s[i],s[r]);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3740
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
typedef long long int lint;
using namespace std;
priority_queue <lint> pq;



int main(){
    lint n,m;
    cin>>n>>m;
    for(lint i=0;i<n;i++){
        int x;
        cin>>x;
        pq.push(x);
    }
    while(m--){
    lint k=pq.top();
    pq.pop();
    k/=2;
    pq.push(k);
	
    }
    lint topp=0;
    while(!(pq.empty())){
        topp+=pq.top();
        pq.pop();
    }
    cout<<topp;


   




   

    return 0;
}

Measured memory_bytes: 1400
a,b=map(int,input().split())
x=[]
y=[]
if a%2==0:
    x.append(25*a//2)
    x.append((25*a+24)//2)
    y.append(10*b)
    y.append(10*b+9)
    if x[1]<y[0] or y[1]<x[0]:
        print(-1)
    else:
        print(max(x[0],y[0]))
else:
    x.append(25 * a // 2+1)
    x.append((25 * a + 24) // 2)
    y.append(10 * b)
    y.append(10 * b + 9)
    if x[1] < y[0] or y[1] < x[0]:
        print(-1)
    else:
        print(max(x[0], y[0]))

Measured memory_bytes: 3188
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
 


int main(){
     
    string str;
    int first=0,last;
       
    cin>>str;
    last=str.size()-1;
    while(1){
        if(str[first]=='A')break;
        first++;
    }
    while(1){
        if(str[last]=='Z')break;
        last--;
    }
    cout<<last-first+1<<endl;
    
     
    return 0;
}
 

Measured memory_bytes: 640
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int primax = 10000000;
		int[] pri = new int[primax+10000];
		for(int i=2;i<=primax;i++) pri[i] = i;
		for(int i=2;i<=primax+1;i++){
			for(int j=i+i;j<=primax;j+=i){
					pri[j]=0;
			}
		}

		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			for(int i=n;;i--){
				if(pri[i]>0 && pri[i-2]>0 && pri[i-6]>0 && pri[i-8]>0){
					System.out.println(i);
					break;
				}
			}
		}
	}
	
}

Measured memory_bytes: 63324
#include <bits/stdc++.h>
using namespace std;
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_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))

int N;
vector<int> a;

constexpr int INF = 10000000;

bool is_eq_greater(int val)
{
    vector<int> v(2 * N - 1);
    REP(i, 2 * N - 1) v[i] = (a[i] >= val);
    {
        bool flg = true;
        REP(i, N) if (!v[i * 2]) flg = false;
        if (flg) return true;
    }
    if (!v[N - 1] and !v[N]) return false;
    if (!v[N - 1] and !v[N - 2]) return false;

    int r2 = -1, l2 = -1, r1 = N - 1, l1 = N - 1;
    REP(k, N - 1)
    {
        if (v[N - 1 + k] + v[N - 1 + k + 1] == 0) break;
        r1 = N - 1 + k;
        if (v[N - 1 + k] + v[N - 1 + k + 1] == 2) { r2 = N - 1 + k + 1; break; }
    }
    REP(k, N - 1)
    {
        if (v[N - 1 - k] + v[N - 1 - k - 1] == 0) break;
        l1 = N - 1 - k;
        if (v[N - 1 - k] + v[N - 1 - k - 1] == 2) { l2 = N - 1 - k - 1; break; }
    }
    if (l2 >= 0 and r2 >= 0) return true;
    if (l2 < 0 and r2 >= 0 and (l1 + r1) / 2 <= N - 1) return true;
    if (r2 < 0 and l2 >= 0 and (l1 + r1) / 2 >= N - 1) return true;
    return false;
}


int main()
{
    cin >> N;
    a.resize(2 * N - 1);
    cin >> a;

    int L = 1, R = N * 2 + 1; // [L, R)
    while (R - L > 1)
    {
        int C = (L + R) / 2;
        (is_eq_greater(C) ? L : R) = C;
    }
    cout << L << endl;
}


Measured memory_bytes: 1920
/*
 * Matheus Oliveira
 * 09:17:32 02/05/2020
 * b.cpp
*/

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

#define EPS
#define INF
#define MAXN
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define sc(x) scanf("%d", &x);
#define sc2(x, y) scanf("%d %d", &x, &y);
#define sc3(x, y, z) scanf("%d %d %d", &x, &y, &z);
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, bg, ed) printf("%s: ", #x); for(int i = bg; i < ed; i++) printf("%d%c", x[i], (i == ed-1) ? '\n' : ' ');

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int main() {
	double aux;
	int cnt = 0;

	ll x, val = 100;
	scanf("%lld", &x);
	
	while(val < x) {
		aux = ((double) val) / 100.0;
		aux = floor(aux);

		val += ((ll) aux);
		cnt++;

		//printf("val: %lld\n", val);
	}

	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 3824
n,m = map(int, input().split())
h = list(map(int, input().split()))
road_list = [list(map(int, input().split()))]
for _ in range(m-1):
    road_list.append(list(map(int,input().split())))

lower_set = set()
for road in road_list:
    if h[road[0]-1] >= h[road[1]-1]:
        lower_set.add(road[1]-1)
        
    if h[road[0]-1] <= h[road[1]-1]:
        lower_set.add(road[0]-1)

count = 0
for i in range(n):
    if not i in lower_set:
        count += 1

print(count)


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

int main() {

	unsigned long long H;
	cin >> H;

	unsigned long long cnt = 0;
	unsigned long long ans = 1;
	while (H > 1) {
		H = H / 2;
		cnt += 1;
		ans += pow(2, cnt);
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
import           Control.Applicative
import           Data.List

newtype Dice =
    Dice [Int]
    deriving (Eq, Show)

dice :: Dice
dice = Dice [0,1,2,3,4,5]

roll :: Char -> Dice -> Dice
roll 'E' (Dice ds) = Dice [ds !! (i-1) | i <- [4,2,1,6,5,3]]
roll 'N' (Dice ds) = Dice [ds !! (i-1) | i <- [2,6,3,4,1,5]]
roll 'S' (Dice ds) = Dice [ds !! (i-1) | i <- [5,1,3,4,6,2]]
roll 'W' (Dice ds) = Dice [ds !! (i-1) | i <- [3,2,6,1,5,4]]

main :: IO ()
main = do
    xs <- fmap read . words <$> getLine :: IO [Int]
    cs <- getLine :: IO [Char]
    let ds = foldl' (\d f -> f d) dice (fmap roll cs)
    case ds of
        Dice (a:as) -> print (xs !! a)



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

int main() {
  string s;
  int N;
  cin >> s;
  N = s.size();
  N = N - 2;
  while (N > 0) {
    for (int i=0; i<N/2; i++) {
      if (s[i] != s[i+N/2]) {
        N -= 2;
        break;
      }
      if (i == N/2-1) {
        cout << N << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static final int SIZE = 40;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] lefts = new int[m];
		int[] rights = new int[m];
		for (int i = 0; i < m; i++) {
		    lefts[i] = sc.nextInt() - 1;
		    rights[i] = sc.nextInt() - 1;
		}
		long[] values = new long[m];
		UnionFindTree uft = new UnionFindTree(n);
		for (int i = m - 1; i >= 0; i--) {
		    values[i] = uft.getValue();
		    uft.unite(lefts[i], rights[i]);
		}
		StringBuilder sb = new StringBuilder();
		for (long x : values) {
		    sb.append(x).append("\n");
		}
		System.out.print(sb);
    }
    
    static class UnionFindTree {
        int[] parents;
        int[] counts;
        long value2;
        
        public UnionFindTree(int size) {
            parents = new int[size];
            counts = new int[size];
            value2 = 0;
            for (int i = 0; i < size; i++) {
                parents[i] = i;
                counts[i] = 1;
                value2 += size - 1;
            }
        }
        
        public int find(int x) {
            if (parents[x] == x) {
                return x;
            } else {
                return parents[x] = find(parents[x]);
            }
        }
        
        public void unite(int x, int y) {
            int xx = find(x);
            int yy = find(y);
            if (xx == yy) {
                return;
            }
            long size = parents.length;
            value2 -= (size - counts[xx]) * counts[xx] + (size - counts[yy]) * counts[yy];
            parents[xx] = yy;
            counts[yy] += counts[xx];
            value2 += (size - counts[yy]) * counts[yy];
        }
        
        public long getValue() {
            return value2 / 2;
        }
    }
}



Measured memory_bytes: 86684
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N = (1 << 18) + 1;
typedef pair<int, int> P;
int d[N];
P f[N];

P merge(P A, P B) {
  if(A.fi < B.fi) swap(A, B);
  return P(A.fi, max(A.se, B.fi));
}

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 0; i < (1 << n); ++i) {
    scanf("%d", &f[i].fi);
    f[i].se = 0;
  }
  for(int i = 1; i < (1 << n); i <<= 1) {
    for(int j = 1; j < (1 << n); ++j) {
      if(i & j) {
        f[j] = merge(f[j], f[j ^ i]);
      }
    }
  }
  for(int i = 1; i < (1 << n); ++i) {
    d[i] = max(d[i - 1], f[i].fi + f[i].se);
    printf("%d\n", d[i]);
  }
  return 0;
}

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

using namespace std;

#define ll long long

int main() {
    int a = 0, mx = 0;
    string x;
    cin >> x;
    for (int i = 0; i < x.length(); i++) {
        if (x[i] == 'R') {
            a++;
            if (a > mx) {
                mx = a;
            }
        } else {
            a = 0;
        }
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int H, W, N;
	int min_x, min_y, max_x, max_y;
	cin >> W >> H >> N;
	min_x = min_y = 0;
	max_x = W;
	max_y = H;

	for (int i = 0; i < N; i++)
	{
		int x, y, a;
		cin >> x >> y >> a;
		switch (a)
		{
		case 1:
			min_x = max(x, min_x);
			break;
		case 2:
			max_x = min(x, max_x);
			break;
		case 3:
			min_y = max(y, min_y);
			break;
		case 4:
			max_y = min(y, max_y);
			break;
		}
	}

	if (max_x <= min_x)
		cout << "0" << endl;
	else if (max_y <= min_y)
		cout << "0" << endl;
	else
		cout << (max_x - min_x) * (max_y - min_y) << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0)break;
    for(j=1;j<=H;j++){
      for(i=1;i<=W;i++){
	if(i>1&&i<W&&j>1&&j<H){printf(".");
	}else{printf("#");}
      }
      printf("\n");
    }
    printf("\n");
}
  return 0;
}

Measured memory_bytes: 572
import java.util.*;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		int s[] = new int[m], c[] = new int[m];
		Map<Integer, Integer> map = new TreeMap<Integer, Integer>();
		int ans = -1;
		boolean isexist = true;
		for (int i = 0; i < m; ++i) {
			s[i] = sc.nextInt();
			c[i] = sc.nextInt();
			if (map.containsKey(s[i])) {
				if (map.get(s[i]) != c[i])
					isexist = false;
			}
			if (n > 1) {
				if (s[i] == 1 && c[i] == 0)
					isexist = false;
			}
			map.put(s[i], c[i]);
		}
		sc.close();
		if (isexist) {
			StringBuffer tmp = new StringBuffer();
			if (n > 1)
				tmp.append("1");
			else
				tmp.append("0");
			for (int i = 1; i < n; ++i) {
				tmp.append("0");
			}
			for (int key : map.keySet()) {
				int value = map.get(key);
				tmp.replace(key - 1, key, String.valueOf(value));
			}
			ans = Integer.parseInt(tmp.toString());
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22612
N = gets.to_i
A = [gets.split.map(&:to_i), gets.split.map(&:to_i)]

max = sum = A[0].reduce(:+) + A[1][A[1].length - 1]

N.times.reverse_each do |i|
  next if i.zero?
  sum = sum - A[0][i] + A[1][i-1]
  max = sum if max < sum
end

puts max

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	ll n, a, b;
	cin >> n >> a >> b;
	ll s = a + b;
	ll ans = ((n / s) * a) + min(a, n % s);
	cout << ans;
}


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

int main(){
  string S;
  cin>>S;
  if((S.at(0)==S.at(1)&&S.at(2)==S.at(3)&&S.at(0)!=S.at(2))||(S.at(0)==S.at(2)&&S.at(1)==S.at(3)&&S.at(0)!=S.at(1))||(S.at(0)==S.at(3)&&S.at(1)==S.at(2)&&S.at(0)!=S.at(1))){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
    

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

int main(void){
  string s;
  cin >> s;
  if(s[0]==s[1]&& s[1]==s[2] || s[1]==s[2] && s[2]==s[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<long long> a(n);
	for (auto&& ai : a) cin >> ai;
	long long r1 = 0, r2 = 0;
	long long sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (i%2 == 0 && sum <= 0)
		{
			r1 += 1 - sum;
			sum = 1;
		}
		else if (i%2 == 1 && sum >= 0)
		{
			r1 += sum + 1;
			sum = -1;
		}
	}
	sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (i%2 == 0 && sum >= 0)
		{
			r2 += sum + 1;
			sum = -1;
		}
		else if (i%2 == 1 && sum <= 0)
		{
			r2 += 1 - sum;
			sum = 1;
		}
	}
	cout << min(r1, r2) << endl;
	return 0;
}


Measured memory_bytes: 1024
n,m=(int(i) for i in input().split())
list_a=[]
list_b=[]
for i in range(m):
  a,b=(int(i) for i in input().split())
  list_a.append(a)
  list_b.append(b)
  
max_a=max(list_a)
min_b=min(list_b)

if min_b-max_a+1>=0:
  print(min_b-max_a+1)
else:
  print(0)


Measured memory_bytes: 57688
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int w=sc.nextInt(),h=sc.nextInt();
        int n=sc.nextInt();
        int[] x = new int[n],y=new int[n],a=new int[n];
        for(int i=0;i<n;i++){
            x[i]=sc.nextInt();
            y[i]=sc.nextInt();
            a[i]=sc.nextInt();
        }

        boolean[][] map = new boolean[h][w];
        for(int i=0;i<h;i++)for(int j=0;j<w;j++)map[i][j]=false;

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



            if(a[i]==1){
                for(int j=0;j<x[i];j++)for(int k=0;k<h;k++)map[k][j]=true;
            }else if(a[i]==2){
                for(int j=w-1;j>=x[i];j--)for(int k=0;k<h;k++)map[k][j]=true;
            }else if(a[i]==3){
                for(int j=0;j<y[i];j++)for(int k=0;k<w;k++)map[j][k]=true;
            }else if(a[i]==4){
                for(int j=h-1;j>=y[i];j--)for(int k=0;k<w;k++)map[j][k]=true;
            }
            
        }

        int ans = 0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(!map[i][j])ans++;
            }
        }
        System.out.println(ans);


    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  int k = a[0],j = 1;
  if(k == 2){
    cout << 1 << endl;
    return 0;
  }
  bool flag = false;
  while(j < N){
    k = a[k - 1];
    j++;
    if(k == 2){
      flag = true;
      break;
    }
  }
  
  if(flag){
    cout << j << endl;
  }else{
    cout << -1 << endl;
  }

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define inf(x) (ll)(1e##x)
using namespace std;
const int mod = 1e9+7;
int n,k,f[2010][2010];
ll inv[4001000],fac[4001000],ifac[4001000];
ll C(int n,int m){return fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
void upd(int &a,ll b){a=(a+b)%mod;}
int main(){
	cin>>n>>k;
	if(k==1){cout<<1<<'\n';return 0;}
	f[0][0]=1;
	inv[1]=1;
	for(int i=2;i<=4000000;i++) inv[i]=inv[mod%i]*-(mod/i)%mod;
	fac[0]=ifac[0]=1;
	for(int i=1;i<=4000000;i++) fac[i]=fac[i-1]*i%mod,ifac[i]=ifac[i-1]*inv[i]%mod;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=i;j++){
			upd(f[i+1][j],f[i][j]);
			if(i>j) upd(f[i][j+1],f[i][j]*C((n-i)+(n-j)*(k-1)-1,k-2));
		}
	ll ans=f[n][n]*fac[n]%mod;
	cout<<(ans+mod)%mod<<'\n';
	return 0;
}

Measured memory_bytes: 109696
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
    /*ll t;
    cin>>t;
    while(t--)
    {
       
    }*/
    ll n,k;
    cin>>n>>k;
    ll h[n];
    ll dp[n];
    for(ll i=0;i<n;i++)
    cin>>h[i];
    dp[0]=0;
    for(ll i=1;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(ll j=1;j<=k;j++)
        {
            if(i-j>=0)
            dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
        }
        
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
cc = list(map(int, input().split()))

ans = 0
prv = -2
for i in range(n):
	#print(i, ans)
	ans += bb[aa[i] - 1]
	if aa[i] - 1 == prv + 1:
		ans += cc[prv]
	prv = aa[i] - 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  int k, n, maxDis = 0;
  cin >> k >> n;
  int a[n];
  REP(i, n) {
    cin >> a[i];
  }
  REP(i, n) {
    int dis = (a[(i + 1) % n] + k - a[i]) % k;
    maxDis = max(maxDis, dis);
  }
  cout << k - maxDis << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  /*
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());

  int flag = 0;
  for (int i = 0; i < s.length(); i++){
    for (int j = i; j < t.length(); j++){
      if (s[i] < t[j]){
        cout << "Yes" << endl;
        return 0;
      }
      if (s[i] == t[j]){
        flag += 1;
      }
    }
  }

  if ((flag == (s.length() * t.length())) && (s.length() < t.length())){
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
  */

  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if (s < t){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }


  return 0;
}


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

int main(){
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;i++){
        if(i%d==0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x " = " << (x) << '\n';
#define P(x) cout << #x << '\n';    
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	
	int n;
	cin >> n;
	vector<string> a(n);
	vector<int> t(n);
	for(int i = 0; i < n; ++ i)
	{
		cin >> a[i] >> t[i];
	}
	int ans = 0;
	string q;
	cin >> q;
	bool ok = false;
	for(int i = 0; i < n; ++ i)
	{
		if(ok)
			ans += t[i];
		if(a[i] == q)
			ok = true;
	}
	cout << ans << '\n';
	
	return 0;
}






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

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

    int r,g,b,n;cin>>r>>g>>b>>n;

    int ans=0;

    int rm=n/r;
    for(int i=rm;i>=0;i--)
    {
        int nr=n-i*r;
        int gm=nr/g;
        for(int j=gm;j>=0;j--)
        {
            int ng=nr-j*g;
            if(ng%b==0)ans++;
        }
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



typedef vector<ll> V;
typedef vector<V> MATRIX;

int N,M;
ll table[10000];

MATRIX calc_ans(MATRIX left, MATRIX right){
    MATRIX RET(1,V(N));
    for(int col = 0; col < N; col++){
    	RET[0][col] = 0;
    	for(int row = 0; row < N; row++){
    		RET[0][col] += left[0][row]*right[row][col];
    		RET[0][col] %= MOD;
    	}
    }

    return RET;
}


MATRIX calc(MATRIX left,MATRIX right){

	MATRIX ret(N,V(N));

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++)ret[i][k] = 0;
	}

	for(int col = 0; col < N; col++){
		ret[0][col] = 0;
		for(int row = 0; row < N; row++){
			ret[0][col] += left[0][row]*right[row][col];
			ret[0][col] %= MOD;
		}
	}

	for(int row = 0; row <= N-2; row++){
		for(int col = 0; col <= N-1; col++){
			ret[row+1][(col+1)%N] = ret[row][col];
		}
	}

	return ret;

}

MATRIX pow(MATRIX MULT,int count){

	MATRIX ret(N,V(N));

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++){
			if(row == col)ret[row][col] = 1;
			else{
				ret[row][col] = 0;
			}
		}
	}

	while(count > 0){
		if(count%2 == 1)ret = calc(ret,MULT);
		MULT = calc(MULT,MULT);
		count /= 2;
	}

	return ret;
}



int main(){

	int K;
	scanf("%d %d %d",&N,&M,&K);

	for(int i = 0; i < M; i++){
		scanf("%lld",&table[i]);
		table[i] %= N;
	}

	ll work[N];
	work[0] = 1;
	for(int i = 1; i <= N-1; i++)work[i] = 0;

	for(int i = 0; i < M; i++){
		work[table[i]]++;
	}

	MATRIX first_state(1,V(N));
	first_state[0][0] = 1;

	for(int i = 1; i <= N-1; i++)first_state[0][i] = 0;

	MATRIX transition(N,V(N));
	for(int i = 0; i <= N-1; i++)transition[0][i] = work[i];

	for(int row = 0; row <= N-2; row++){
		for(int col = 0; col <= N-1; col++){
			transition[row+1][(col+1)%N] = transition[row][col];
		}
	}

	if(K > 1){
		transition = pow(transition,K);
	}

	MATRIX ans = calc_ans(first_state,transition);

	for(int i = 0; i < N; i++){
		printf("%lld\n",ans[0][i]%MOD);
	}

	return 0;
}



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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long ll;
typedef pair<int, int> P;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 100 + 5;
const int MAX_N = 1e5 + 5;

int MOD = 1e9 + 7;
long modpow(long m, long p) {
    if (p == 0) return 1;
    if (p % 2)
        return m * modpow(m, p - 1) % MOD;
    else {
        long res = modpow(m, p / 2);
        return res * res % MOD;
    }
}

int main() {
    int n;
    ll ans = 1;
    cin >> n;
    vector<int> roleModel;
    vector<int> v;
    for (int i = n - 1; i >= 0; i -= 2) {
        if (i == 0) {
            roleModel.push_back(0);
            break;
        }
        roleModel.push_back(i);
        roleModel.push_back(i);
    }
    sort(roleModel.begin(), roleModel.end());
    rep(i, n) {
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    if (v == roleModel) {
        ans = modpow(2, n / 2);
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);
struct mint {
  ll x; 
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}com(200005);
int main(){
   int n;cin>>n;
   ll a[n];
   rep(i,n)cin>>a[i];
   mint sum =0;
   mint ans =0;
   rep(i,n){
       ans+=sum*a[n-1-i];
       sum+=a[n-1-i];
   }
   cout<<ans.x<<endl;
}

Measured memory_bytes: 7988
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

double T, X;

int main() {
	scanf("%lf %lf", &T, &X);
	double ans = T / X;
	printf("%0.12lf", ans);

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ff first
#define dd second
#define mp make_pair
#define pb push_back
#define pp pair<int,int>
#define N 200007 // check
#define M
#define K 76
#define endl "\n"
using namespace std;

int n;

const int rg = 1 << 18;
const int sz = 1 << 19;

int tab[N];
int temp[N];
int tree[sz];

void clean() {
    for(int i = 0; i < sz; ++i) tree[i] = 0;
}

void add(int x, int val) {
    int temp = rg+x-1;
    while(temp != 0) {
        tree[temp] += val;
        temp/=2;
    }
}

void update(int x) {
    add(x+n+2, 1);
}

int sum2(int i, int start, int meta, int a, int b) {
    if(a <= start and  b >= meta) {
        return tree[i];
    }
    if(a > meta or b < start) return 0;
    int s = (start+meta)/2;
    return  sum2(i*2, start, s, a, b) + sum2(i*2+1, s+1, meta, a, b);
}

int sum(int a, int b) {
    return sum2(1,1,rg,a+n+2,b+n+2);
}

int numberOfLess(int t) {
    clean();
    for(int i = 0; i < n; ++i) {
        if(tab[i] < t) {
            temp[i] = -1;
        }
        if(tab[i] > t) {
            temp[i] = 1;
        }
        if(tab[i] == t) {
            temp[i] = -1;
        }
    }

    int licz = 0;
    int res = 0;

    update(0);

    for(int i = 0; i < n; ++i) {
        licz += temp[i];
        res += sum(max(-n-1-licz,-n-1), min(-licz-1,n));
        update(-licz);
    }
    return res;
}

int sorted[N];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> tab[i];
        sorted[i] = tab[i];
    }

    int nn = (n*(n-1)/2 + n);

    int ile = nn/2+1;

    sort(sorted, sorted + n);

    int l = 0; int r = n-1;
    while(r - l > 4) {
        int s = (r+l)/2;
        if(numberOfLess(sorted[s]) >= ile) {
            r = s;
        } else {
            l = s;
        }
    }

    for(int i = l; i <= r; ++i) {
        if(numberOfLess(sorted[i]) >= ile) {
            cout << sorted[i] << endl; break;
        }
    }
}

Measured memory_bytes: 7680
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:break
    for j in range(H):
        for i in range(W):
            if j%2==1 and i%2==1:
                print("#",end="")
            elif j%2==1 and i%2==0:
                print(".",end="")
            elif j%2==0 and i%2==1:
                print(".",end="")
            else:
                print("#",end="")
        print()
    print()
                


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

using namespace std;

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

	const int num = 753;
	int ans = num;
	for (int i = 0; i < S.size() - 2; i++)
	{
		int x = stoi(S.substr(i, 3));

		if (abs(x - num) < ans)
		{
			ans = abs(x - num);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

func main() {
  var n int = NextInt()
  var p []int = NextIntArray()
  var a []int = make([]int,n)
  var b []int = make([]int,n)
  var r []int = make([]int,n)
  for i:=0;i<n;i++ { r[p[i]-1] = i+1 }
  for i:=0;i<n;i++ {
    a[i] = 30000*(i+1)
    b[i] = 30000*(n-i-1)+r[i]
  }
  fmt.Print(a[0])
  for i:=1;i<n;i++ {
    fmt.Print(" ")
    fmt.Print(a[i])
  }
  fmt.Println()
  fmt.Print(b[0])
  for i:=1;i<n;i++ {
    fmt.Print(" ")
    fmt.Print(b[i])
  }
  fmt.Println()
}

var reader = bufio.NewReaderSize(os.Stdin,1000000)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var a []int = make([]int,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.Atoi(s[i]) }
  return a
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define pc _putchar_nolock
#define mp make_pair
#define mt make_tuple
#define um unordered_map
#define inf (ll)9223372036854775807
#define sz(x) (int)x.size()
using namespace std;
using ll=long long int;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
void input(vector<int>&a,int n)
{
   rep(i,0,n-1)
   cin>>a[i];
}
int ce(int a,int b)
{
	if(a%b==0) return a/b; 
	return a/b+1; 
}
void solve()
{
 int n; cin>>n; int k=ce(n,1000); 
 cout<<k*1000-n<<"\n"; 
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  while(t--)
  {
	 solve();
  }
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

ll funcxor(ll N) {
	if (N < 0)
		return 0;
	ll ans = 0;
	bool N_is_odd = N % 2;
	if (N % 2 == 0)
		ans = N;
	if (N % 4 == 1 || N % 4 == 2)
		ans++;
	return ans;
}

int main() {
	ll A, B;
	cin >> A >> B;
	ll Axor = funcxor(A - 1);
	ll Bxor = funcxor(B);
	ll ans = Axor ^ Bxor;
	cout << ans << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  LL i,o,t,j,l,s,z;
  cin >> i >> o >> t >> j >> l >> s >> z;
  cout << o+max(i/2*2+j/2*2+l/2*2,(j-1)/2*2+(l-1)/2*2+(i?1:0)*(j?1:0)*(l?1:0)*(3+(i-1)/2*2)) << endl;
  return 0;
}

Measured memory_bytes: 256