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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll  = long long;
using ii  = pair<int, int>;
using vi  = vector<int>;
using vd  = vector<double>;
using vb  = vector<bool>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

constexpr int MAX = 100000;

vector<vector<pair<int, int>>> al(100000);
vi dist(MAX, -inf);
vb visited(MAX);

bool bfs(int i, int d) {
	if (visited[i] && d != dist[i]) return false;
	if (visited[i] && d == dist[i]) return true;

	visited[i] = true;
	dist[i] = d;
	rep(j, al[i].size()) {
		if (!bfs(al[i][j].first, d + al[i][j].second)) return false;
	}
	return true;
}

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

	rep(i, m) {
		int l, r, d;
		cin >> l >> r >> d;

		l--, r--;
		al[l].push_back({ r, d });
		al[r].push_back({ l, -d });
	}

	rep(i, n) {
		if (!visited[i]) {
			if (!bfs(i, 0)) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 11008
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;
	
	
	void doIt() {
		for(int i = 1; i <= 5; i++) {
			if(sc.nextInt() == 0) {
				System.out.println(i);
				return;
			}
		}
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 35672
#include<bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
int oo = 0x3f3f3f3f;

int main(){
	int n;
	cin >> n;
	int ar[2][n];
	int sum[2][n];
	for( int i = 0; i < 2; i++ ){
		for( int j = 0; j < n; j++ ){
			cin >> ar[i][j];
		}
	}
	sum[0][0] = ar[0][0];
	sum[1][0] = ar[1][0];
	for( int i = 1; i < n; i++ ){
		sum[0][i] = ar[0][i] + sum[0][i-1];
		sum[1][i] = ar[1][i] + sum[1][i-1];
	}
	int ans = 0;
	for( int i = 0; i < n; i++ ){
		int temp = sum[0][i] + sum[1][n-1];
		if( i > 0 )temp -= sum[1][i-1];
		ans = max( ans , temp);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	string a, b;
	cin >> a >> b;

	int n = a.size();
	if (a.size() > b.size()) {
		cout << "GREATER" << endl;
		return 0;
	}
	else if (a.size() < b.size()) {
		cout << "LESS" << endl;
		return 0;
	}
	rep(i, n) {
		if (a[i] > b[i]) {
			cout << "GREATER" << endl;
			return 0;
		} else if (a[i] < b[i]) {
			cout << "LESS" << endl;
			return 0;
		}
	}
	cout << "EQUAL" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////
vector <vector<int>> edge;
vector <int> dp;
int dfs(int u)
{
	if(dp[u]!=-1)
		return dp[u];
	int res = 0;
	for(auto v:edge[u])
		res = max(res,1+dfs(v));
	dp[u] = res;
	return res;

}

int main()
{	int x,y;
	cin>>x>>y;
	edge.resize(x+1);
	dp.resize(x+1,-1);
	REP(i,y)
	{
		int a,b;
		cin>>a>>b;
		edge[a-1].push_back(b-1);
	}
	REP(i,x)
	{
		edge[x].push_back(i);
	}
	int ans = dfs(x)-1;
	cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 11592
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007 //1000000000000000003
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int a,b,c,d,E,F;

  cin>>a>>b>>c>>d>>E>>F;
  a*=100; b*=100;
  bool water[3001]={};
  bool sugar[3001]={};

  rep(i,31){
    rep(j,31){

      int wat=i*a+j*b;

      if(wat<=3000){
        water[wat]=true;
      }
    }
  }

  rep(i,3001){
    rep(j,3001){

      int sug=i*c+j*d;

      if(sug<=3000){
        sugar[sug]=true;
      }
    }
  }

  double maxden=0;
  int ansi=0;
  int ansj=0;

  rep(i,F+1){
    rep(j,F+1){
      if(i+j==0) continue;
      if(!water[i]) continue;
      if(!sugar[j]) continue;
      if(i+j>F) continue;

      if(((double)100*j)/(i+j)<=((double)100*E)/(100+E) and ((double)100*j)/(i+j)>=maxden){
        maxden=((double)100*j)/(i+j);
        ansi=i;
        ansj=j;
      }
    }
  }

  cout<< ansi+ansj<<" "<<ansj<<"\n";


}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
N = gets.to_i
A = Array.new(N + 1,0)
S = Array.new(N + 1,0)

gets.split.map(&:to_i).each_with_index{|x,i| A[i+1] = x }
(1 .. N).each{|i| S[i] = S[i-1] + (A[i] - A[i-1]).abs }

ans = (1 .. N).map do |i| 
  if i == N
    S[N-1] + A[N-1].abs
  else
    S[i-1] + (A[i-1] - A[i+1]).abs + (S[N] - S[i+1]) + (A[N].abs) 
  end
end

puts ans


Measured memory_bytes: 13324
from operator import itemgetter

def solve():
    N = int(input())
    As = list(map(int, input().split()))
    Bs = list(map(int, input().split()))

    Cs = sorted(As)
    Ds = sorted(Bs)

    for A, B in zip(Cs, Ds):
        if A > B:
            return False

    for i in range(N-1):
        if Cs[i] <= Ds[i+1] and Cs[i+1] <= Ds[i]:
            return True

    ABs = [(A, B) for A, B in zip(As, Bs)]
    ABs.sort(key=itemgetter(1))

    As = [A for A, B in ABs]
    Bs = [B for A, B in ABs]
    iAs = list(range(N))
    iAs.sort(key=lambda iA: As[iA])
    convs = dict()
    for i in range(N):
        convs[As[iAs[i]]] = i

    for i in range(N-2):
        if As[i] <= Bs[i]:
            return True
        X, Y = As[i], As[iAs[i]]
        As[i], As[iAs[i]] = As[iAs[i]], As[i]
        iAs[convs[X]], iAs[convs[Y]] = iAs[convs[Y]], iAs[convs[X]]

    if As[N-2] <= Bs[N-2] and As[N-1] <= Bs[N-1]:
        return True
    else:
        return False

if solve():
    print('Yes')
else:
    print('No')


Measured memory_bytes: 103016
(defun solve (n path trc)
  (let ((cnt 0))
    (labels ((f (trc)
                (if (= n (length trc))
                  (incf cnt)
                  (loop
                    for k in (set-difference (aref path (car trc)) trc) do
                    (f (cons k trc))))))
      (f trc)
      cnt)))
  
(defun main ()
  (let* ((n (read))
         (m (read))
         (path (make-array n :initial-element nil)))
    (loop for i below m do
          (let* ((a (1- (read)))
                 (b (1- (read))))
            (push a (aref path b))
            (push b (aref path a))))
    (format t "~a~%" (solve n path '(0)))))
(main)

Measured memory_bytes: 16868
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	int n, k;
	cin >> n >> k;
	BitRep(i, n) {
		bitset<18> bit(i);
		if (bit.count() == k) {
			cout << i << ":";
			Rep(j, n) {
				if (bit[j]) cout << " " << j;
			}
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>

using namespace std;

int main() {

    string s; cin >> s;
    string a = s.substr(0, 2), b = s.substr(2, 2);
    bool a_year = a > "12" || a == "00";
    bool b_year = b > "12" || b == "00";
    if ((a_year && b_year)) {
        cout << "NA\n";
    } else if (a_year) {
        cout << "YYMM\n";
    } else if (b_year) {
        cout << "MMYY\n";
    } else {
        cout << "AMBIGUOUS\n";
    }
}

Measured memory_bytes: 3088
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array

const int INF = 1e15;

void solve(){
	int n, S;
	cin >> n >> S;
	vector<int> w(n), v(n);
	int sum = 0;
	for(int i = 0;i < n; ++i){
		cin >> w[i] >> v[i];
		sum += v[i];
	}
	vector<int> dp(sum+1,INF);
	dp[0] = 0;
	for(int i = 0;i < n; ++i){
		for(int j = sum; j >= v[i]; --j){
			dp[j] = min(dp[j],dp[j-v[i]]+w[i]);
		}
	}
	int ans = 0;
	for(int i = 0;i <= sum; i++){
		if(dp[i] <= S) ans = max(ans, i);
	}
	cout << ans << "\n";
} 

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int TC = 1;
    while(TC--)
        solve();

    return 0;
}



Measured memory_bytes: 3980
list = [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]
K = int(input())

print(list[K-1])


Measured memory_bytes: 38256
#include <stdio.h>

int main(void)
{
	int a,b,c;
	int i;
	while((scanf("%d %d",&a,&b))!=EOF){
		c=a+b;
		i=1;
		while(c>=10){
			c=c/10;
			i=i+1;
		}
	printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

void call(int n);
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	call(n);
	return 0;
}

void call(int n){
	for(int i=1; i<=n; i++) {
		int x=i;
		if(x%3==0) {
			cout<<' '<<i;
			continue;
		}
		do{
			if(x%10==3) {
				cout<<' '<<i;
				break;
			}
			x/=10;
		}while(x);
	}
	cout << endl;
}



Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

using namespace std;

signed main() {
	int a, b;
	cin >> a >> b;

	if (a <= 9 && b <= 9) cout << a * b << endl;
	else cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
using ll = long long;
using ld = long double;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c; cin >> a >> b >> c;
  puts((a == b && b == c) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(){
    char s[100];
    char x[100];
    scanf("%s", &s);
    
    for(int i = 0; i < strlen(s); i++){
    	if( s[i] == ',' ){
		
    		s[i] = (' ');
    		
		}
   	} printf("%s", s);
    
    return 0;
}

Measured memory_bytes: 1720
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int N;
int A[1000], B[1000];

int main() {
    cin >> N;
    rep(i,N) cin >> A[i];
    rep(i,N) B[i] = A[i];
    ll ans = 0;
    rep(i,N) {
        vector<int> v;
        for (int j = 2; j*j <= A[i]; j++) {
            if (A[i]%j) continue;
            while (A[i]%j==0) A[i] /= j;
            v.push_back(j);
        }
        if (A[i] > 1) v.push_back(A[i]);
        for (int x: v) {
            ll cnt = 0;
            rep(j,N) {
                if (B[j]%x == 0) cnt += B[j];
            }
            ans = max(ans,cnt);
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main(void){

  int n;
  while( cin >> n, n ){

    int temp = n;
    int res[101] = {0};

    while(n--){
      for( int i = 0 ; i < 5 ; i++ ){
	int s;
	cin >> s;
	res[n] += s;
      }
    }

    sort( res, res + temp );
    cout << res[temp - 1] << " " << res[0] << endl;
  }
  return 0;
}

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

int main()
{
    /*A
    int a,b;
    cin>>a>>b;
    if(a>b)
    {
        cout<<"safe"<<endl;
    }
    else
    {
        cout<<"unsafe"<<endl;
    }
    */
    /*B
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    bool flag = true;
    for(int i=0;i<200;i++)
    {
        if(i%2==0)
        {
            c = c-b;
            if(c<=0)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        else
        {
            a = a-d;
            if(a<=0)
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    */
    ll n;
    cin>>n;
    set <string> setter;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        setter.insert(s);    
    }

    cout<<setter.size()<<endl;
    return 0;
}

Measured memory_bytes: 19256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    String s = sc.next();
    
    int harfOfN = n / 2;
    String firstOfS = s.substring(0, harfOfN);
    String lastOfS = s.substring(harfOfN + 1 -1);
    
    if (firstOfS.equals(lastOfS)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int n = 0;
		int s = 0;
		int w = 0;
		int e = 0;
		for(int i = 0; i < str.length(); i++) {
			if(str.charAt(i)=='S') {
				s++;
			}
			if(str.charAt(i)=='N') {
				n++;
			}
			if(str.charAt(i)=='E') {
				e++;
			}
			if(str.charAt(i)=='W') {
				w++;
			}
		}
		if(s>0&&n>0&&w==0&&e==0) {
			System.out.println("Yes");
			return;
		}
		if(s==0&&n==0&&w>0&&e>0) {
			System.out.println("Yes");
			return;
		}
		if(s>0&&n>0&&w>0&&e>0) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
		
	}
}

Measured memory_bytes: 21844
#include<string>
#include<stdio.h>
using namespace std;

string ctable[] = {
	".,!? ",
	"abc",
	"def",
	"ghi",
	"jkl",
	"mno",
	"pqrs",
	"tuv",
	"wxyz"
};

int main(){
	int cases;
	cin>>cases;
	while(cases--){
		string str;
		cin>>str;
		
		int mem = 0;//times * 10 + type
		for(int i = 0; i < str.size(); i++){
			int t = (int)(str[i]-'0');
			if(!t){
				if(mem){
					cout<<ctable[mem%10-1].at((mem/10)%ctable[mem%10-1].size());
				}
				mem = 0;
			}else{
				if(mem%10 == t)mem+=10;
				else mem = t;
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    string ans = "";
    for(int i=0; i<s.size(); i++){
        if(s[i]=='0'){
            ans += "0";
        }else if(s[i]=='1'){
            ans += "1";
        }else{
            if(ans.size()>=1){
                ans.pop_back();
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	int a, b, x=0;
	for(int i=0;i<n;i++) {
		cin >> a >> b;
		if(a == b) {
			x++;
		} else {
			x = 0;
		}
		if(x == 3) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 3516
a = int(input())
card = [input() for i in range(a)]
allcard = ["S 1","S 2","S 3","S 4","S 5","S 6","S 7","S 8","S 9","S 10","S 11","S 12","S 13","H 1","H 2","H 3","H 4","H 5","H 6","H 7","H 8","H 9","H 10","H 11","H 12","H 13","C 1","C 2","C 3","C 4","C 5","C 6","C 7","C 8","C 9","C 10","C 11","C 12","C 13","D 1","D 2","D 3","D 4","D 5","D 6","D 7","D 8","D 9","D 10","D 11","D 12","D 13"]
ans = [] 
for x in card:
    if x in allcard:
        allcard.remove(x)

for i in allcard:
    print(i)


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

int main() {
  int n,a;
  double t;
  cin>>n>>t>>a;
  vector<double>x(n);
  for(int i=0;i<n;i++) cin>>x[i];
  int ans=0;
  double dif=1000000;
  for(int i=0;i<n;i++){
    double d=abs(a-(t-0.006*x[i]));
    if(d<dif){
      dif=d;
      ans=i+1;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3788
n, l = map(int, input().split())

aji = []
for i in range(n):
    a = l + i
    aji.append(a)

s = sum(aji)
ans = 0
dif = []
for i in range(n):
    sd = s - aji[i]
    b = abs(s-sd)
    dif.append(b)
    
ans = s - aji[dif.index(min(dif))]

print(ans)



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

using namespace std;
using llong = long long;

string s;
int gx,gy;
int cnt =0;
vector<int> X,Y;
bool xtable[8001][16001],ytable[8001][16001];

int main(){
  cin >> s;
  cin >> gx >> gy;
  string news ;
  bool is_x = true;
  int fnum = 0;
  X.push_back(0),Y.push_back(0);
  for(int i=0;i<s.length();++i){
    int j = i;
    while(j<s.length()&&s[j]=='T') j++;
    int tnum = j-i;
    if(tnum>0){
      if(is_x) X.push_back(fnum);
      else Y.push_back(fnum);
      fnum = 0;
      if(tnum%2==0){
        if(is_x) X.push_back(0);
        else Y.push_back(0);
      }else{
        is_x = !is_x;
      }
      i = j-1;
    }else{
      fnum++;
    }
  }
  if(fnum>0){
    if(is_x) X.push_back(fnum);
    else Y.push_back(fnum);
  }
  //
  // for(auto x:X) cout << x << " ";
  // cout << endl;
  // for(auto y:Y) cout << y << " ";
  // cout << endl;

  xtable[0][8000] = true;
  ytable[0][8000] = true;
  for(int i=1;i<X.size();++i){
    for(int j=0;j<16001;++j){
      if(j-X[i]>=0) xtable[i][j] |= xtable[i-1][j-X[i]];
      if(j+X[i]>=0&&i!=1) xtable[i][j] |= xtable[i-1][j+X[i]];
    }
  }
  for(int i=1;i<Y.size();++i){
    for(int j=0;j<16001;++j){
      if(j-Y[i]>=0) ytable[i][j] |= ytable[i-1][j-Y[i]];
      if(j+Y[i]>=0) ytable[i][j] |= ytable[i-1][j+Y[i]];
    }
  }
  //
  // for(int i=0;i<X.size();++i){
  //   for(int j=8000-5;j<=8000+5;++j){
  //     cout << xtable[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  // for(int i=0;i<Y.size();++i){
  //   for(int j=8000-5;j<=8000+5;++j){
  //     cout << ytable[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  //
  if(xtable[X.size()-1][gx+8000]&&ytable[Y.size()-1][gy+8000]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 86272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int par[200100];
int depth[200100];
int N,A,B,C;
int L[10];
int dfs(int k, int a, int b, int c){
    if(k == N){
        if(min(a, min(b,c))) return abs(A-a) + abs(B-b) + abs(C-c);
        else return 1e9;
    }
    int ans = MAX;
    ans = min(ans, dfs(k+1, a + L[k], b, c) + (a>0 ? 10:0));
    ans = min(ans, dfs(k+1, a, b + L[k], c) + (b>0 ? 10:0));
    ans = min(ans, dfs(k+1, a, b, c + L[k]) + (c>0 ? 10:0));
    ans = min(ans, dfs(k+1, a, b, c));
    return ans;
}
int main(){
    cin >> N >> A >> B >> C;
    for(int i = 0; i < N; i++){cin >> L[i];}
    int res = dfs(0,0,0,0);
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;

/* editorial */

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

    int H, W;
    vector<string> A;

    cin >> H >> W;
    A.resize(H);
    vector<vector<int>> d(H);
    for (int i = 0; i < H; i++)
    {
        cin >> A[i];
        d[i].resize(W);
    }

    queue<pair<int, int>> q;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (A[i][j] == '#')
            {
                q.push(make_pair(i, j));
            }
            else
            {
                d[i][j] = -1;
            }
        }
    }

    int px[4] = {-1, 0, 1, 0};
    int py[4] = {0, 1, 0, -1};
    while (!q.empty())
    {
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        for (int i = 0; i < 4; i++)
        {
            int nx = x + px[i];
            int ny = y + py[i];
            if ((0 <= nx && nx < H) && (0 <= ny && ny < W) && A[nx][ny] == '.' && d[nx][ny] == -1)
            {
                d[nx][ny] = d[x][y] + 1;
                q.push(make_pair(nx, ny));
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            ans = max(ans, d[i][j]);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13456
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(void){
    int i;
    char W[11];
    char T[100];
    int cnt = 0;
    scanf("%s",W);
    for(i = 0; i < 11; i ++ ){
        W[i] = tolower(W[i]);
    }
    while(1){
        scanf("%s",T);
        if(strcmp(T ,"END_OF_TEXT") != 0){
            for(i = 0; i < 100; i ++ ){
                T[i] = tolower(T[i]);
            }
        }
        if(strcmp(T,"END_OF_TEXT") ==0)break;
        else if(strcmp(T,W) == 0)cnt ++;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 552
#include <iostream>
#include <cmath>
#include <map>

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

    std::map<long long, long long> a;
    for(int i = 0; i < n; ++i){
        int val;
        std::cin >> val;

        auto itr = a.find(val);
        if(a.end() == itr){
            a.insert(std::make_pair(val, 1));
        }else{
            ++(itr->second);
        }
    }

    long long sqr = 1;
    auto ritr = a.rbegin();
    ritr = std::find_if(ritr, a.rend(), [](auto i){
        return 4 <= i.second;
    });

    if(a.rend() != ritr){
        for(int i = 0; i < 2; ++i){
            sqr *= ritr->first;
        }
    }else{
        sqr = 0;
    }

    long long rec = 1;
    ritr = a.rbegin();
    for(int i = 0; i < 2; ++i){
        ritr = std::find_if(ritr, a.rend(), [](auto i){
            return 2 <= i.second;
        });

        if(a.rend() != ritr){
            rec *= ritr->first;
        }else{
            rec = 0;
            break;
        }

        ++ritr;
    }

    std::cout << std::max(sqr, rec) << std::endl;

    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 998244353;
const int N = 1e6 + 5;
const int M = 1e3 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m, k;
char s[N];
int a[N];
ll qsm(ll x,ll y, ll MOD){ ll res=1; while(y){if(y&1) res=res*x%MOD;
x=x*x%MOD; y>>=1;} return res; }
int res1, res2, cnt1, cnt2, cnt, res;

int solve(int i){
    int tmp;
    if(a[i]){
        if(cnt1==0){
            return 0;
        }
        tmp=(res1-qsm(2,i-1,cnt1)+cnt1)%cnt1;
    }
    else{
        tmp=(res2+qsm(2,i-1,cnt2)+cnt2)%cnt2;
    }
    int ans=1;
    while(tmp){
        cnt=__builtin_popcount(tmp);
        tmp%=cnt;
        ++ans;
    }
    return ans;
}

int main(){
    scanf("%d%s",&n,s+1);
    res=0, cnt=0;
    rep(i,1,n){
        if(s[i]=='1') ++cnt;
        a[n-i+1]=s[i]-'0';
    }
    res1=res, res2=res;
    cnt1=cnt-1, cnt2=cnt+1;
    rep(i,1,n){
        if(a[i]){
            if(cnt1>0) res1=(res1+qsm(2,i-1,cnt1))%cnt1;
            res2=(res2+qsm(2,i-1,cnt2))%cnt2;
        }
    }
    per(i,n,1) printf("%d\n", solve(i));
    return 0;
}
/*
23
00110111001011011001111
*/
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     ·ð×æ±£ÓÓ      ÓÀÎÞBUG


Measured memory_bytes: 4780
N,T = map(int,input().split())
C = []
for i in range(N):
    a,b = map(int,input().split())
    C.append([a,b])
C.sort()
dp = [[0 for i in range(T)]for j in range(N+1)]
for i in range(1,N+1):
    a,b = C[i-1][0],C[i-1][1]
    for t in range(1,T):
        p = dp[i-1][t]
        if t >= a:
            q = dp[i-1][t-a] + b
            dp[i][t] = max(p,q)
        else:
            dp[i][t] = p
M = 0
for i in range(1,N+1):
    M = max(M,C[i-1][1]+dp[i-1][T-1])
print(M)

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

int main()
{
    int n;
    long long int sum = 0;
    cin >> n;
    vector<int> tall(n);
    for (int i = 0; i < n; i++)
    {
        cin >> tall.at(i);
    }
    for (int i = 0; i < n - 1; i++)
    {
        int b;
        b = tall.at(i + 1) - tall.at(i);
        if (b < 0){
            tall.at(i + 1) = tall.at(i);
            sum += -b;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n, m, x;
    cin >> n >> m >> x;
    vector<ll> a(m);
    ll high = 0, low = 0;
    rep(i, m) {
        cin >> a[i];
        if (a[i] > x)
            high++;
        else
            low++;
    }

    cout << min(high, low) << "\n";

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*

3 1
012 6
3 2
003 3
012 6
111 1

4 1
0112 12
4 2
0013
0022
0112
1111
12 6 12 1
31

4 3
0004
0013
0022
0112
1111
31+4=35

5 1
01112 20

5 2
00113 20
00122 20
11111 1

5 3
00014
00023
+40

5 4
00005 +5

3:6 10
  6 4
4:12 31 35
  12 19 4
  3*4 9*2+1 4
5:20 61 101 106
  20 40 40 5
  4*5 20+20+1 20+20 5
なんだこれ･･･
0がK個の場合の数が増えているのか
総数Nを、N-Kに振り分ける。
N-K=M
nCm * (n-m)Hx // 
21=20+1
5C2=10
3箇所に5
5-3=2 3箇所に2を振り分ける 002か011だけ。2通りにしたい
3H2=4C2=6
2Hx=2
2+x-1 C x=2
x=1

5C3=10
5を2箇所で振り分ける
5-2=3を2箇所で分ける。
2*2=4を得たい。
5C3* 03 12
2H3=4C3=4

3つの枠に2つを入れる
002
011
区別がつかないものとした場合の数ってどうもとめるんだ
2C1?

5H3=5+3-1C5-1
=7C4=7C3

2H3=4C3=4C1

計算ミスってただけだった
nCm*(n-m)HmでOK

*/

const int MAX = 510000;
const int MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
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;
    }
}
 
// 二項係数計算
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 main(){
  COMinit();
  ll N,K,ans=0; cin>>N>>K;
  K=min(N-1,K);
  vector<ll> DP(K+1,0);
  DP[2]=1;//11111のやつ
  for(ll i=1; i<=K; i++){
    (DP[i]+=DP[i-1])%=MOD;
    (DP[i]+=COM(N,i)*COM(N-1,i))%=MOD;//nCi*(n-iHi)    
  }
  cout<<DP[K]<<endl;
}

Measured memory_bytes: 13824
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    l = list(map(int,input().split()))
    l = [((i-1)//n, (i-1) % n) for i in l]
    check = [[1]*n for i in range(n)]
    d =  [[min(i, n-i-1, j, n-j-1) for j in range(n)] for i in range(n)]

    ans = 0
    for x,y in l:
        check[x][y] = 0
        ans += d[x][y]
        q = [(x,y,d[x][y])]
        while q:
            bx,by,z = q.pop()

            if bx != 0:
                if d[bx-1][by] > z:
                    d[bx-1][by] = z
                    q.append((bx-1,by,z+check[bx-1][by]))
            if bx != n-1:
                if d[bx+1][by] > z:
                    d[bx+1][by] = z
                    q.append((bx+1,by,z+check[bx+1][by]))
            if by != 0:
                if d[bx][by-1] > z:
                    d[bx][by-1] = z
                    q.append((bx,by-1,z+check[bx][by-1]))
            if by != n-1:
                if d[bx][by+1] > z:
                    d[bx][by+1] = z
                    q.append((bx,by+1,z+check[bx][by+1]))  
    print(ans)
if __name__ =="__main__":
    main()


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int Alice = 0;
  for (int i = 0;i < N;i += 2) {
    Alice += vec.at(i);
  }
  
  int Bob = 0;
  for (int i = 1;i < N;i += 2) {
    Bob += vec.at(i);
  }
  
  cout << Alice - Bob << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vi a(n);
  int x = 0;
  bool od = false;
  for(int i=0;i<(n);++i) {
    cin >> a[i];
    x ^= a[i];
    od |= a[i] % 2;
  }
  if(x == 0) {
    cout << (od ? "Alice" : "Bob") << endl;
  } else {
    cout << (x == 1 ? "Bob" : "Alice") << endl;
  }
}



Measured memory_bytes: 3360
#include<bits/stdc++.h>
#include<atcoder/all>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
using namespace atcoder;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,q,tmp,a,b,type;
    cin>>n>>q;
    fenwick_tree<long long> ft(n);
    for(int i=0;i<n&&cin>>tmp;i++){
        ft.add(i,tmp);
    }
    while(q--&&cin>>type>>a>>b){
        if(!type)
            ft.add(a,b);
        else
            cout<<ft.sum(a,b)<<"\n";
    }
    return 0;
}


Measured memory_bytes: 8252
#include <bits/stdc++.h>
#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long

using namespace std;


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 solve() {
	ll n, m, k;
	cin >> n >> m >> k;
	
    vector<int> a(n);
    for (int i = 0; i < n; i++){
       cin >> a[i];
    }
    
    vector<int> b(m);
    for(int i =0; i <m; i++){
       cin >> b[i];
    }
    
    ll sum = 0, count = 0;
    int i = 0,j = 0;        
    
    while(i < n && sum + a[i] <= k){
        sum += a[i];
        i++;
    }
    count = i;     
   
    while(j < m && i >= 0) {  
        sum += b[j];             
        j++;
        while(sum > k && i > 0){
            i--;
            sum -= a[i];
        }
        if(sum <= k && i + j > count) {
            count = i + j;
        }
    }
    cout << count << endl;

	
}

int main() {
    FAST_INPUT;

    solve();

    return 0;
}


Measured memory_bytes: 4760
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define rall(n) std::rbegin(n), std::rend(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

void calc() {

	std::string S; std::cin >> S;
	Int N = S.size(); //桁数
	Int K = 0; std::cin >> K;

	std::vector<std::vector<std::array<Int, 2>>> dp(N + 1, std::vector<std::array<Int, 2>>(K + 1));
	dp[0][0][0] = 1;
	
	rep(i, N)rep(j, K + 1)rep(k, 2) {
		Int nd = (Int)(S[i] - '0');
		rep(d, 10) {
			//次の遷移先を決める
			Int ni = i + 1, nj = j, nk = k;
			if (d != 0)nj++;
			if (nj > K)continue;
			if (k == 0) {
				if (d > nd)continue;
				if (d < nd)nk = 1;
			}
			dp[ni][nj][nk] += dp[i][j][k];
		}
	}

	Int ans = dp[N][K][0] + dp[N][K][1];
	std::cout << ans;

}


int main() {

	init();
	calc();

	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

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

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

  long sum = 0;
  rep(i, n) {
    for(int j = i + 1; j < n; j++) {
      if (i == j) continue;
      sum += d[i] * d[j];
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int main() {
	int a, b;
	cin >> a >> b;
	if (a == b)PRI(0);
	else if ((a + b) % 2 == 0) PRI((a + b) / 2);
	else PRI("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <queue>
using namespace std;

#define N 200050
#define INF 1000000007
int a[N];

int mn[2][N*8],pos[2][N*8];

#define ls p<<1
#define rs (p<<1)|1
void setTree(int p,int l,int r)
{
	if(l==r)
	{
		for(int i=0;i<2;i++)
			mn[i][p]=INF,pos[i][p]=l;
		(l&1)? mn[1][p]=a[l]: mn[0][p]=a[l];
		return;
	}
	int mid=(l+r)>>1;
	setTree(ls,l,mid);
	setTree(rs,mid+1,r);
	for(int i=0;i<2;i++)
	{
		int tmp= mn[i][ls]<mn[i][rs]? ls: rs;
		mn[i][p]=mn[i][tmp],pos[i][p]=pos[i][tmp];
	}
}

int query(int p,int l,int r,int gl,int gr,int tp)
{
	if(l==gl && r==gr)
	{
		if(l==r)
			return (l&1)==tp? l: -1;
		else
			return pos[tp][p];
	}
	int mid=(l+r)>>1;
	if(gr<=mid) return query(ls,l,mid,gl,gr,tp);
	else if(gl>mid) return query(rs,mid+1,r,gl,gr,tp);
	else
	{
		int tl=query(ls,l,mid,gl,mid,tp);
		int tr=query(rs,mid+1,r,mid+1,gr,tp);
		if(tl==-1) return tr;
		else if(tr==-1) return tl;
		else return a[tl]<a[tr]? tl: tr;
	}
}

struct Node{int mnv,l,r;};
bool operator<(const Node &a,const Node &b){return a.mnv>b.mnv;}
priority_queue<Node> pq;

int whr[N];
int ans[N],acnt;
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		whr[a[i]]=i;
	}
	
	setTree(1,1,n);
	pq.push((Node){a[query(1,1,n,1,n,1)],1,n});
	for(int i=2;i<=n;i+=2)
	{
		Node nd=pq.top();pq.pop();
		ans[++acnt]=nd.mnv;
		int pos=whr[nd.mnv];
		int rp=query(1,1,n,pos+1,nd.r,(pos+1)&1);
		ans[++acnt]=a[rp];
		if(pos>nd.l)
		{
			pq.push((Node){a[query(1,1,n,nd.l,pos-1,nd.l&1)],nd.l,pos-1});
		}
		if(rp>pos+1)
		{
			pq.push((Node){a[query(1,1,n,pos+1,rp-1,(pos+1)&1)],pos+1,rp-1});
		}
		if(nd.r>rp)
		{
			pq.push((Node){a[query(1,1,n,rp+1,nd.r,(rp+1)&1)],rp+1,nd.r});
		}
	}
	for(int i=1;i<=n;i++)
		printf("%d%c",ans[i],i<n?' ':'\n');
}


Measured memory_bytes: 21240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+5;
int main(){
	int n;
	cin>>n;
	set<string> ss;
	for(int i = 0;i<n;i++){
		string s;cin>>s;
	    ss.insert(s);
	}
	cout<<(int)ss.size();
	return 0;
}


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

using namespace std;
typedef long long ll;

int n;
int a[100010];
map<int, int> mp;

int main(void) {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }

  ll ans = 0;
  for (auto i : mp) {
    if (i.second >= i.first) {
      ans += (i.second - i.first);
    } else {
      ans += i.second;
    }
  }
  cout << ans << endl;

  return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)
int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << max(A * B, C * D) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int x,y,i,j,sum;
    scanf("%d%d",&x,&y);
    for(i=0;i<=x;i++){
        j = x-i;
        sum=i*2+j*4;
        if(sum==y){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x, ll n, int md) {
    if (n == 0)return 1;
    if (n % 2 == 0)return modexp((x * x) % md, n / 2, md);
    return (x * modexp((x * x) % md, n / 2, md)) % md;
}


int main(){
    fastio;
    //clock_t tm = clock();
    int n;string s;
    cin>>n;
    cin>>s;
    int m=0;
    f(i,0,n){
        if(s[i]=='R')++m;
    }
    int ans=0;
    f(i,0,m){
        if(s[i]=='W')++ans;
    }
    cout<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define lol long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((lol)(1e17+100))
#define MX ((lol)(4e9+100))
#define ARRS ((lol)(1e6+100))
#define ARS ((lol)(1e3+100))
#define HS ((lol)(233))
#define MOD ((lol)(1e9+9))
#define EP ((double)(1e-9))
#define EPS ((double)(1e-8))
#define pb push_back
#define PI ((double)3.141592653)
#define LG 21

ll n,m;
ll pas=0,k,p;
ll a[ARRS];
ll f[ARRS];
ll h[ARRS];
ll t[ARRS];
string s[5000];
string g[5000];

map<ll,ll> mp;

ll pw(ll a,ll b){
	ll p=1;
	while(b){
		if(b&1)p=(p*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return p;
}

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

	for(int a=0; a<n; a++){
		ll e=1;
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				//cout<<s[(i+a)%n][j]<<" "<<s[j][(i+a+n)%n]<<endl;
				if(s[(i+a)%n][j]!=s[(j+a)%n][i])
					e=0;
			}
		}
		pas+=e;
	}
	cout<<pas*n;

	

}


Measured memory_bytes: 512
N = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7

A.sort()
flag = True
for i in range(N):
  if N%2 == 0:
    if A[i] != (i//2)*2+1:
      flag = False
      break
  else:
    if A[i] != ((i+1)//2)*2:
      flag = False
      break
print(2**(N//2) % MOD if flag else 0)

Measured memory_bytes: 52332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    string s; cin >> s;
    int n; cin >> n;
    rep(i, n) {
        string t; cin >> t;
        int a, b; cin >> a >> b;
        if (t == "replace") {
            string u; cin >> u;
            s = s.substr(0, a) + u + s.substr(b + 1, SZ(s) - a - SZ(u));
        } else if (t == "reverse") {
            reverse(s.begin() + a, s.begin() + b + 1);
        } else {
            out(s.substr(a, b - a + 1));
        }
    }
}



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

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  int count = 0;
  rep(i, 3) {
    if (s.at(i) == t.at(i)) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
from sys import stdin
il = lambda: list(map(int, input().split()))
IL = lambda: list(map(int, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n, m, x, y = IL()
xs = IL()
ys = IL()
a = max(xs)
b = min(ys)
if x < a and b <= y and a < b:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064