akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

vi edg[100100];
int mem[100100];
int dp(int at){
    if(mem[at] != -1) return mem[at];
    int ans = 0;
    rep(i,0,edg[at].size()){
        ans = max(ans, 1+dp(edg[at][i]));
    }
    return mem[at] = ans;
}


int main()
{
    cin.sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    memset(mem,-1,sizeof(mem));
    rep(i,0,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        edg[a].pb(b);
    }
    int ans = -1;
    rep(i,0,n){
        ans = max(ans, dp(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int d;
    scanf("%d", &d);
    if(d == 25) printf("Christmas\n");
    else if(d == 24) printf("Christmas Eve\n");
    else if(d == 23) printf("Christmas Eve Eve\n");
    else if(d == 22) printf("Christmas Eve Eve Eve\n");
    return 0;
}

Measured memory_bytes: 3644
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        r: usize,
        g: usize,
        b: usize,
        n: usize
    }
    let mut cnt = 0;
    for rr in (0..(n / r) + 1).rev() {
        let rk = rr * r;
        let n_r = n - rk;
        for gg in (0..(n_r / g) + 1).rev() {
            let gk = gg * g;
            if (n_r - gk) % b == 0 {
                cnt += 1;
            }
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
N=int(input())
lis=[]
count=0
for i in range(1,N+1):
  for j in range(1,i+1):
    if i%j==0:
        if i%2!=0:
            count+=1
  if count==8:
    lis.append(i)
  count=0
print(len(lis))

Measured memory_bytes: 3060
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b,c=map(int,input().split())
    L=[int(input())for _ in range(n)]
    INF=10**9
    def dfs(cur,aa,bb,cc):
        if cur==n:
            return abs(aa-a)+abs(bb-b)+abs(cc-c)-30 if aa*bb*cc>0 else INF
        ret0=dfs(cur+1,aa,bb,cc)
        ret1=dfs(cur+1,aa+L[cur],bb,cc)+10
        ret2=dfs(cur+1,aa,bb+L[cur],cc)+10
        ret3=dfs(cur+1,aa,bb,cc+L[cur])+10
        return min(ret0,ret1,ret2,ret3)
    print(dfs(0,0,0,0))

if __name__=='__main__':
    main()

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

int main(){
    long N,M,ans=0;
    cin >> N >> M;
    vector<long> X(M);
    vector<long> DIF(M-1);
    for(int i=0;i<M;++i) cin >> X[i];
    sort(X.begin(),X.end());
// N個が0,N-M個が数直線小さい順のabs差
    for(int i=0;i<M-1;++i) DIF[i] = X[i+1]-X[i];
    sort(DIF.begin(),DIF.end());
    for(int i=0;i<M-N;++i) ans += DIF[i];
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
    int a, b, x = 0, n = 1;
    scanf("%d %d", &a, &b);
    for(int i = 0; i < a; i++) n *= 100;
    for(int i = 0; i < b; i++){
        x += n;
        if(x % (n*100) == 0) x += n;
    }
    printf("%d", x);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
typedef array<int, 3>arr3;


void solve() {
	int A, B; cin >> A >> B;
	print(max({ A + B,A - B,A*B }));
}

signed main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
		solve();
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
    boost();
    ll t=1;
    //cin >> t;
    while(t--){
       ll x,y;
       cin >> x >> y;
       ll a,b;
       if(y%2==0){
           y=y/2;
           b=y-x;
           a=x-b;
           if(a<0||b<0)
           cout <<"No" << endl;
           else
           cout << "Yes" << endl;
       }
       else
       cout << "No" << endl;
    }
}

Measured memory_bytes: 3612
n,s = map(int, input().split())

for x in range(n+1):
    for y in range(n+1-x):
        tmp = n-x-y
        if (x*10000+y*5000+tmp*1000) == s:
            print('{} {} {}'.format(x,y,tmp))
            exit(0)

print('-1 -1 -1')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    ios
    int n,cnt=0,ans=0;
    cin>>n;

    for(int i=1;i<=n;i+=2)
    {
        cnt=0;
        for(int j=1;j*j<=i;j++)
        {
            if(i%j==0)
            {
                cnt++;
            }
        }
        if(cnt==4)
        ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        for(int i=1;;i++){
            int x = sc.nextInt();

            if(x==0){
                break;
            }else{
                System.out.printf("Case %d: %d\n",i,x);
            }
        }
    }
}


Measured memory_bytes: 61856
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define int long long

using namespace std;

const int N = 5e5 + 5, mod = 1e9 + 7;

int n, ar[N], cnt[N], l, r, pref[N], len1, len2, fc[N], rf[N];

int binpow (int a, int b)
{
    if (b == 0) return 1ll;

    if (b & 1)
        return a * binpow(a, b - 1) % mod;

    int res = binpow(a, b / 2);

    return res * res % mod;
}
int Cnk(int n, int k)
{
    return fc[n] * rf[k] % mod * rf[n - k] % mod;
}
main ()
{
    scanf("%lld", &n);

    fc[0] = 1;

    rf[0] = binpow( fc[0], mod - 2 );

    for (int i = 1; i < N; i++)
    {
        fc[i] = fc[i - 1] * i % mod;
        rf[i] = binpow( fc[i], mod - 2 );
    }

    for (int i = 1; i <= n + 1; i++)
    {
        scanf("%lld", &ar[i]);
        if (cnt[ ar[i] ])
        {
            l = cnt[ ar[i] ];
            r = i;
        }
        cnt[ ar[i] ] = i;
    }
    len1 = l - 1;
    len2 = n - r + 1;

    for (int k = 1; k <= n + 1; k++)
    {
        int ans = Cnk(n + 1, k);

        if (len1 + len2 >= k - 1)
        {
            ans -= Cnk(len1 + len2, k - 1);

            if (ans < 0)
                ans += mod;
        }

        cout << ans << endl;
    }
}


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

using namespace std;

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

  int min_m = 1 << 10;
  for (int i = 0; i < N; ++i) {
    int m;
    cin >> m;
    X -= m;
    min_m = min(min_m, m);
  }

  int ans = N + X / min_m;

  cout << ans;

  return 0;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;

int main() {
	int a, b, c;

	cin >> a >> b >> c;

	if (a <= c && c <= b || b <= c && c <= a)Yes;
	else No;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<stack>
#include<map>
#include<bitset>
#include <cstdlib>
#include<cstring>
#define ll long long;
#define pb push_back
const int MOD = 1e9 + 7;
const int qq = 1e5 + 10;
const int INF = 1e9 + 10;
const double eps = 1e-11;
const double pi = acos(-1.0); 
const double PI = 3.1415926535897932384;
using namespace std;
#define ma = 2147483647;
#define mi = -2147483647;
int main()
{

	ios::sync_with_stdio(0); cin.tie(0);

	long double a, b, h, m;
	cin >> a >> b >> h >> m;

	double md = double( m) * 6.0;
	double hd = double(h) * 30.0 + (double(m) / 60.0 ) * 30.0;
	double de = md - hd;
	if (de < 0)de *= -1.0;
	if (de >= 180.0)
	de = 360.0 - de;
	double ans = sqrt(-2.0 * double(a) * double(b) * cos(de * PI / 180) + double(a) * double(a) + double(b) * double(b));

	//printf("%.20lf", ans);
	//cout.precision(20);cout << ans;
	cout << fixed << setprecision(20) << ans;

	
	return 0;
}

Measured memory_bytes: 4220
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0155

"""
import sys
from sys import stdin
from math import sqrt
input = stdin.readline


def dijkstra(s, G):
    BLACK, GRAY, WHITE = 0, 1, 2
    d = [float('inf')] * 101
    color = [WHITE] * 101
    p = [-1] * 101

    d[s] = 0
    while True:
        mincost = float('inf')
        # ??\??????????????§??????????????¨?????????????????????u???????????????
        for i in range(101):
            if color[i] != BLACK and d[i] < mincost:  # S????±???????????????????S??¨??\?¶?????????????????????????????????????????°???????????????????
                mincost = d[i]
                u = i  # u??????????????????ID
        if mincost == float('inf'):
            break
        color[u] = BLACK  # ?????????u???S????±???????????????´???
        for v in range(101):
            if color[v] != BLACK and G[u][v] != float('inf'):
                # v????????????????????????????????°??????S???????????£???u????????????????????????????????????????????°??????????????±??§??´??°??????
                if d[u] + G[u][v] < d[v]:
                    d[v] = d[u] + G[u][v]
                    p[v] = u
                    color[v] = GRAY
    return d, p


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break

        G = [[float('inf')] * (100+1) for _ in range(100+1)]
        data = []
        for _ in range(n):
            b, x, y = map(int, input().strip().split(' '))
            data.append([b, x, y])

        for i in range(n):
            b1, x1, y1 = data[i]
            for j in range(n):
                b2, x2, y2 = data[j]
                if b1 == b2:
                    continue
                dist = sqrt((x1 - x2)**2 + (y1 - y2)**2)
                if dist <= 50.0:
                    G[b1][b2] = dist
                    G[b2][b1] = dist

        m = int(input())
        for _ in range(m):
            s, g = map(int, input().strip().split(' '))
            if s == g:
                print(s)
                continue
            if (not 1<= s <= 100) or (not 1<= g <= 100):
                print('NA')
                continue
            d, p = dijkstra(s, G)
            if d[g] == float('inf'):
                print('NA')
            else:
                path = [g]
                while p[g] != s:
                    path.append(p[g])
                    g = p[g]
                path.append(s)
                rev = path[::-1]
                print(' '.join(map(str, rev)))


def main2(args):
    while True:
        n = int(input())
        if n == 0:
            break

        for _ in range(n):
            b, x, y = map(int, input().strip().split(' '))

        m = int(input())
        for _ in range(m):
            s, g = map(int, input().strip().split(' '))
            print('NA')


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 8084
#include <cstdio>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

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

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end
int main() {
    unsigned int  A,B,C;

    cin >> A>>B>>C;
    vector<int> s(A+2);
    vector<int> t(B+2);

    cout << min(C, B/A)<<endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    public void Proc()
    {
        int num = int.Parse(Console.ReadLine());
        string[] inpt = Console.ReadLine().Split(' ');
        // inpt = "13 19 9 5 12 8 7 4 21 2 6 11".Split(' ');
        int[] arr = new int[num];
        for (int i = 0; i < num; i++)
        {
            arr[i] = int.Parse(inpt[i]);
        }
        int idx = this.Partition(arr, 0, num - 1);
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < arr.Length; i++)
        {
            if (ans.Length > 0)
            {
                ans.Append(" ");
            }
            if (i == idx)
            {
                ans.Append("[" + arr[i] + "]");
            }
            else
            {
                ans.Append(arr[i]);
            }
        }
        Console.WriteLine(ans.ToString());
    }

    private int Partition(int[] A, int p, int r)
    {
        /*
         * 1 partition(A, p, r)
            2   x = A[r]
            3   i = p-1
            4   for j = p to r-1
            4     if A[j] <= x
            5       i = i+1
            6       A[i] ??¨ A[j] ?????????
            7   A[i+1] ??¨ A[r] ?????????
            8   return i+1
         **/

        int x = A[r];
        int i = p - 1;
        for (int j = p; j <= r - 1; j++)
        {
            if (A[j] <= x)
            {
                i++;
                int tmp = A[i];
                A[i] = A[j];
                A[j] = tmp;
            }
        }
        int tmp2 = A[i + 1];
        A[i + 1] = A[r];
        A[r] = tmp2;
        return i + 1;
    }


    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 18428
import math

menu = []
score = 0
ans = 0
for i in range(5):
    m = int(input())
    score = m % 10
    if score == 0:
        score = 10
    menu.append([m, score])

menu.sort(key=lambda x: x[1], reverse=True)

for i in range(5):
    if i < 4:
        tmp = math.ceil(menu[i][0] / 10) * 10
    else:
        tmp = menu[i][0]
    ans += int(tmp)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
struct UnionFind{
    vector<long long> size, par;
    UnionFind(long long n) {
        size.resize(n, 0);
        par.resize(n, 0);
        for (long long i = 0; i < n;i++){
            maketree(i);
        }
    }
    void maketree(long long x){
        par[x] = x;
        size[x] = 1;
    }
    long long findroot(long long x){
        if (x != par[x]) par[x] = findroot(par[x]);
        return par[x];
    }
    bool issame(long long x,long long y){
        return findroot(x) == findroot(y);
    }
    bool unite(long long x,long long y){
        x = findroot(x);
        y = findroot(y);
        if (x == y) return false;  //already united
        if(size[x]>size[y]){
            par[y] = x;
            size[x] += size[y];
        }
        else{
            par[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    long long treesize(long long x){
        return size[findroot(x)];
    }
};

int main(){
ll n,m;
ll ans = 0;
cin >> n >> m;
ll a[m],b[m];
for (ll i = 0; i < m;i++){
    cin >> a[i]>>b[i];
    a[i]--;
    b[i]--;
}
    for (ll i = 0; i < m; i++) {
        UnionFind uf(n);
        for (ll j = 0; j < m; j++) {
            if (i == j)
                continue;
            else
                uf.unite(a[j], b[j]);
        }
        if (uf.treesize(0) != n) ans++;
    }
cout << ans << endl;
}

Measured memory_bytes: 256
N, A, B, C, D = map(int,input().split())
S = input()

flag = 0

if D > C:
    for i in range(D-B-2):
        if S[B+i] == '#' and S[B+i+1] == '#':
            print('No')
            flag = 1
            break
    if flag == 0:
        for j in range(C-A-2):
            if S[A+j] == '#' and S[A+j+1] == '#':
                print('No')
                flag = 1
                break        
        if flag == 0:
            print('Yes')
else:
    count = 0
    for i in range(D-B+3):
        if S[B-2+i] == '.':
            count += 1
        else:
            count = 0
        if count == 3:
            flag = 1
            break
    if flag == 0:
        print('No')
    else:
        for j in range(C-A-2):
            if S[A+j] == '#' and S[A+j+1] == '#':
                print('No')
                flag = 0
                break        
        if flag == 1:
            print('Yes')
        
        

Measured memory_bytes: 3572
//ΔARC085D
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 222222;
const int inf = 1e9;
int n,q,b[N],f[N],g[N];
pair<int,int> p[N];
int T[N<<2];
void build(int k=1,int l=0,int r=n){
	if(l==r){
		T[k]=inf;
		return;
	}
	int h=l+r>>1;
	build(k<<1,l,h);
	build(k<<1|1,h+1,r);
	T[k]=min(T[k<<1],T[k<<1|1]);
}
void modify(int x,int y,int k=1,int l=0,int r=n){
	if(l==r){
		T[k]=y;
		return;
	}
	int h=l+r>>1;
	if(x<=h)
		modify(x,y,k<<1,l,h);
	else
		modify(x,y,k<<1|1,h+1,r);
	T[k]=min(T[k<<1],T[k<<1|1]);
}
int query(int L,int R,int k=1,int l=0,int r=n){
	if(L<=l&&r<=R)
		return T[k];
	int h=l+r>>1,res=inf;
	if(L<=h)
		res=min(res,query(L,R,k<<1,l,h));
	if(h<R)
		res=min(res,query(L,R,k<<1|1,h+1,r));
	return res;
}
int main()
{
	int i,x,y;
	scanf("%d",&n);
	for(x=1;x<=n;x=x+1)
		f[x]=inf;
	for(i=1;i<=n;i=i+1){
		scanf("%d",b+i);
		if(!b[i])
			b[i]=-1,f[0]++;
	}
	scanf("%d",&q);
	for(i=1;i<=q;i=i+1){
		scanf("%d%d",&x,&y);
		p[i]=make_pair(x,-y);
	}
	sort(p+1,p+q+1);
	build();
	modify(0,f[0]);
	i=1;
	for(x=1;x<=n;x=x+1){
		while(p[i].first==x){
			y=-p[i++].second;
			f[y]=min(f[y],query(x-1,y));
			modify(y,f[y]);
		}
		f[x]=min(f[x],f[x-1]+b[x]);
		modify(x,f[x]);
	}
	printf("%d",f[n]);
	return 0;
}

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

int main() {
  int N, counter = 0, temp = 0;
  cin >> N;

  vector<int> mochi(N);
  for (int i = 0; i < N; i++) {
    cin >> mochi.at(i);
  }
  sort(mochi.begin(), mochi.end());
  // reverse(card.begin(), card.end());
  
  for (int i = 0; i < N; i++) {
    if (temp == mochi.at(i)) {
      continue;
    }
    else {
      counter++;
      temp = mochi.at(i);
    }
  }
  
  cout << counter << endl;
  

  // cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var N, cnt int
	fmt.Scan(&N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}
	A, cnt = bubbleSort(A, N)
	fmt.Println(strings.Trim(fmt.Sprint(A), "[]"))
	fmt.Println(cnt)
}

func bubbleSort(A []int, N int) ([]int, int) {
	finished := true
	cnt := 0
	for finished {
		finished = false
		for i := N - 1; i > 0; i-- {
			if A[i] < A[i-1] {
				A[i], A[i-1] = A[i-1], A[i]
				finished = true
				cnt++
			}
		}
	}
	return A, cnt
}



Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array
const int mxN=2e5;
int n, k, a[mxN];

int check(int p) {
	int c=0;
	for (int i=n-1; i>=0; i--) {
		if (a[i]<=p) break;
		c+=a[i]/p;
	}
	return c;
}

int main()
{   
	cin >> n >> k;
	for (int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);
	int l=1, r=1e9+1;
	while (l<r) {
		int mid=l+(r-l)/2;
		if (check(mid)>k) {
			l=mid+1;
		} else {
			r=mid;
		}
	}
	cout << l;
	return 0;
}

Measured memory_bytes: 4400
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
cnt=0
for i in range(N):
    tmp=0
    A=list(map(int,input().split()))
    for j in range(M):
        tmp+=A[j]*B[j]
    tmp+=C
    if tmp>0:
        cnt+=1
    else:
        cnt+=0
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	long long int N,t=0,f=0;
	long long int a[100000];
	cin >> N;
	for (int i = 1; i <= N; i++){
		cin >> a[i];
	}
	for (int i = 1; i <= N; i++){
		if (a[i] % 4 == 0){
			f++;
		}
		else if (a[i] % 2==0){
			t++;
		}
	}
	if (N % 2 == 0){
		if (2 * f + t >= N){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	else{
		if (3 * f + t >= N){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
def search(a_cards, b_cards, left, right, turn):
  #print(a_cards, b_cards, left, right, turn)
  if a_cards == []:
    return True
  if b_cards == []:
    return False

  ret = False
  if turn == 0:
    if left not in a_cards and right not in a_cards:
      return search(a_cards, b_cards, left, right, 1)
    if left in a_cards:
      ret = ret or search([i for i in a_cards if i != left], b_cards, left - 1, right, 1)
    if right in a_cards:
      ret = ret or search([i for i in a_cards if i != right], b_cards, left, right + 1, 1)
    return ret
  
  ret = True
  if turn == 1:
    if left not in b_cards and right not in b_cards:
      return search(a_cards, b_cards, left, right, 0)
    if left in b_cards:
      ret = ret and search(a_cards, [i for i in b_cards if i != left], left - 1, right, 0)
    if right in b_cards:
      ret = ret and search(a_cards, [i for i in b_cards if i != right], left, right + 1, 0)
    return ret


n = int(input())
all_cards = [i + 1 for i in range(13) if i != 6]
for _ in range(n):
  a_cards = list(map(int, input().split()))
  b_cards = [i for i in all_cards if i not in a_cards]
  if search(a_cards, b_cards, 6, 8, 0):
    print("yes")
  else:
    print("no")


Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define debug(a,b) cerr << #a<<" = "<<a<<"   |   "<<#b<<" = "<<b<<'\n'
#define endl '\n'
#define SZ(x) (int)x.size()
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
typedef vector<pi32> vp32;
typedef vector<pi64> vp64;
const ll mod = 1e9 + 7;
const ll MX = 1e5+10, inf = 1e9 + 7;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int sum=0;
	int x=min(k,a);
	int r1=k-x;
	sum+=x;
	//cerr(sum);
	int y=min(r1,b);
	int r2=r1-y;
	int z=min(r2,c);
	//cerr(z);
	sum+=((-1)*z);
	cout<<sum<<endl;
	return 0;
}




Measured memory_bytes: 3652
s = input()

def check(s):
    n = len(s)
    for i in range(n // 2):
        if s[i] != s[n - 1 - i]:
            return False
    return True

s2 = s[:(len(s) - 1) // 2]
s3 = s[(len(s) + 3) // 2 - 1: ]

# print(s2, s3)

if check(s) and check(s2) and check(s3):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38480
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
using ldb = long double;
using pa = pair < int, int >;
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;
#define pb push_back
#define all(c) c.begin(),c.end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define F  first
#define S  second
#define f(i,x,n) for(int i=x;i<n;i++) 
const int MOD = 1e9 + 7, INF = INT_MAX, N = 5e5 + 10;
const double PI = acos(-1);
const int LINF = LLONG_MAX;

int a, b, c, d,sum;
string s1,s2,s;
char ch1,ch2,ch;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b;
    cout << a*(a-1)/2 + b*(b-1)/2;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
 
using namespace std;
 
main(){
  string S;
  int K;
  cin>>K>>S;
  if(K>=S.size()){
    for(int i=0;i<S.size();i++)printf("%c",S[i]);
  }else{
    for(int i=0;i<K;i++)printf("%c",S[i]);
    printf("...");
  }
}

Measured memory_bytes: 3724
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    string s, t; cin>>s>>t;
    int n = s.size();
    int m = t.size();

    vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
    for(int i=0; i<n; i++){
        dp[i+1][0] = i + 1;
    }
    for(int i=0; i<m; i++){
        dp[0][i+1] = i + 1;
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            dp[i+1][j+1] = min(dp[i][j+1] + 1, dp[i+1][j] + 1);

            if(s[i] == t[j]){
                chmin(dp[i+1][j+1], dp[i][j]);
            }
            else{
                chmin(dp[i+1][j+1], dp[i][j] + 1);
            }
        }
    }

    cout << dp[n][m] << endl;
}


Measured memory_bytes: 6780
#include<bits/stdc++.h>
#define M 100005
#define ll long long
#define P 1000000007
using namespace std;
int n;
char s[M];
int cnt[M][30];
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	
	for(int i=1;i<=n;i++){
		for(int j=0;j<26;j++) cnt[i][j]=cnt[i-1][j]+(s[i]-'a'==j);
	}
	
	ll ans=0;
	for(int i=1;i<=n;i++){
		ll res=1;
		for(int j=0;j<26;j++){
			if(j==s[i]-'a') continue;
			res=(res*1ll*(cnt[i][j]+1))%P;
		}
		ans=(ans+res)%P;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12032
n = int(input())
a = list(map(int, input().split()))

def solve(a, t):
  ans = 0
  x = 0
  for i in a:
    x += i
    if t==True and x<1:
      ans += 1-x
      x = 1
    elif t==False and x>-1:
      ans += x+1
      x = -1
    t = not t
  return ans

print(min(solve(a,True), solve(a,False)))

Measured memory_bytes: 14212
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int > pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};
bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
signed main(){
int n;
int ans = 0;
bool hoge = true;
string str[105];
cin >> n;
FOR(i,n){
cin >> str[i];
FOR(j,i){
if(str[i] == str[j]) hoge = false;
}
if(i){
int blen = str[i-1].length();
if(str[i-1][blen-1] != str[i][0]) hoge = false;
}
}
if(hoge) cout <<"Yes\n";
else cout << "No\n";
return 0;
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

dx = abs(c - a)
dy = abs(b - d)

if c >= a and d > b:
  e = c - dy
  f = d + dx
  g = e - dx
  h = f - dy
  print(e, f, g, h)
elif c < a and d >= b:
  e = c - dy
  f = d - dx
  g = e + dx
  h = f - dy
  print(e, f, g, h)
elif d < b and c <= a:
  e = c + dy
  f = d - dx
  g = e + dx
  h = f + dy
  print(e, f, g, h)
else:
  e = c + dx
  f = d + dy
  g = e - dx
  h = f + dy
  print(e, f, g, h)


Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    VV<int> g(n);
    for(int i=0; i<m; i++) {
        int a,b; cin >> a >> b;
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }
    V<int> res(n, -1);
    res[0] = 0;
    queue<int> q; q.push(0);
    while(q.size()) {
        int t = q.front(); q.pop();
        for(int a : g[t]) {
            if(res[a] == -1) {
                res[a] = t+1;
                q.push(a);
            }
        }
    }
    for(int i=1; i<n; i++) {
        if(res[i] == -1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i=1; i<n; i++) {
        cout << res[i] << endl;
    }
}


Measured memory_bytes: 10192
import queue

nv, ne = map(int, input().split(' '))
in_degs = [0] * nv
q = queue.Queue()
outs = {}
o = []

for _ in range(ne):
    s, t = map(int, input().split(' '))

    if s in outs: outs[s].append(t)
    else: outs[s] = [t]

    in_degs[t] += 1

for i in range(nv):
    if in_degs[i] == 0: q.put(i)

while not q.empty():
    v = q.get()
    o.append(v)

    if v in outs:
        for out in outs[v]:
            in_degs[out] -= 1
            if in_degs[out] == 0: q.put(out)

[print(v) for v in o]

Measured memory_bytes: 12412
'use strict';

function Main(INPUT) {
    const input = INPUT.split("\n");
    const N = Number(input[0]);
    const T = Number(input[1].split(" ")[0]);
    const A = Number(input[1].split(" ")[1]);
    const H = input[2].split(" ").map(n => Number(n));
    let ans = 1;

    for (let i = 1; i < N; i++) {
        if (Math.abs(A - (T - H[i] * 0.006)) < Math.abs(A - (T - H[ans - 1] * 0.006))) {
            ans = i + 1;
        }
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000
#define N             200005

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

vi v;
void solve(int a,int d){
    if(d>9) return ;
    v.pb(a);
    if(a%10>0) solve(a*10+a%10-1,d+1);
    solve(a*10+a%10,d+1);
    if(a%10<9) solve(a*10+a%10+1,d+1);
}
int solve(){
    cin>>n;
    rep(i,1,9) solve(i,0);
    sort(all(v));
    cout<<v[n-1];
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

int N;
vector<int> A;

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

int main()
{
  cin >> N;
  A.resize(N);
  REP(i,0,N) cin >> A[i];

  vector<int> L(N+1),R(N+1);
  // L[i+1]: gcd(A[0]...A[i])
  L[0] = 0;
  REP(i,0,N) L[i+1] = gcd(L[i], A[i]);
  // R[i]: gcd(A[i]...A[N-1])
  R[N] = 0;
  RREP(i,N,0) R[i] = gcd(A[i], R[i+1]);


  int ans = -1; // gcdの最大値
  REP(i,0,N) {
    // A[i]を除いたN-1個のgcdの計算
    chmax(ans, gcd(L[i],R[i+1]));
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> z = {a, b, c};
    if (z[0] == z[1] && z[1] == z[2]) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
masu = [list(input()) for _ in range(H)]

def kazu(h,w):
    houkou = [[1,0],[1,-1],[0,-1],[-1,-1],[-1,0],[-1,1],[0,1],[1,1]]
    count = 0
    for ya in houkou:
        if 0 <= h+ya[0] < H and 0 <= w+ya[1] < W:
            if masu[h+ya[0]][w+ya[1]] == '#':
                count += 1

    return count

for w in range(W):
    for h in range(H):
        if masu[h][w]=='.':
            masu[h][w] = kazu(h,w)

for l in masu:print(*l,sep='')


Measured memory_bytes: 9204
l,r = map(int,input().split())
mod = 2019

x = r // mod
line = x * mod

if l*r < mod:
    print(l*r)

elif l < line < r:
    print(0)

else:
    ans = 0
    for i in range(l,r):
        for j in range(i+1,r+1):
            x = i * j
            x = x % mod
            if i==l and j==i+1:
                ans = x
            elif x < ans:
                ans = x
    print(ans)
            

Measured memory_bytes: 3064
s = str(input())
n = len(s)
t = 1
x = int((n - 1) / 2)
y = int(int((n - 1) / 2) / 2)
for i in range(x):
    if s[i] != s[-i-1]:
        t = 0
for i in range(y):
    if s[i] != s[int((n - 1) / 2) - i - 1]:
        t = 0
    if s[int((n - 1) / 2) + i + 1] != s[-i-1]:
        t = 0
if t == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
#include<set>
#include<iomanip>
#include<bitset>

using namespace std;

/************************************************/

int main(void) {
	int n, k;
	cin >> n >> k;
	vector<int>x(n);
	for (int i = 0; i < n; i++)cin >> x[i];
	int sum = 0;
	for (int i = 0; i < n; i++){
		if (x[i] <= k - x[i]) {
			sum += 2 * x[i];
		}
		else{
			sum += 2 * abs(x[i] - k);
		}
	}
	cout << sum;
	return 0;
}

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

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

    map<long long, long long> mprev;

    long long ini;
    cin >> ini;
    for (int i=1; i<=sqrt(ini); i++) {
        if (ini%i == 0) {
            mprev[i] = 1;
            mprev[ini/i] = 1;
        }
    }

    long long a;
    cin >> a;

    for (int i=1; i<=sqrt(a); i++) {
        if (a%i == 0) {
            if (mprev.find(i) == mprev.end()) {
                mprev[i] = 1;
            } else {
                mprev[i]++;
            }
            if (i != a/i) {
                if (mprev.find(a/i) == mprev.end()) {
                    mprev[a/i] = 1;
                } else {
                    mprev[a/i]++;
                }
            }
        }
    }

    map<long long, long long> mnow = {};

    for (int i=0; i<n-2; i++) {
        cin >> a;

        mnow = {};

        for (map<long long, long long>::iterator it=mprev.begin(); it!=mprev.end(); ++it) {
            if (a%(it->first) == 0) {
                if (mprev.find(it->first) != mprev.end()) {
                    mnow[it->first] = mprev[it->first] + 1;
                }
            } else {
                if (mprev[it->first] == 2+i) {
                    mnow[it->first] = 2+i;
                }
            }
        }

        mprev = mnow;
    }

    long long anskey = 0;

    for (map<long long, long long>::iterator it=mprev.begin(); it!=mprev.end(); ++it) {
        // cout << it->first << " " << it->second << endl;
        if (it->first > anskey) anskey = it->first;
    }
    
    cout << anskey << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
    set<int>st;
    for(int i=0;i<n;i++){
    	int d;
    	cin>>d;
    	st.insert(d);
    	}
    	if((int)st.size()==n){
    		cout<<"YES"<<endl;
    	}else{
    		cout<<"NO"<<endl;
    	}
	return 0;
}

Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ARC095D {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            Array.Sort(input);
            int high = input[N - 1];
            int low = -1;
            if (high % 2 == 0) {
                for (int i = 0; i < N; i++) {
                    int now = input[i];
                    int tar = high / 2;
                    if (Math.Abs(tar - low) > Math.Abs(tar - now)) {
                        low = now;
                    }
                }
            } else {
                for (int i = 0; i < N; i++) {
                    int now = input[i];
                    int tar = high / 2;
                    if(now <= tar) {
                        if (Math.Abs(tar - low) > Math.Abs(tar - now)) {
                            low = now;
                        }
                    } else {
                        if (Math.Abs(tar + 1 - low) > Math.Abs(tar + 1 - now)) {
                            low = now;
                        }
                    }
                }
            }
            Console.WriteLine(high.ToString() + " " + low.ToString());
        }
    }
}


Measured memory_bytes: 21088
package main

import(
	"fmt"
	"math"
)

func main() {
    var A, B, X float64
    fmt.Scan(&A)
    fmt.Scan(&B)
    fmt.Scan(&X)
    var ans float64
    if X <= A * A * B / 2 {
        ans = math.Atan(A * B * B / (2 * X))
    } else {
        ans = math.Atan(2 * (A * A * B - X) / (A * A * A))
    }
    ans = ans * 180 / math.Pi
    fmt.Println(ans)
}

Measured memory_bytes: 512
lister = []
backet = {}

first_input = input().split(" ")

N = int(first_input[0])
M = int(first_input[1])

# get input
for j in range(M):
    two_input = input().split(" ")
    lister.append(int(two_input[0]))
    lister.append(int(two_input[1]))

# create key
order = range(1,N+1,1)


# create dict
for j in order:
    backet[j]=0

# setting 
for i in lister:
    value = backet[i]
    value += 1
    # update
    backet[i] = value


# printing
for m in order:
    print(backet[m])



Measured memory_bytes: 3064
using System;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            Double radius = Double.Parse(Console.ReadLine());

            Double result = Math.Pow(radius, 2) * Math.PI;

            Double lengthAnswer = (radius + radius) * Math.PI;

            Console.WriteLine(result.ToString("f6") + " " + lengthAnswer.ToString("f6"));
        }
    }
}


Measured memory_bytes: 15916
#include <bits/stdc++.h>
#include<numeric>
#include<cstdlib>
#define ll long long int
#define all(x) x.begin(),x.end()
 
 #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
#define v vector<long long int> 
#define vv vector< int> 
#define gcd(m,n) __gcd(m,n)
#define vp vector<pair<long long int ,long long int>>
#define pb push_back
#define mp make_pair
#define pp pop_back
#define iter vector<int>::iterator
#define pa pair<long long int ,long long int> 
#define f(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,n) for (ll i=a ; i<n ;i+=1)
#define fe(d,e) for(auto d:e)
#define mod 1000000007
#define F first
#define S second
#define sett set<long long int>
#define um unordered_map<ll,ll>
# define N 100005LL
using namespace std;

vector<vector<ll>> graph(200005);
ll visited[200005]; 

void dfs(ll node){
    visited[node]=1;
    cout<<node<<" ";
    for (ll u:graph[node]){
        if(!visited[u])dfs(u);
    }
}
auto factor(int n){
    vector <int> ans;
    for (int i=2;i<=sqrt(n);i+=1){
        if (n%i==0){
            if (i==n/i)ans.pb(i);
            else{
                ans.pb(i);
                ans.pb(n/i);
            }
        }
    }
    ans.pb(n);
    return ans;
}
auto solve(){
    ll n;
    cin>>n;
    v arr(n);
    f(i,n)cin>>arr[i];
    v suff(n);
    suff[n-1] = arr[n-1];
    for(int i=n-2;i>=0;i--)suff[i]=suff[i+1]+arr[i];
    ll ans=0;
    f(i,n-1){
        ans+=((arr[i]%mod)*(suff[i+1]%mod))%mod;
        ans%=mod;
    }
    cout<<ans<<"\n";


}



int main(){
    ll t=1;
    while(t--)
    
        solve();
    }

    

Measured memory_bytes: 11172