akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>

using namespace std;

int main() {
    ios :: sync_with_stdio(false);
    int a[200005], n, i;
    cin>>n;
    for(i=0; i<n; ++i) {
        cin>>a[i];
    }

    for(i=n-1; i>=0; i-=2) {
        cout<<a[i]<<' ';
    }
    if(n%2) {
        for(i=1; i<n; i+=2) {
            cout<<a[i]<<' ';
        }
    }
    else {
        for(i=0; i<n; i+=2) {
            cout<<a[i]<<' ';
        }
    }
    cout<<endl;
    return 0;
}

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

const int MAX_N = 102, MAX_W = 1e5+2;
int N, W;
int w[MAX_N], v[MAX_N];
ll dp[MAX_W];

void solve()
{
	for(int i=0;i<N;++i){
		for(int j=W; j>=w[i]; --j){
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	cout << dp[W] << '\n';
}

int main()
{
	cin >> N >> W;
	for(int i=0;i<N;++i){
		cin >> w[i] >> v[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }


int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size() - 1; i++){
        if(s[i] == s[i + 1]) return cout << "Bad", 0;
    }
    cout << "Good";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

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

int main (void) {
  ll N, X; std::cin >> N >> X;
  std::vector<ll> x(N+1);
  for(int i=0; i<N; i++) std::cin >> x[i];
  x[N] = X;

  std::sort(x.begin(), x.end(), [] (ll &l, ll &r) { return l < r; } );

  ll ans = x[1]-x[0];
  for(int i=1; i<N; i++) {
    ans = gcd(ans, x[i+1]-x[i]);
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 1024
eval"A,B,Q,*I="+`dd`.split*?,
s=[-F=1e15]+I[0,A]+[F]
t=[-F]+I[A,B]+[F]
eval"I[-Q,Q].map{|x|p s[s#{a='.bsearch_index{|y|y>x}-1,2].map{|'}s|t[t#{a}t|[(s-x).abs,(t-x).abs].min+(t-s).abs}.min}.min}"

Measured memory_bytes: 67280
#include <bits/stdc++.h>
#define int long long
#define maxn 100005
#define inf 2000000000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
const double PI = acos(-1);
using namespace std;

main(){
	//ios::sync_with_stdio(false); cin.tie(0);
	//freopen("inp.txt","r",stdin); //freopen("out.txt","w",stdout);
	int a,b,c,d; cin>>a>>b>>c>>d;
	int t1 = c/b; if (c%b!=0) t1++;
	int t2=a/d; if (a%d!=0) t2++;
	if (t1<=t2) cout<<"Yes"; else cout<<"No";
 	
}

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

int main() {
  string a, b, ans = "No";
  cin >> a >> b;
  long x = stoi(a + b), y;
  
  y = sqrt(x);
  if (x == y * y) ans = "Yes";
  
  cout << ans << endl;
}

Measured memory_bytes: 3708
#include "bits/stdc++.h"
using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B) {
		cout << C << endl;
	}
	else if (A == C) {
		cout << B << endl;
	}
	else {
		cout << A << endl;
	}
	return 0;
}


Measured memory_bytes: 3540
import heapq
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(n)]

koho=[[] for _ in range(m)]
for i in range(n):
  a,b=AB[i]
  if m-a>=0:
    koho[m-a].append(b)

q=[]
cnt,ans=m-1,0
while cnt>=0:
  for b in koho[cnt]:
    heapq.heappush(q,-b)
  if len(q)>0:
    ans+=heapq.heappop(q)
  cnt-=1
print(-ans)

Measured memory_bytes: 39628
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }

int N;
string S[200];
int Colors[200]; // none:0 white:1 black:2

bool dfs(int pos, int color) {
  Colors[pos] = color;

  int next_color = color == 1 ? 2 : 1;
  rep(i, S[pos].size()) {
    if(S[pos][i] == '1') {
      if(color == Colors[i]) return false;
      if(Colors[i] == 0) {
        if(!dfs(i, next_color)) return false;
      }
    }
  }

  return true;
}

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

  cin >> N;
  rep(i, N) cin >> S[i];

  bool is_bipartite_graph = dfs(0, 1);

  if(!is_bipartite_graph) {
    cout << -1 << endl;
    return 0;
  }

  vector<vector<int>> G(N, vector<int>(N, 1e9));
  rep(i, N) {
    rep(j, N) {
      if(i == j) G[i][j] = 0, G[j][i] = 0;
      if(S[i][j] == '1') G[i][j] = 1, G[j][i] = 1;
    }
  }

  rep(k, N) {
    rep(i, N) {
      rep(j, N) {
        chmin(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }

  int d = 0;
  rep(i, N) {
    chmax(d, *max_element(G[i].begin(), G[i].end()));
  }

  cout << d + 1 << endl;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
  string s;
  int sum = 700;
  cin >> s;
  
  if (s[0] == 'o') {
    sum += 100;
  }
  if (s[1] == 'o') {
    sum += 100;
  }
  if (s[2] == 'o') {
    sum += 100;
  }

  cout << sum << endl;
}


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

int main(void){
	ios::sync_with_stdio(false);
	int A, B, K,i,j;
	cin >> A >> B >> K;
	for (i = 0; i < K; i++) {
		if (i % 2 == 0) {
			if (A % 2 != 0) {
				A -= 1;
			}
			B += A / 2;
			A /= 2;
		}
		else {
			if (B % 2 != 0) {
				B -= 1;
			}
			A += B / 2;
			B /= 2;
		}
	}
	cout << A << " " << B;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    VI a(3);
    REP(i,3){
        cin >> a[i];
    }
    SORT(a);

    if (a[0]==5 && a[1]==5 && a[2]==7){
        cout << "YES" << ENDL;
    } else{
        cout << "NO" << ENDL;
    }

    return 0;
}

Measured memory_bytes: 764
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 10000)

func readLine() string {
	buf := make([]byte, 0, 10000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	_ = readLine()
	vstr := strings.Split(readLine(), " ")
	cstr := strings.Split(readLine(), " ")

	var a []int

	for i := 0; i < len(vstr); i++ {
		vvalue, _ := strconv.Atoi(vstr[i])
		cvalue, _ := strconv.Atoi(cstr[i])
		a = append(a, vvalue-cvalue)
	}

	var ans int

	for i := 0; i < len(a); i++ {
		if a[i] > 0 {
			ans += a[i]
		}
	}

	fmt.Println(ans)
}


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

typedef long long int ll;
using ii= pair<ll,ll>;
#define all(o) (o).begin(),(o).end()
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ld long double
#define eps 0.00000000001

class prioritize{
    public: bool operator() (ii &p1,ii &p2){
        return p1.F<p2.F;
    }
};

int main()
{
    
    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r", stdin);
        freopen("output1.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll n,k;
    cin>>n>>k;

    ll arr[n];
    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }
    
    sort(arr,arr+n);
    ll left=1;
    ll right=1e9;
    ll mid=0;
    ll ans=1e9;

    while(left<=right){
         mid = left + (right-left)/2;
        
        ll count=0;

        for(ll i=0;i<n;i++){
            ll x= floor((arr[i]-1)/mid);
            count+=x;
        }

        if(count<=k){
            right=mid-1;
            ans=min(ans,mid);
        }
        else left=mid+1;
    }
     
    if(k==0||ans==1e9) cout<<arr[n-1]<<"\n";
    else cout<<ans<<"\n";
    

}

Measured memory_bytes: 5112
import java.util.*;
public class Main {
	public static void main(String[] args){
		String az = "abcdefghijklmnopqrstuvwxyz";
		
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String[] someString = new String[n];
		for (int i=0;i<n;i++) {
			someString[i] = scan.next();
		}
		
		int hitCount=0;
		int saveCount=-1;

		// check a-z
		for (int i=0;i<az.length();i++) {
			// check strings
			for (int l=0;l<someString.length;l++){
				// check character in string
				for (int j=0;j<someString[l].length();j++) {
					if (someString[l].charAt(j) == az.charAt(i)) {
						hitCount++;
					}
				}
				if (saveCount == -1 || saveCount > hitCount) {
					saveCount = hitCount;
				}
				hitCount = 0;
			}
			for (int m=0;m<saveCount;m++){
				System.out.print(az.charAt(i));
			}
			saveCount = -1;
		}
	}
}

Measured memory_bytes: 21972
import java.util.Scanner;

class Main{
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		String str = sc.nextLine();
		char[] moji = str.toCharArray();
		
		for(int i=0; i < moji.length; i++){
			if(moji[i] >= 'A' && moji[i] <= 'Z' ){
				moji[i] += 0x20;
			}
			else if(moji[i] >= 'a' && moji[i] <= 'z' ){
				moji[i] -= 0x20;
			}
			
		}
		

		System.out.println(moji);
		
	}
}


Measured memory_bytes: 25936
S = input()
def rle_encode(data):
    encoding = []
    prev_char = ''
    count = 1

    if not data: return ''

    for char in data:
        # If the prev and current characters
        # don't match...
        if char != prev_char:
            # ...then add the count and character
            # to our encoding
            if prev_char:
                encoding.append([int(count), prev_char])
            count = 1
            prev_char = char
        else:
            # Or increment our counter
            # if the characters do match
            count += 1
    else:
        # Finish off the encoding
        encoding.append([int(count), prev_char])
        return encoding

S_rle = list(rle_encode(S))
if len(S_rle) == 1:
  print(sum(range(S_rle[0][0]+1)))
  exit()
total = 0
if S_rle[0][1] == '>':
  head = S_rle[0]
  S_rle.pop(0)
  total += sum(range(head[0]+1))
else:
  head = []
if S_rle[-1][1] == '<':
  tail = S_rle[-1]
  S_rle.pop(-1)
  total += sum(range(tail[0]+1))
else:
  tail = []
body = S_rle[:]
for i in range(len(body)//2):
  num1, num2 = body[2*i][0], body[2*i+1][0]
  total += sum(range(max(num1, num2)+1)) + sum(range(min(num1, num2)))
print(total)

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

int main()
{
  long long int N, K;
  cin >> N >> K;
  long long int R, S, P;
  cin >> R >> S >> P;
  string T;
  cin >> T;
  long long int ans = 0;
  vector<char> hand(N);
  for (int i = 0; i < N; i++)
  {
    if (i < K)
    {
      if (T[i] == 'r')
      {
        ans += P;
        hand[i] = 'p';
      }
      else if (T[i] == 's')
      {
        ans += R;
        hand[i] = 'r';
      }
      else
      {
        ans += S;
        hand[i] = 's';
      }
    }
    else
    {
      if (T[i] == 'r' && hand[i - K] != 'p')
      {
        ans += P;
        hand[i] = 'p';
      }
      else if (T[i] == 's' && hand[i - K] != 'r')
      {
        ans += R;
        hand[i] = 'r';
      }
      else if (T[i] == 'p' && hand[i - K] != 's')
      {
        ans += S;
        hand[i] = 's';
      }
      else
      {
        hand[i] = 'x';
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define all(vec) vec.begin(),vec.end()
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;


void virus(){
          string a, b;
          cin >> a >> b;
          ll n = (ll)a.size(), m = (ll)b.size();
          ll dp[n+1][m+1];
          for(auto i=0; i<=n; i++) dp[i][0] = 0;
          for(auto i=0; i<=m; i++) dp[0][i] = 0;
          
          for(auto i=1; i<=n; i++){
              for(auto j=1; j<=m; j++){
                  if(a[i - 1] == b[j - 1]) dp[i][j] = dp[i-1][j-1] + 1;
                  else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
              }
          }

          string ans = "";
          while(n and m){
              if(dp[n-1][m] == dp[n][m]) n--;
              else if(dp[n][m-1] == dp[n][m]) m--;
              else{
                  ans += a[n-1];
                  n--, m--;
              }
          }
          reverse(all(ans));
          cout<<ans<<endl;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
           //cerr << "\n Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 73856
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<sstream>
#include<numeric>
#include<queue>
#include<cstdio>
#include<iterator>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb(x) push_back(x)
ll mod = 1e9 + 7;
ll inf = 1e9 + 7;
template<typename T, typename U>
T binpow(T a, U n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return (binpow(a, n - 1) * a) % mod;
    else {
        ll b = binpow(a, n / 2) % mod;
        return (b * b) % mod;
    }
}
template<typename T>
T gcd(T a, T b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
template<typename T>
istream& operator>>(istream& str, vector<T>& vec) {
    for (auto& w : vec) str >> w;
    return str;
}
template<typename T>
ostream& operator<<(ostream& str, vector<T>& vec) {
    for (auto& w : vec) str << w << ' ';
    return str;
}

struct segtree {
    vector<set<ll>>mn;
    vector<ll>tree;
    size_t size = 1;
    //void build(ll x, ll lx, ll rx, vector<ll>& vec);
    void build(ll size_) {
        while (size < size_) {
            size *= 2;
        }
        tree.resize(size * 2 - 1);
        mn.resize(size * 2 - 1);
    }
    void update(ll i, ll x, ll v, ll lx, ll rx) {
        if (rx - lx == 1) {
            tree[x] = v;
            return;
        }
        ll m = (lx + rx) / 2;
        if (i < m) {
            update(i, 2 * x + 1, v, lx, m);
        }
        else {
            update(i, 2 * x + 2, v, m, rx);
        }
        tree[x] = tree[2 * x + 1] + tree[2 * x + 2];
    }

    ll get(ll l, ll r, ll x, ll lx, ll rx) {
        if (l <= lx && rx <= r) return tree[x];
        if (rx <= l || lx >= r) return 0;
        ll m = (lx + rx) / 2;
        return get(l, r, 2 * x + 1, lx, m) + get(l, r, 2 * x + 2, m, rx);
    }
};

vector <vector<int>>g;
vector<bool>used;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int>vec(n), divs(1e6);
    cin >> vec;
    ll allg = gcd(vec[0], vec[1]);
    for (int i = 2; i < n; ++i) {
        allg = gcd(allg, vec[i]);
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 2; j * j <= vec[i]; ++j) {
            if (vec[i] % j == 0) {
                divs[j]++;
                while (vec[i] % j == 0) vec[i] /= j;
            }
        }
        if(vec[i]!=1)
            divs[vec[i]]++;
    }

    if (count_if(all(divs), [](int l) {return l > 1; }) == 0) {
        cout << "pairwise coprime";
    }
    else if (allg == 1) {
        cout << "setwise coprime";
    }
    else {
        cout << "not coprime";
    }
}

Measured memory_bytes: 11056
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    Int a,b;
    cin>>a>>b;

    if((a+b) % 2 == 1) {
        cout<<"IMPOSSIBLE"<<endl;
    } else {
        cout<<(a+b)/2<<endl;
    }

    return 0;
}


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

int main(){
  ll n,k,b;
  double h,a;
  k=0;
  cin >> n >> a;
  for(b=1;b<=n;b++){
    cin >> h;
    if(h>=a){
      k+=1;
    }
  }
  cout <<k;
  return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 50;
ll n, m, q, aa[N], b[N], c[N], d[N], mx;

void chk(vector<int> &a){
    ll ans = 0;
    for(int i=0; i<q; i++)
        if(a[b[i]]-a[aa[i]]==c[i])
            ans += d[i];
    mx = max(mx, ans);
}

void rec(int last, int pos, vector<int> &a){
    if(pos == n){
        chk(a);
        return;
    }
    for(int i=last; i<=m; i++){
        a[pos] = i;
        rec(i, pos+1, a);
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> q;
    for(int i=0; i<q; i++){
        cin >> aa[i] >> b[i] >> c[i] >> d[i];
        --aa[i]; --b[i];
    }
    vector<int> z(n);
    rec(1, 0, z);
    cout << mx;
    return 0;
}


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

ll v = 1005,e;
vector<vector<pair<ll,ll>>> graph(v,vector<pair<ll,ll>>());
vector<ll> shortest(v,INF);

bool bellmanford(ll start){
    shortest[start] = 0;
    int cnt = 0;
    while(1){
        bool update = false;
        for(int i=0;i<v;i++){
            if(shortest[i] == INF) continue;
            for(pair<ll,ll> edge:graph[i]){
                if(shortest[edge.second] > shortest[i] + edge.first){
                    shortest[edge.second] = shortest[i] + edge.first;
                    update = true;
                }
            }
        }
        if(!update) break;
        cnt ++;
        if(cnt > v) return false;
    }
    return true;
}

int main(){
    int start;
    cin >> v >> e >> start ;
    rep(i,e){
        int s,t,d;
        cin >> s >> t >> d;
        graph[s].push_back(make_pair(d,t));
    }

    if(!bellmanford(start)){
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }

    rep(i,v){
        if(shortest[i] == INF) cout << "INF" << endl;
        else cout << shortest[i] << endl;
    }
}


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

int main() {
    int64_t N, K;
    cin >> N >> K;

    vector<int64_t> A(N);
    for (int64_t& a : A) {
        cin >> a;
    }

    for (int64_t i = K; i < N; i++) {
        cout << (A[i - K] < A[i] ? "Yes" : "No") << endl;
    }
}

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

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

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

  vector<vector<int>> graph(n);
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
    }

  int ans = 0;

  for(int i = 0; i < n; i++){
    bool good = true;
    for(long unsigned int j = 0; j < graph[i].size(); j++){
      int c = graph[i][j];
      if(h[i] <= h[c])  good = false;
    }
    if(good)  ans++;
  }

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


Measured memory_bytes: 9024
#include<stdio.h>

int main(){
		int i;
		char s[5];
		scanf("%s",s);
		for(i=1;s[i]!=0;i++){
				if(s[i-1]=='A'&&s[i]=='C'){
						puts("Yes");
						return 0;
				}
		}
		puts("No");
		return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int c=0;int j=0;
    for(int i=0;i<n;i++){
        if(s[i]=='(')c++;
        else if(s[i]==')' && c==0)j++;
        else c--;
    }
    for(int i=0;i<j;i++)cout<<'(';
    cout<<s;
    for(int i=0;i<c;i++)cout<<')';
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int  n;
    cin >> n;
    vector<pair<long,long>> prvec;
    long a,b;
    rep(i,n){
        cin >> a >> b;
        prvec.push_back(make_pair(b,a));
    }
    long amari = 0;
    long past = 0; 
    sort(prvec.begin(),prvec.end());
    rep(i,n){
        pair<long,long> pr=prvec[i];
        amari+=(pr.first-past);
        past=pr.first;
        amari-=pr.second;
        if(amari<0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
int hp,HP;
int h,w;
string mp[101];
int dmg[1<<8];
string seq;
int P,p[12];

void Max(int &a,int b){a=max(a,b);}

void Go(int &x,int &y,char ch){
  if(ch=='U') y--;
  if(ch=='D') y++;
  if(ch=='L') x--;
  if(ch=='R') x++;
}

int dp[1010][1<<12];
void update(int idx,int bit,int hp,int dmg,int i){
  Max(dp[i][bit],hp-dmg);
  if(idx==P||hp-dmg>0) return;
  update(idx+1,bit,hp,dmg,i);
  if(bit>>idx&1)return;
  update(idx+1,bit|(1<<idx),min(HP,hp+p[idx]),dmg,i);
}

bool DP(){
  int x = 0,y = 0,size=seq.size();
  memset(dp,0,sizeof(dp));
  dp[0][0] = hp;
  for(int i=0;i<size;i++){ 
    Go(x,y,seq[i]);
    for(int bit=0;bit<(1<<P);bit++)
      if(dp[i][bit])update(0,bit,dp[i][bit],dmg[mp[y][x]],i+1);
  }

  for(int i=0;i<(1<<P);i++) if(dp[size][i])return 1;
  return 0;
}


int main(){
  int cnt=0;
  while(1){
    cnt++;
    cin>>hp>>HP;
    if(!hp&&!HP) return 0;
    cin>>h>>w;
    for(int i=0;i<h;i++)cin>>mp[i];

    int Alpha;
    cin>>Alpha;
    for(int i=0,cost;i<Alpha;i++){
      char ch;
      cin>>ch>>cost;
      dmg[ch] = cost;
    }
    
    int s;
    cin>>s;
    seq.clear();
    for(int i=0,num;i<s;i++){
      char ch;
      cin>>ch>>num;
      seq+=string(num,ch);
    }

    cin>>P;
    for(int i=0;i<P;i++)cin>>p[i];
    cout<<(DP()? "YES":"NO")<<endl;
  }
  return 0;
}

Measured memory_bytes: 19172
N, M = map(int, input().split())
# 素因数分解
def factorization(N):
    prime = primelist(int(N**(1/2))+2)
    factor = [0 for i in range(int(N**(1/2)+2))]
    isprime = False
    for i in prime:
        while N % i == 0:
            N = N // i
            factor[i] += 1
    if sum(factor) == 0:
        isprime = True
    if N != 1:
        factor.append(1)
    return factor, isprime

# 素数
def primelist(N):
    prime = [2]
    for i in range(3, N+1):
        flag = 1
        for j in prime:
            if i % j == 0:
                flag = 0
                break
        if flag == 1:
            prime.append(i)
    return prime

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
factor = factorization(M)[0]
ans = 1


for i in factor:
    ans *= cmb(N+i-1, i)
    ans %= 1000000007

print(ans)

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#define llint long long
#define mod 1000000007

using namespace std;

llint m;
string s;
llint sum[10];

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

  cin >> m >> s;
  int lead = s[0]-'0';
  reverse(s.begin(),s.end());

  if(s.size() == 1 && m == 0){
    cout << 0 << endl;
    return 0;
  }

  llint mul = 1;
  for(int i = 0; i < s.size(); i++){
    (sum[s[i]-'0'] += mul) %= mod;
    mul *= 10, mul %= mod;
  }

  llint perm[10];
  for(int i = 0; i < 10; i++) perm[i] = i;
  do{
    if(perm[lead] == 0) continue;
    llint tmp = 0;
    for(int i = 0; i < 10; i++){
      tmp += perm[i] * sum[i] % mod;
      tmp %= mod;
    }

    if(tmp == m){
      string ans;
      for(int i = 0; i < s.size(); i++){
        ans += (char)(perm[s[i]-'0'] + '0');
      }
      reverse(ans.begin(), ans.end());
      cout << ans << endl;
      return 0;
    }
  }while(next_permutation(perm, perm+10));

  cout << -1 << endl;

  return 0;
}



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

using namespace std;

#define endl '\n'

int n;
map <pair<pair<int,int>,int>,string> mp;
vector <string> op;
string ans;

string solve(int i,int a,int b, int c){
  if(a < 0 || b < 0 || c < 0)
    return "No";

  if(i == n){
    return "";
  }

  char op1 = op[i][0];
  char op2 = op[i][1];
  string ret;

  if(op1 == 'A' && op2 == 'B'){
    ret = solve(i+1,a+1,b-1,c);
    if(ret != "No")
      return "A" + ret;
    ret = solve(i+1,a-1,b+1,c);
    if(ret != "No")
      return "B" + ret;

    return ret;
  }

  if(op1 == 'A' && op2 == 'C'){
    ret = solve(i+1,a+1,b,c-1);
    if(ret != "No")
      return "A" + ret;
    ret = solve(i+1,a-1,b,c+1);
    if(ret != "No")
      return "C" + ret;
    
    return ret;
  }

  ret = solve(i+1,a,b+1,c-1);
  if(ret != "No")
    return "B" + ret;
  ret = solve(i+1,a,b-1,c+1);
  if(ret != "No")
    return "C" + ret;

  return ret;
}

int main(){

  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);
  
  int a,b,c;
  cin >> n >> a >> b >> c; 
  
  op.resize(n);

  for(int i=0;i<n;i++)
    cin >> op[i];

  string ans = solve(0,a,b,c);
  if(ans != "No"){
    cout << "Yes" << endl;
    for(int i=0;i<n;i++)
      cout << ans[i] << endl;
  }
  else
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 38048
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ers erase
#define ins insert
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) cout << #x << "= " << x << '\n';
#define kill(x) return cout << x, 0;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 25;

ll n, a[N], A, B;

int main(){
	cin >> n >> A >> B;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
	}
	ll ans = 0;
	for (int i = 2; i <= n; i++){
		if ((a[i] - a[i - 1]) * A < B){
			ans += (a[i] - a[i - 1]) * A;
		}else{
			ans += B;
		}
	}
	cout << ans;



	return 0;

}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
using namespace std;

int n;
long long a[200005];
long long sum[200005];

long long ABS(long long k)
{
    if (k>0) return k;
    else return -k;
}

int main()
{
    scanf ("%d",&n);
    for (int i=1;i<=n;i++)
        scanf ("%lld",&a[i]);
    for (int i=1;i<=n;i++)
        sum[i]=sum[i-1]+a[i];
    long long ans=1;
    for (int i=1;i<=16;i++)
        ans*=10;
    for (int i=1;i<n;i++)
        {
        long long x,y;
        x=sum[i];
        y=sum[n]-sum[i];
        if (ABS(x-y)<ans) ans=ABS(x-y);
        }
    printf ("%lld",ans);
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>                                
using namespace std;
#define pb push_back
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
const int mill = 1e9;
const ll mln = 1e6;
const int INF = 2e9;
const ll mod = 1e9 + 7;
const ll mod2 = 3e9 - 71;
const ll longINF = 3e18;
const ld pi = acos(-1);
const ld eps = 1e-8;
const int M = 1 << 21;
const ll smod = 998244353;

int a[100005];
int n;
                                                                                                                                                                            
int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);                                                                                         
	cout.tie(0);
	srand(time(0));   
	#ifdef LOCAL
         	freopen("input.txt", "r", stdin);
        	freopen("output.txt", "w", stdout);
        #endif
        cin >> n;
        a[n + 1] = 0;
        for (int i = 1; i <= n; i++)
        	cin >> a[i];
        int sum = 0;
        for (int i = 1; i <= n + 1; i++)
        	sum += abs(a[i] - a[i - 1]);
        for (int i = 1; i <= n; i++) {
        	cout << sum - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]) << '\n';
        }
        return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define fastcin  ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(){
	
	fastcin
	
	double r;
	cin >> r;
	
	cout << 2 * M_PI * r << endl;
	
	return 0;
}


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

const double pi=acos(-1);
typedef long long ll;
const int maxn=1e4+10;
int  f[100005],a[maxn],b[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll h,n;
    cin >> h >> n;
    for(int i=0;i<n;i++)
        cin >> a[i] >> b[i];
    for(int i=1;i<=h;i++)
    {
        int x=1e9+10;
        for(int j=0;j<n;j++)
        {
            if(i-a[j]<=0)
                x=min(x,b[j]);
            else
            {
                int k;
                if(i%a[j])
                    k=i/a[j]+1;
                else
                    k=i/a[j];
                x=min(x,min(f[i-a[j]]+b[j],k*b[j]));
            }
        }
        f[i]=x;
    }
    cout << f[h];
    return 0;
}


Measured memory_bytes: 384
using System;

namespace abc079_c
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int[] n = new int[4];
            for (int i = 0; i < 4; i++)
            {
                n[i] = int.Parse(s[i].ToString());
            }
            if (n[0] + n[1] + n[2] + n[3] == 7)
            {
                Console.Write(n[0] +
                "+" + n[1] +
                "+" + n[2] +
                "+" + n[3]);
            }
            else if (n[0] + n[1] + n[2] - n[3] == 7)
            {
                Console.Write(n[0] +
                "+" + n[1] +
                "+" + n[2] +
                "-" + n[3]);
            }
            else if (n[0] + n[1] - n[2] + n[3] == 7)
            {
                Console.Write(n[0] +
                "+" + n[1] +
                "-" + n[2] +
                "+" + n[3]);
            }
            else if (n[0] + n[1] - n[2] - n[3] == 7)
            {
                Console.Write(n[0] +
                "+" + n[1] +
                "-" + n[2] +
                "-" + n[3]);
            }
            else if (n[0] - n[1] + n[2] + n[3] == 7)
            {
                Console.Write(n[0] +
                "-" + n[1] +
                "+" + n[2] +
                "+" + n[3]);
            }
            else if (n[0] - n[1] + n[2] - n[3] == 7)
            {
                Console.Write(n[0] +
                "-" + n[1] +
                "+" + n[2] +
                "-" + n[3]);
            }
            else if (n[0] - n[1] - n[2] + n[3] == 7)
            {
                Console.Write(n[0] +
                "-" + n[1] +
                "-" + n[2] +
                "+" + n[3]);
            }
            else if (n[0] - n[1] - n[2] - n[3] == 7)
            {
                Console.Write(n[0] +
                "-" + n[1] +
                "-" + n[2] +
                "-" + n[3]);
            }
            Console.WriteLine("=7");
        }
    }
}

Measured memory_bytes: 13140
# -*- coding: utf-8 -*-

N = int(input())

a = [i for i in map(int, input().split())]

a = [0] + a + [0]

total = 0
for i in range(N+1):
    total += abs(a[i] - a[i+1])

for i in range(1, N+1):
    print(total + abs(a[i-1] - a[i+1]) - (abs(a[i-1] - a[i]) + abs(a[i] - a[i+1])))

Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int N, K;
    cin >> N >> K;
    long double p[N];
    for(int i = 0; i < N; i++){
        cin >> p[i];
        p[i] = (p[i] + 1)/2;
    }
    
    long double ans = 0;
    for(int i = 0; i < K; i++) ans += p[i];
    long double tmp = ans;
    for(int i = K; i < N; i++){
        tmp += p[i] - p[i - K];
        ans = max(ans, tmp);
    }
    cout << fixed << setprecision(12) << ans << "\n";
    return 0;
}


Measured memory_bytes: 3328
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    ans=0
    for i in range(1,n+1):
        for j in range(1,i):
            for k in range(1,j):
                if x==i+j+k:
                    ans=ans+1
    print(ans)


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++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;

    }
}

LL comb(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;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int a[3];
    for( int i = 0; i < 3; ++i ) {
        cin >> a[i];

    }
    sort(a, a + 3);
    if( a[0] == a[1] && a[1] != a[2] ||
        a[0] == a[2] && a[0] != a[1] ||
        a[1] == a[2] && a[0] != a[1] ) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> a(M), b(M), c(M, 0); // cの集合はbitで表す
    rep(i, M) {
        cin >> a[i] >> b[i];
        rep(j, b[i]) {
            int t;
            cin >> t;
            t--;
            c[i] += (1 << t);
        }
    }

    vector<vector<ll>> dp(1100, vector<ll>(5000, INF));
    dp[0][0] = 0;

    rep(i, M) {
        rep(j, (1 << N)) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);

            int nj = j | c[i]; // i番目の鍵を使う時の次の集合をbitで

            dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + a[i]);
        }
    }

    cout << (dp[M][(1 << N) - 1] < INF ? dp[M][(1 << N) - 1] : -1) << endl;
}

Measured memory_bytes: 43392
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int N;
  cin>>N;
  string str;
  cin>>str;

  int M = 2;
  vector<int> data(M);
  for (int i = 0; i < str.size(); i++)
  {
    if(str[i] == '(')data[0]++;
    else data[1]++;
  }
  int COUNT = 0;
  for (int i = 0; i < str.size(); i++)
  {
    static int NUML = 0;
    static int NUMR = 0;
    if(str[i] == '(')
    {
      NUML++;
    }
    if(str[i] == ')')
    {
      if(NUML>0)
      {
        COUNT++;
        NUML --;
      }
    }
  }
  data[0] -= COUNT;
  data[1] -=COUNT;
  

  for (int i = 0; i < data[1]; i++)
  {
    cout<<"(";
  }
  cout<<str;
  for (int i = 0; i < data[0]; i++)
  {
    cout<<")";
  }
  cout<<endl;
  
  
  
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    ll max1 = LLONG_MIN, max2 = LLONG_MIN;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] > max1) {
            max2 = max1;
            max1 = A[i];
        } else if (A[i] > max2) {
            max2 = A[i];
        }
    }

    for (ll i = 0; i < N; i++) {
        cout << (A[i] == max1 ? max2 : max1) << endl;
    }
}

Measured memory_bytes: 3200
import scala.collection.mutable
import scala.io.StdIn
import java.util._
import util.control.Breaks._

object Main extends App {
  StdIn.readLine()
  val l = StdIn.readLine().split(" ").map(_.toInt)
  var sum = 0
  for(x <- l.indices){
    for(y <- x+1 until l.length){
      sum += l(x)*l(y)
    }
  }
  println(sum)
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
const long long MOD = 1000000007;
const double PI = 3.1415926535;

int main(void) {
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  if (h == 0 && m == 0) {
    cout << abs(a-b) << endl;
    return 0;
  }

  //短針
  double argh = h * 30 + m * 0.5;
  //長針
  double argm = m * 6;

  double rad;
  //短針を追い越さない時
  if (argh > argm) {
    rad = (argh - argm) / 180.0 * PI;
  } else
    rad = (argm - argh) / 180.0 * PI;
  double ans = pow(a * a + b * b - 2 * a * b * cos(rad), 0.5);
  printf("%0.9lf\n", ans);
  return 0;
}


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


def read():
    N, D = map(int, input().strip().split())
    XY = []
    for i in range(N):
        x, y = map(int, input().strip().split())
        XY.append((x, y))
    return N, D, XY


def solve(N, D, XY):
    ans = 0
    for x, y in XY:
        if x**2 + y**2 <= D**2:
            ans += 1
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 35972
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

void solve(int N, vector<int> H);

void solve(int N, vector<int> H) {
  int ans = 0;
  int hmax = 0;
  for (int h : H) {
    if (h >= hmax) {
      ans += 1;
      hmax = max(hmax, h);
    }
  }
  cout << ans << endl;
}

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  solve(N, H);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = []
for i in range(N):
    a = list(map(int, input().split()))
    pre = [0 for _ in range(N)]
    for k in a[2:]:
        pre[k-1] = 1
    ans.append(pre)
for i in range(N):
    print(' '.join(list(map(str, ans[i]))))



Measured memory_bytes: 5680
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define debug cout << "Ok" << endl;

using namespace std;

void solve(){

	return;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n ,m;

	cin >> n >> m;

	cout << (n > 9 ? m : m + 100*(10-n)) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 

struct DisjointSet {
    vector<int64_t> par; //根.連結成分の根にはその成分の要素数を符号反転して保存する．

    DisjointSet(int64_t n) : par(n, -1) {} //.0-indexed 
    void init(int64_t n) {par.assign(n, -1);}// 初期化

    int root(int64_t x) {
        if (par[x] < 0) return x; //根が負なら自身が根．
        else return par[x] = root(par[x]); //径路圧縮
    }

    // 連結判定
    bool issame(int64_t x, int64_t y) { return root(x) == root(y); }

    bool unite(int64_t x, int64_t y) { // 結合が行われればtrue.行われなければfalse.
        x = root(x); y = root(y); // 径路圧縮
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); 
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int64_t size(int64_t x){ return -par[root(x)]; }
};

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

int N, M, K; cin >> N >> M >> K;
// vector<vector<bool>> F(N+1, vector<bool>(N+1, false)), B(N+1, vector<bool>(N+1, false));
VI cntB(N+1, 0), cntF(N+1, 0);
DisjointSet DS(N+1);
rep(i, 0, M){
    int a, b; cin >> a >> b;
    // F[a][b] = true;
    // F[b][a] = true;
    ++cntB[a];
    ++cntB[b];
    if (!DS.issame(a, b)) DS.unite(a, b);
}
rep(i, 0, K){
    int a, b; cin >> a >> b;
    // B[a][b] = true;
    // B[b][a] = true;
    if (DS.issame(a, b)){
        ++cntF[a];
        ++cntF[b];
    }
}

rep(i, 1, N+1){
    cout << DS.size(i) - cntB[i] - cntF[i] - 1 << ' ';
}

cout  << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  LL n,W;
  cin >> n >> W;
  vector<vector<LL>> v(4,vector<LL>(n)),ruiseki(4,vector<LL>(n+1,0));
  vector<LL> kosu(4,0);
  LL w1;
  LL wi,vi;
  cin >> w1 >> vi;
  v[0][0]=vi;
  kosu[0]++;
  for(LL i=1;i<n;i++){
    cin >> wi >> vi;
    v[wi-w1][kosu[wi-w1]]=vi;
    kosu[wi-w1]++;
  }
  for(LL i=0;i<4;i++){
    sort(v[i].begin(),v[i].begin()+kosu[i],greater<LL>());
    for(LL j=1;j<=kosu[i];j++){
      ruiseki[i][j]=ruiseki[i][j-1]+v[i][j-1];
       // cout << ruiseki[i][j] << " ";
    }
    // cout << endl;
  }
  LL ans=0;
  for(LL i=0;i<=kosu[0];i++){
    for(LL j=0;j<=kosu[1];j++){
      for(LL k=0;k<=kosu[2];k++){
        for(LL l=0;l<=kosu[3];l++){
          // cout << i << j<< k << l << " " << ruiseki[0][i]+ruiseki[1][j]+ruiseki[2][k]+ruiseki[3][l] << endl;
          if(i*w1+j*(w1+1)+k*(w1+2)+l*(w1+3)<=W) ans=max(ans,ruiseki[0][i]+ruiseki[1][j]+ruiseki[2][k]+ruiseki[3][l]);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int N;
int query;

int main()
{
	scanf("%d", &N);
	scanf("%d", &query);
	int sumOfLarger;
	int toFind;
	int ans1 = 0 ;
	int ans2 = 0;
	int ans3 = 0;
	int flag = 0;
	
	for(int i = 0; i <= 2000; i++)
	{
		for(int j = 0; j <= 4000; j++)
		{
			toFind = N - (i + j);
			if((i * 10000) + (j * 5000) + (toFind * 1000) == query && toFind >= 0)
			{
				ans1 = i;
				ans2 = j;
				ans3 = toFind;
				flag = 1;
				// cout << i << " " << j << " " << ans3 << " " << query << " " << (i * 10000) + (j * 5000) + (toFind * 1000) << " ";
			}
		} 
		// if(flag)
		// {
		// 	break;
		// }
	}

	if(!ans1 && !ans2 && ans3 <= 0)
	{
		printf("-1 -1 -1");
	}
	else
	{
		// cout << "1";
		printf("%d %d %d", ans1, ans2, ans3);
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256