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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  
  
  int sum = 0;
  
  for(int i = 0; i < m; i++){
    cin >> a.at(i);
    sum += a.at(i);
  }
  
  if(n-sum>=0){
    cout << n - sum << endl;
  }
  else{
    cout << -1 << endl;
  }
  
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<cmath>

using namespace std;

int main()
{
    int X;
    cin >> X;
    int N = X/100;
    // cout << X << " " << N << endl;
    for (int i=1; i<N+1; ++i)
    {
        if(X>= 100*i && X<= 105*i)
        {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vs = vector<string>;
#define forn(i,n) for (int i=0; i<int(n); ++i)

void cxxio() {
    ios::sync_with_stdio(false);
    cin.tie(0);
}

int main() {
    cxxio();
    int H, W;
    cin>>H>>W;
    vs T(H);
    forn(i, H) cin>>T[i];
    vs A(H, string(W, '.'));
    vs B(H, string(W, '.'));
    forn(i, H) forn(j, W) {
        if (T[i][j]=='#')
            A[i][j]=B[i][j]='#';
        else if (j==0)
            A[i][j]='#';
        else if (j==W-1)
            B[i][j]='#';
        else if (i%2==0)
            A[i][j]='#';
        else
            B[i][j]='#';
    }
    forn(i, H)
        cout<<A[i]<<'\n';
    cout<<'\n';
    forn(i, H)
        cout<<B[i]<<'\n';
}


Measured memory_bytes: 1536
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, H[105];

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", H + i);

  int ans = 0;
  int L = 0;
  
  while (true){
    bool flag = false;
    int L = 0, R = N;
    for (int i = 0; i < N; i++){
      if (H[i] > 0) {
        L = i, flag = true; break;
      }
    }
    if (!flag) break;

    int now = H[L];
    for (int i = L; i <= N; i++){
      if (H[i] == 0){
        R = i; break;
      }
      now = min(H[i], now);
    }
    ans += now;
    for (int i = L; i < R; i++) H[i] -= now;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3760
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long k = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		if (k <= a) {
			System.out.println(1);
			return;
		}
		if (a <= b) {
			System.out.println(-1);
			return;
		}
		long goal = k - a;
		long m = a - b;
		long count = goal / m;
		if (goal % m != 0) {
			count++;
		}
		count = count * 2 + 1;
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
dish=[int(input()) for i in range(5)]
dish_s=[(dish[i]+9)//10 for i in range(5)]
dish_d=[dish[i]%10 for i in range(5)]
sum=0
for i in range(5):
  sum+=dish_s[i]
m=0
for i in range(5):
  if dish_s[i]*10-dish[i]>m:
    m=dish_s[i]*10-dish[i]  
print(sum*10-m)

Measured memory_bytes: 8952
#include <stdio.h>

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

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
 int a , b , t;
 cin >> a >> b >> t;
 int k = t / a;
 cout << k * b << endl;
}

Measured memory_bytes: 256
def insersionSort(A, N, count=0, g=1):
    # 間隔 g で挿入ソートを行う
    for i in range(g, N):
        v = A[i]
        j = i - g 
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            count += 1
        A[j+g] = v
        
    return A, count

def shellSort():
    N, *A = map(int, open(0).read().split())
  
    G = [1]
    cursor = 2
    while True:
        g = (3 ** cursor - 1) // 2
        if g < N:
            G.append(g)
            cursor += 1
        else:
            break
    G = G[::-1]
    
    print(len(G))
    print(' '.join([str(g) for g in G]))
    
    count = 0
    for g in G:
        A, count = insersionSort(A, N, count, g)
    print(count)
    
    for a in A:
        print(a)
        
if __name__=="__main__":
    shellSort()


Measured memory_bytes: 120868
h,w=map(int,input().split())

l=[]
for i in range(h):
    a=input()
    if "#" in a:
        l.append(a)


r=[]
for i in range(w):
    for k in l:
        if k[i]=="#":
            r.append(i)
            break
n=len(l)
new_l=[]

for i in range(n):
    s=""
    for k in r:
        s=s+l[i][k]
    new_l.append(s)

for i in new_l:
    print(i)



Measured memory_bytes: 9220
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	int a, b, k;
	cin >> a >> b >> k;
	vi ans;
	repr(i, a, min(a + k, b)) {
		ans.push_back(i);
	}
	repr(i, max(b - k + 1, a), b+1) {
		ans.push_back(i);
	}

	sort(all(ans));

	ans.erase(unique(all(ans)),ans.end());

	sort(all(ans));

	rep(i, ans.size()) {
		cout << ans[i] << endl;
	}


	return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string str = Console.ReadLine();
        string[] strs = str.Split(' ');

        double x1 = double.Parse(strs[0]);
        double y1 = double.Parse(strs[1]);

        double x2 = double.Parse(strs[2]);
        double y2 = double.Parse(strs[3]);


        double length;

        if (x1 >= x2)
        {
            if (y1 >= y2)
            {
                length = Math.Sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
            }
            else
            {
                length = Math.Sqrt(((x1 - x2) * (x1 - x2)) + ((y2 - y1) * (y2 - y1)));
            }
         
        }
        else
        {
            if (y1 >= y2)
            {
                length = Math.Sqrt(((x2 - x1) * (x2 - x1)) + ((y1 - y2) * (y1 - y2)));
            }
            else
            {
                length = Math.Sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));
            }
        }

        Console.WriteLine(length);
        
        
    }
}

Measured memory_bytes: 9272
#include <iostream>
using namespace std;
using ll = long long;
int main() {
    ll n;
    cin >> n;
    long long p = 100;
    ll o = 0;
    while (p < n)
    {
        p *= 1.01;
        ll k = p;
        o++;
        p = k;
    }
    cout << o << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
    int N, K;
    char c;
    
    
    scanf("%d%c%d", &N, &c, &K);
    
    
    if(N+1 < K*2)
    {
        printf("NO\n");
    }
    else
    {
        printf("YES\n");
    }
    
    //system("pause");
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
  	int d;
  	cin >> d;
  	if(d == 25){
      cout << "Christmas";
    }else if(d == 24){
      cout << "Christmas Eve";
    }else if(d == 23){
      cout << "Christmas Eve Eve";
    }else if(d == 22){
      cout << "Christmas Eve Eve Eve";
    }

}


Measured memory_bytes: 3628
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();

		Integer[] per = {a + b, a - b, a * b};

		Arrays.sort(per, Collections.reverseOrder());

		System.out.println(per[0]);
	}
}


Measured memory_bytes: 22612
def main():
    n = int(input())
    D = [list(map(int, input().split())) for i in range(n)]
    for i in range(2, n):
        if D[i-2][0] == D[i-2][1]:
            if D[i-1][0] == D[i-1][1]:
                if D[i][0] == D[i][1]:
                    print('Yes')
                    exit()
    print('No')
if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
(defun f (x)
    (if (evenp x) (+ 1 (f (/ x 2)))
                  0))

(let* ((n (read))
       (a (make-array n)))
    (dotimes (i n) (setf (aref a i) (read)))
    (princ (apply #'min (mapcar #'f  (coerce a 'list) )))
)

Measured memory_bytes: 14824
import java.util.*;

class Main {

    static char ball = 'A';

    static void swap (char p1, char p2) {
        if ( p1 == ball ) {
            ball = p2;
            return;
        }
        if ( p2 == ball ) {
            ball = p1;
            return;
        }
    }

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            String line = sc.nextLine();
            char p1 = line.charAt(0);
            char p2 = line.charAt(2);
            swap(p1, p2);
        }

        System.out.println(ball);
    }
}

Measured memory_bytes: 12000
n = int(input())
nums = list(map(int, input().split(" ")))

maxnum = -1000000
minnum = 1000000
total = 0

for item in nums:
	if maxnum < item:
		maxnum = item
	if minnum > item:
		minnum = item
		
for item in nums:
	total += item
	
print(str(minnum) + " " + str(maxnum) + " " + str(total))


Measured memory_bytes: 6588
x = int(input())

if 400 <= x and x <= 599:
    print("8")
if 600 <= x and x <= 799:
    print("7")
if 800 <= x and x <= 999:
    print("6")
if 1000 <= x and x <= 1199:
    print("5")
if 1200 <= x and x <= 1399:
    print("4")
if 1400 <= x and x <= 1599:
    print("3")
if 1600 <= x and x <= 1799:
    print("2")
if 1800 <= x and x <= 1999:
    print("1")

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;

int s[555];
int u[555];
int p[555];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<pair<int, int> > x(n);
	for (int i=0;i<n;i++) {
		cin>>x[i].F;
		x[i].S=i+1;
		p[i+1]=x[i].F;
	}
	sort(x.begin(), x.end());
	int i2=1;
	vector<int> ans;
	for (auto xx:x){
		while (i2<xx.F){
			int f=0;
			for (int i=1;i<=n;i++){
				if (s[i]==0&&u[i]+1<i){
					if (f==0||p[i]<p[f]){
						f=i;
					}
				}
			}
			if (f){
				ans.push_back(f);
				u[f]++;
			}
			else{
				for (int i=1;i<=n;i++){
					if (s[i]==1&&u[i]<n){
						f=i;
						break;
					}
				}
				if (!f){
					cout<<"No"<<endl;
					return 0;
				}
				ans.push_back(f);
				u[f]++;
			}
			i2++;
		}
		ans.push_back(xx.S);
		u[xx.S]++;
		s[xx.S]=1;
		if (u[xx.S]!=xx.S){
			cout<<"No"<<endl;
			return 0;
		}
		i2++;
	}
	for (int i=1;i<=n;i++){
		while (u[i]<n) {
			ans.push_back(i);
			u[i]++;
		}
	}
	cout<<"Yes"<<endl;
	for (int t:ans){
		cout<<t<<" ";
	}
	cout<<endl;
}

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

int main(){
  int N,K,T,L;
  double U,V;
  cin >> N >> K >> T >> U >> V >> L;
  cout << setiosflags(ios::fixed) << setprecision(15);
  vector<int> D(N+1,0);
  for(int i=0;i<N;++i){
    cin >> D[i];
  }
  double Time=0;
  int pos=0;
  int Npos=0;
  int until=0;
  while(pos < L){
    if(pos==D[Npos]){
      ++Npos;
      until+=T*V;
      if(until>(K+1)*T*V){
	until=(K+1)*T*V;
      }
    }
    if(until==0){
      Time+=1/U;
    }else{
      Time+=1/V;
      --until;   
    }
    pos+=1;
  }
  cout << setiosflags(ios::fixed) << setprecision(15) << Time << endl;
  return 0;
}

Measured memory_bytes: 1296
using System;
using System.Collections.Generic;
using System.Linq;

namespace Competitive
{
    internal class Solution
    {
        private int N, K;
        
        public void Run()
        {
            int[] ary = Input.ReadIntArray();
            N = ary[0];
            K = ary[1];

            long ret = 0;
            for (int b = K + 1; b <= N; b++)
            {
                int res = K == 0 ? N % b : Math.Max(0, N % b - K + 1);
                ret += (N / b) * (b - K) + res;
            }
            
            Console.WriteLine(ret);

        }
    }

    internal static class Input
    {
        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define MAXN 200010
#define MOD 1000000007
inline int fuck(int x, int p) {
	register int y = 1;
	for (; p; p >>= 1) {
		if (p & 1) y = 1LL * y * x % MOD;
		x = 1LL * x * x % MOD;
	}
	return y;
}
const int inv2 = fuck(2, MOD - 2);
int n, a[MAXN], b[MAXN], c[MAXN], d[MAXN], BIT[MAXN], all, ans;
inline void up(int &x, int y) {
	if ((x += y) >= MOD) x -= MOD;
}
inline int lowbit(int x) { return x & -x; }
inline void add(int x, int y) {
	for (; x <= n; x += lowbit(x)) up(BIT[x], y);
}
inline int qry(int x) {
	register int y = 0;
	for (; x; x -= lowbit(x)) up(y, BIT[x]);
	return y;
}
int count[MAXN];
inline void add(int x) {
	for (; x <= n; x += lowbit(x)) count[x]++;
}
inline int get(int x) {
	register int y = 0;
	for (; x; x -= lowbit(x)) y += count[x];
	return y;
}
int l[MAXN], r[MAXN];
int main() {
	for (int i = scanf("%d", &n); i <= n; i++) scanf("%d", &a[i]), b[a[i]]++;
	for (int i = n; i >= 1; i--) b[i] += b[i + 1];
	all = 1;
	for (int i = 1; i <= n; i++) {
		if ((b[i] -= n - i) <= 0) return puts("0"), 0;
		all = 1LL * all * b[i] % MOD;
	}
	for (int i = 1; i <= n; i++) c[i] = 1LL * (b[i] - 1) * fuck(b[i], MOD - 2) % MOD;
	l[0] = 0;
	for (int i = 1; i <= n; i++) l[i] = c[i] ? l[i - 1] : i;
	r[n + 1] = n + 1;
	for (int i = n; i >= 1; i--) r[i] = c[i] ? r[i + 1] : i;
	d[0] = 1;
	for (int i = 1; i <= n; i++) d[i] = d[i - 1] ? 1LL * d[i - 1] * c[i] % MOD : c[i];
	for (int i = n; i >= 1; i--) {
		int tmp = (qry(r[a[i]] - 1) - qry(a[i] - 1) + MOD) % MOD;
		tmp = 1LL * tmp * all % MOD;
		tmp = 1LL * tmp * inv2 % MOD;
		tmp = 1LL * tmp * fuck(d[a[i]], MOD - 2) % MOD;
		up(ans, tmp);
		add(a[i], d[a[i]]);
	}
	memset(BIT, 0, sizeof(BIT));
	for (int i = 1; i <= n; i++) {
		int tmp = (qry(r[a[i]] - 1) - qry(a[i]) + MOD) % MOD;
		tmp = 1LL * tmp * all % MOD;
		tmp = 1LL * tmp * inv2 % MOD;
		tmp = 1LL * tmp * fuck(d[a[i]], MOD - 2) % MOD;
		tmp = (1LL * (get(n) - get(a[i])) * all % MOD - tmp + MOD) % MOD;
		up(ans, tmp);
		add(a[i], d[a[i]]);
		add(a[i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

#define 	N 1

int cnt1, cnt2, cnt3, n;
void solve(){
	cin>>n;
	rep(i,0,n) {ll t; cin>>t; if(t%4 == 0) cnt1++; else if(t%2) cnt2++; else cnt3++;}
	if((cnt1 >= cnt2)||(cnt3 == 0 && cnt1 == cnt2 - 1)) cout << "Yes "<<endl;
	else cout << "No" << endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
class BinaryIndexedTree:
    def __init__(self,n,default = 0):
        self.s = [default]*(n+1)
        self.n = n
    
    def add(self,val,idx):
        while idx < self.n+1:
            self.s[idx] = self.s[idx] + val
            idx += idx&(-idx)
        return
    
    def get(self,idx):
        res = 0
        while idx > 0:
            res = res + self.s[idx]
            idx -= idx&(-idx)
        return res

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n = int(input())
S = [ord(s) - ord('a') for s in input()[:-1]]

BIT = [BinaryIndexedTree(n) for i in range(26)]

for i,s in enumerate(S):
    BIT[s].add(1,i+1)

Q = int(input())
ans = []
for _ in range(Q):  
    flag,x,y = input().split()

    if flag == "1":
        i = int(x)
        c = ord(y) - ord('a')
        BIT[S[i-1]].add(-1,i)
        BIT[c].add(1,i)
        S[i-1] = c
    else:
        l = int(x)
        r = int(y)
        res = 0
        for i in range(26):
            # print([BIT[i].get(r),BIT[i].get(l)])
            res += (BIT[i].get(r) > BIT[i].get(l-1))
        ans.append(str(res))
print("\n".join(ans))


Measured memory_bytes: 182480
N=int(input())

guide=[]

for i in range(N):
    name,score=map(str,input().split())
    guide.append([i,name,int(score)])

guide_sorted=sorted(guide,reverse=True,key=lambda x:x[2])
guide_sorted=sorted(guide_sorted,key=lambda x:x[1])

for i in range(N):
    print(guide_sorted[i][0]+1)

Measured memory_bytes: 9124
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
int n,m,q,ans;
void gen();
vector<int> cur(1);
vector<vector<int>> poss;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>q;
    vector<int> a(q),b(q),c(q),d(q);
    for(int i=1;i<=m;i++)
        cur[0]=i,gen();
    for(int i=0;i<q;i++)
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    for(auto p:poss)
    {
        int curAns=0;
        for(int i=0;i<q;i++)
            curAns+=d[i]*(p[b[i]-1]-p[a[i]-1]==c[i]);
        ans=max(ans,curAns);
    }
    cout<<ans;
    return 0;
}

void gen()
{
    if(cur.size()==n)
    {poss.push_back(cur);return;}
    for(int i=cur.back();i<=m;i++)
    {
        cur.push_back(i),gen();
        cur.pop_back();
    }
    return;
}


Measured memory_bytes: 9800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
int main()
{
	ios::sync_with_stdio(false),cin.tie(0);
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	if(k<=a) cout << k << endl;
	else if(k<=a+b&&k>a) cout << a << endl;
	else if(k<=a+b+c&&k>a+b) cout << a-(k-a-b) << endl;
	return 0;	
}

Measured memory_bytes: 3652
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int n,t;
	cin >> n >> t;
	int ans = INT_MAX;
	for(int i=0 ; i<n ; i++)
	{
		int c,T;
		cin >> c >> T;
		if(T <= t && c < ans)
			ans = c;
	}
	if(ans == INT_MAX)
	cout << "TLE";
else
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  for(int i=0;i<a.size();i++){
    if(a[i]!=b[i]){
      cout<<"No"<<endl;
      return(0);
    }
  }
  cout<<"Yes"<<endl;
  return(0);
}

Measured memory_bytes: 3628
def make_table(N=200):
    import math
    import itertools
    table = [False for _ in range(N + 1)]
    A = list(range(3, math.ceil(math.sqrt(N)), 2))
    # x^1, y^1, z^1
    for x, y, z in itertools.combinations(A, 3):
        if x * y * z <= N:
            table[x * y * z] = True
    # x^3, y^1
    for x, y in itertools.combinations(A, 2):
        if x * x * x * y <= N:
            table[x * x * x * y] = True
    return table


def resolve():
    table = make_table()
    N = int(input())
    print(sum(table[:N + 1]))


resolve()


Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 1e17
#define nllinf -4e18
 
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > >
 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repupx(a,b,i,x) for(i=a;i<=b;i+=x)
	
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second

#define err(n) cout<<n<<" ";
#define t1 cout<<",";

 ll MOD= 1e9 +7;

void add_self (ll& a, ll b){
	a+= b;
	if(a>=MOD)a-=MOD;
}

void sub_self (ll& a, ll b){
	a-=b;
	a= ((a%MOD)+MOD)%MOD;
}

ll dp[405][405];

int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j,k;
ll n;cin>>n;
ll a[n];repup(0,n-1,i)cin>>a[i];
ll b[n];
b[0]=a[0];
repup(1,n-1,i)b[i]=a[i]+b[i-1];

ll l,r;

repdown(0,n-1,l){
	repup(l,n-1,r){
		if(l==r)dp[l][r]=0;
		else{
			dp[l][r]=llinf;
			ll sum=b[r];
			if(l!=0)sum-=b[l-1];
			repup(l,r-1,k)	dp[l][r]= min(dp[l][r], dp[l][k]+dp[k+1][r]+ sum);
			
		
		}
	}
}


cout<<dp[0][n-1];

}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int32 dx[4] = {-1, 1, 0, 0};
int32 dy[4] = {0, 0, -1, 1};

int main(void){
	int32 h, w, c;
	while(cin >> h >> w >> c && h+w+c){
		auto in = [&](int32 y, int32 x){ return 0<=y&&y<h&&0<=x&&x<w; };
		vector<vector<int64>> p(h, vector<int64>(w));
		REP(i, h) REP(j, w) cin >> p[i][j];
		int32 res = 0;
		function<void(int32, int32)> dfs = [&](int32 cnt, int32 col){
			if(cnt == 5){
				vector<vector<bool>> visited(h, vector<bool>(w, 0));
				queue<PII> q;
				q.push(PII(0, 0));
				visited[0][0] = 1;
				int32 cnt = 0;
				while(q.size()){
					int32 y, x;
					tie(y, x) = q.front(); q.pop();
					cnt++;
					REP(i, 4){
						int32 yy = y+dy[i], xx = x+dx[i];
						if(!in(yy, xx)) continue;
						if(!visited[yy][xx] && p[yy][xx] == p[y][x]){
							visited[yy][xx] = 1;
							q.push(PII(yy, xx));
						}
					}
				}
				res = max(res, cnt);
				return;
			}
			vector<vector<int64>> tmp = p;
			int32 fc = p[0][0];
			vector<vector<bool>> visited(h, vector<bool>(w, 0));
			visited[0][0] = 1;
			queue<PII> q;
			q.push(PII(0, 0));
			while(q.size()){
				int32 y, x;
				tie(y, x) = q.front(); q.pop();
				p[y][x] = col;
				REP(i, 4){
					int32 yy = y+dy[i], xx = x+dx[i];
					if(!in(yy, xx)) continue;
					if(!visited[yy][xx] && p[yy][xx] == fc){
						visited[yy][xx] = 1;
						q.push(PII(yy, xx));
					}
				}
			}
			if(cnt < 3) REP(i, 6) dfs(cnt+1, i+1);
			else dfs(cnt+1, c);
			p = tmp;
		};
		REP(i, 6) dfs(0, i+1);
		cout << res << endl;
	}
}


Measured memory_bytes: 3148
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};

long long dp[110][112345]; // dp[i][j] : i番目までみて、重さj以下で作れる集合のうち、最大価値
int N,W;
long long w[110], v[110];

long long rec(int x, int tw){ // dp[x][tw] を求める関数
    if(x == 0) return 0;
    if(dp[x][tw] != LINF) return dp[x][tw];

    long long res = -LINF;

    res = max(res, rec(x-1, tw)); 
    if(tw-w[x-1] >= 0) res = max(res, rec(x-1, tw-w[x-1])+v[x-1]);

    return dp[x][tw] = res;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    cin >> N >> W;
    for(int i = 0; i < N; i++){
        cin >> w[i] >> v[i];
    }
    REP(i,110) REP(j,112345) dp[i][j] = LINF;

    long long ans = rec(N,W);
    cout << ans << endl;

}

Measured memory_bytes: 96768
if __name__ == "__main__":
    # N: 夏休み日数, M: 宿題個数
    N, M = map(int, input().split(" "))
    # 宿題実行にかかる日数
    Asum = sum(map(int, input().split(" ")))

    print(max(N - Asum, -1))

Measured memory_bytes: 9504
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int H, W;
string s[100];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int main() {
  cin >> H >> W;
  rep(i, 0, H) { cin >> s[i]; }

  rep(i, 0, H) {
    rep(j, 0, W) {
      if (s[i][j] == '#') {
        bool ok = false;
        rep(k, 0, 4) {
          int ni = i + dx[k];
          int nj = j + dy[k];
          if (ni < 0 || ni >= H) continue;
          if (nj < 0 || nj >= W) continue;
          if (s[ni][nj] == '#') ok = true;
        }
        if (!ok) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int ax[100000], ay[100000];
int main() {
  int an, bn,r;
  while(cin>>an>>bn>>r,an) {
    vector<int> X[10000];
    
    REP(i, an)
      cin >> ax[i] >> ay[i];
    REP(i, bn) {
      int x,y;
      cin >> x >> y;
      X[y].push_back(x);
    }
    REP(y, 10000)
      sort(ALL(X[y]));
    int dx[8*r+1];

    REP(i, 8*r+1) {
      int dyy = i-4*r;
      dx[i] = (int)sqrt(16*r*r-dyy*dyy);
//      cout << i << " " <<dx[i] << endl;
    }

    int res = 0;
    REP(i, an) {
      for (int y=max(0, ay[i]-4*r); y <= ay[i]+4*r; ++y ) {
//        cout << y <<":"<< endl;
        if (y>=10000) break;
        res += upper_bound(ALL(X[y]), ax[i]+dx[y-ay[i]+4*r]) - lower_bound(ALL(X[y]), ax[i]-dx[y-ay[i]+4*r]);
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 2208
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){ 
	while(true){
		int H,W;
		cin >> H >> W;
		if(H==0 && W==0){
			break;
		}
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

typedef long long ll;

int main() {
    ll n, h;    cin >> n >> h;
    ll *a = new ll[n], *b = new ll[n];

    ll a_m = 0;
    ll g = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        a_m = max(a[i], a_m);
    }
    sort(b, b+n, greater<ll>());
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        if (b[i] > a_m && sum < h) {
            g++;
            sum += b[i];
        }
    }

    if (sum >= h)
        cout << g << endl;
    else
        cout << (h-sum + a_m-1)/a_m + g << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	int ans = 0;
	while (n > 0) {
		n /= k;
		ans++;
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define li long long int
#define pb push_back
const li limit=999999;

int main() {
    li t,i,j,l=0;
    li N,M,K,Z;
    string s;
    cin>>N>>s;
    li wc=0,rc=0;
    for(auto it: s)
    {
        if(it == 'W')
            wc++;
        else
            rc++;
    }
    li ans=N; t=0;
    for(i=0;i<rc;i++)
    {
        if(s[i]=='W')
        t++;
    }
    ans=min(ans,t);
    t=0;
    for(i=rc;i<N;i++)
    {
        if(s[i]=='R')
        t++;
    }
    ans=min(ans,t);
        cout<<ans;
    return 0;
}


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

int n;


int main(){
  while(cin>>n, n!=0){

    int counter=n;

    for(int k=1;k<=n;k++){
      for(int i=2;i<=sqrt(n+k);i++){
	if(((n+k)%i)==0){
	  counter--;
	  break;
      }
      }
    }

    cout<<counter<<endl;

  }

  return 0;
}

Measured memory_bytes: 3032
N, T = [int(i) for i in input().split(' ')]
t = [int(i) for i in input().split(' ')]
ans = 0

for i in range(1,N):
    if t[i]-t[i-1]<=T:
        ans += t[i]-t[i-1]
    else:
        ans += T
ans += T
print(ans)

Measured memory_bytes: 25196
s=int(input())
a = list(map(int,input().split()))
c=[0]*3
count =0
if len(a)>=3:
    for i in range(0,s-2):
        c[0]=a[i]
        for j in range(i+1,s-1):
            c[1]=a[j]
            for k in range(j+1,s):
                c[2]=a[k]
                b=sorted(c,reverse=True)
                if b[0]!=b[1] and b[2]!=b[1] and b[0]!=b[2] and b[0]<b[1]+b[2]:
                    count+=1
print(count)

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

using namespace std;

int main()
{
    int n, m;
    
    while (scanf("%d %d", &n, &m) && n){
        string names[1024];
        int D[1024], S[1024];
        
        for (int i = 0; i < n; i++){
            char tmp[128];
            scanf("%s %d %d", tmp, D + i, S + i);
            names[i] = (string)tmp;
        }
        
        for (int i = 0; i < m; i++){
            int x;
            bool f = false;
            scanf("%d", &x);
            for (int j = 0; j < n; j++){
                if (S[j] - D[j] + 1 <= x && x <= S[j]){
                    f = true;
                    printf("%s %d\n", names[j].c_str(), x - S[j] + D[j]);
                }
            }
            if (!f) printf("Unknown\n");
        }
    }
    
    return (0);
}

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

cna=0
for i,a in enumerate(A):
    for at in A[i+1:]:    
        if a>at:
            cna+=1

cna2=0
for a in A:
    for at in A:    
        if a>at:
            cna2+=1


kt=(K-1)*(K)//2

print((K*cna+kt*cna2)%tmp)


Measured memory_bytes: 3188
import sys, math, itertools
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
MOD = 998244353
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def factorialMod(n, p):
    fact = [0] * (n+1)
    fact[0] = fact[1] = 1
    factinv = [0] * (n+1)
    factinv[0] = factinv[1] = 1
    inv = [0] * (n+1)
    inv[1] = 1
    for i in range(2, n + 1):
        fact[i] = (fact[i-1] * i) % p
        inv[i] = (-inv[p % i] * (p // i)) % p
        factinv[i] = (factinv[i-1] * inv[i]) % p
    return fact, factinv

def combMod(n, r, fact, factinv, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

def resolve():
    N, M, K = LI()

    ans = 0
    fact, factinv = factorialMod(N, MOD)

    for i in range(K + 1):
        ans += combMod(N - 1, i, fact, factinv, MOD) * M * pow(M - 1, N - 1 - i, MOD)
        ans %= MOD

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 32516
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct UnionFind{
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        }
         else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
signed main(){
    int N,M;
    cin >> N >> M;
    UnionFind uf(N);
    for(int i = 0; i < M; i++) {
        int X,Y,Z;
        cin >> X >> Y >> Z;
        X--;Y--;
        uf.unite(X,Y);
    }
    set<int>st;
    for(int i = 0; i < N; i++) {
        int X = uf.find(i);
        st.insert(X);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 9584
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}
typedef long long ll;

int main(void){
    ll a, b, c;
    cin>>a>>b>>c;
    if(4*a*b<(c-(a+b))*(c-(a+b)) && c>a+b){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

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

int main(){
  ll n;cin>>n;
  vector<int>a(n);
  map<ll,ll>mp;
  ll sum=0;   
  rep(i,n){
    cin>>a[i];
    mp[a[i]]++;
    sum+=a[i];
  }
    
  ll q;cin>>q;
  vector<int>b(q,1),c(q,1);
  rep(i,q)cin>>b[i]>>c[i];
  
  rep(i,q){
	if(mp[b[i]]>0){
      sum+=mp[b[i]]*(c[i]-b[i]);
      mp[c[i]]+=mp[b[i]];
      mp[b[i]]=0;
    }
    cout<<sum<<endl;
  }
  
}

Measured memory_bytes: 10080
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void B_task();

int main()
{
	B_task();
	fflush(stdout);
	return 0;
}

static void B_task()
{
	int N;
	get1int(N);

	int taste[50] = { 0 };
	for (int i = 0; i < N; i++) {
		get1int(taste[i]);
	}

	int sum = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			sum += taste[i] * taste[j];
		}
	}
	printf("%d\n", sum);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll diff = A - B;
    if (abs(diff) >= 1e18) {
        cout << "Unfair" << endl;
        return 0;
    }
    if (K % 2 == 0) {
        cout << diff << endl;
    } else {
        cout << -diff << endl;
    }
    return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#define ll long long
#define ull unsigned long long
using namespace std;

vector<ll> A;
vector<vector<vector<ll>>> DP;

ll solve(int start, int end, int player){
	if (start > end){
		return 0;
	}
	
	ll &dp = DP.at(start).at(end).at(player);
	if (dp != -1){
		return dp;
	}

	if (player == 1){
		ll ans1 = solve(start + 1, end, 2) + A.at(start);
		ll ans2 = solve(start, end - 1, 2) + A.at(end);
		return (dp = max(ans1, ans2));
	} else if (player == 2){
		ll ans1 = solve(start + 1, end, 2) + A.at(start);
		ll ans2 = solve(start, end - 1, 2) + A.at(end);
		return (dp = -max(ans1, ans2));
	}
	exit(2);
}

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

	int n;
	cin >> n;
	A = vector<ll>(n);
	for (ll &a: A) cin >> a;
	DP = vector<vector<vector<ll>>>(n, vector<vector<ll>>(n, vector<ll>(3, -1)));
	ll ans = solve(0, n - 1, 1);
	cout << ans;
	
	return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<long> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	cout << A[N - 1] - A[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#
# Yet I'm feeling like
# 	There is no better place than right by your side
# 		I had a little taste
# 			And I'll only spoil the party anyway
# 				'Cause all the girls are looking fine
# 					But you're the only one on my mind


import sys
#import re
# inf = float("inf")
sys.setrecursionlimit(10000000)

# abc='abcdefghijklmnopqrstuvwxyz'
# abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
# mod,MOD=1000000007,998244353
# vow=['a','e','i','o','u']
# dx,dy=[-1,1,0,0],[0,0,1,-1]

# from cmath import sqrt
from collections import deque, Counter, OrderedDict,defaultdict
from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
# from math import ceil,floor,log,sqrt,factorial,pow,pi,gcd,log10,atan,tan
# from bisect import bisect_left,bisect_right
# import numpy as np

def dfs(curr,parent):
    visited[curr]=True
    value[curr]+=value[parent]
    for i in mydict[curr]:
        if not visited[i]:
            dfs(i,curr)


def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n,q=get_ints()
mydict=defaultdict(list)
parent=[0]*(n+1)
for i in range(n-1):
    a,b=get_ints()
    mydict[a].append(b)
    parent[b]=a

value=[0]*(n+1)
while q>0:
    index,score=get_ints()
    value[index]+=score
    q-=1

visited=[False]*(n+1)
dfs(1,0)

print(*value[1:])

Measured memory_bytes: 246564
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, L;
  cin >> N >> L;
  vector<pair<int, bool>> T(N);
  T.at(0).first = L;
  int ts = L;
  for(int i=1;i<N;i++){
    T.at(i).second = false;
    T.at(i).first = T.at(i-1).first + 1;
    ts += T.at(i).first;
  }
  for(int i=0;i<N;i++){
    if(T.at(i).first < 0){
      T.at(i).first *= -1;
      T.at(i).second = true;
    }
  }
  sort(T.begin(), T.end());
  if(T.at(0).second) cout << ts + T.at(0).first << endl;
  else cout << ts - T.at(0).first << endl;
}

Measured memory_bytes: 256
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define ll long long
#define fir first
#define sz(a) int((a).size())

int a[85];
ll ans=1000;
signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n-1;i++)
	{
		if(a[i+1]>a[i])
		{
			ans+=(a[i+1]-a[i])*(ans/a[i]);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    long long a_, n ,m, b, c, ans = 0;
    cin >> n >> m;
    vector<int> a;
    vector<pair<int, int>> cb;
    for(int i = 0; i < n; ++i) {
        cin >> a_;
        a.push_back(a_);
    }
    for(int i = 0; i < m; ++i) {
        cin >> b >> c;
        cb.push_back(make_pair(c, b));
    }
    sort(a.begin(), a.end(), greater<int>());
    sort(cb.begin(), cb.end(), greater<pair<int, int>>());
    int j = 0;
    for(int i = 0; i < n; ++i) {
        if(j < m) {
            if(a[i] >= cb[j].first) {
                ans += a[i];
            } else {
                if(cb[j].second > 0) {
                    ans += cb[j].first;
                    cb[j].second--;
                    i--;
                    n--;
                    if(cb[j].second == 0) {
                        j++;
                    }
                }
            }
        } else {
            ans += a[i];
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1784
using System;
using System.Collections.Generic;
using System.Linq;

namespace _2150
{
    class Program
    {
        static List<int> prime;
        static void makeprime()
        {
            prime = new List<int>();
            for (int i = 2; i < 150000; i++)
            {
                bool flag = true;
                foreach (var item in prime)
                {
                    if (i % item == 0) { flag = false; break; }
                }
                if (flag) prime.Add(i);
            }
        }
        static void Main(string[] args)
        {
            makeprime();
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x.Max() == -1) break;
                int start = 0;
                while (prime[start] <= x[0]) start++;
                List<int> list = new List<int>();
                for (int i = start; i < start + 200; i++)
                {
                    for (int j = i; j < start + 200; j++)
                    {
                        list.Add(prime[i] + prime[j]);
                    }
                }
                var ret = list.ToArray();
                Array.Sort(ret);
                Console.WriteLine(ret[x[1] - 1]);
            }
        }
    }
}


Measured memory_bytes: 10524
import sys
input = sys.stdin.readline
import math

s = input()

cut_n = []
cut_s = []

pre_s = 'R'
count = 0
for i in range(len(s)):
    if pre_s == s[i]:
        count += 1
    else:
        cut_n.append(count)
        cut_s.append(pre_s)
        pre_s = s[i]
        count = 1

s = s[:len(s)-1]
out_n = [0]*len(s)

total_n = -1
for t_n, t_s in zip(cut_n, cut_s):
    if t_s == 'R':
        total_n += t_n

        out_n[total_n] += math.ceil(t_n/2)
        out_n[total_n+1] += math.floor(t_n/2)
    else:
        total_n += 1
        out_n[total_n] += math.ceil(t_n/2)
        out_n[total_n-1] += math.floor(t_n/2)

        total_n += (t_n - 1)

out_n = [str(n) for n in out_n]
print(' '.join(out_n))


Measured memory_bytes: 11924