akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

class Solution {
private:
    int N, M, X;
    vector<int> costs;
    vector<vector<int>> arr;
public:
    void load() {
        cin >> N >> M >> X;
        costs.assign(N, 0);
        arr.resize(N);
        for (int i = 0; i < N; ++i) {
            arr[i].resize(M);
            cin >> costs[i];
            for (int j = 0; j < M; ++j) {
                cin >> arr[i][j];
            }
        }
    }

    void solve() {
        int all = 1 << N;
        int res = numeric_limits<int>::max();

        for (int mask = 0; mask < all; ++mask) {
            vector<int> level(M);
            int cost = 0;
            for (int i = 0; i < N; ++i) {
                if ((mask >> i) & 1) {
                    cost += costs[i];
                    for (int j = 0; j < M; ++j) {
                        level[j] += arr[i][j];
                    }
                }
            }
            bool ok{true};
            for (int j = 0; j < M; ++j) {
                if (level[j] < X) {
                    ok = false;
                    break;
                }
            }

            if (ok) {
                res = min(res, cost);
            }
        }

        if (res ==  numeric_limits<int>::max()) {
            cout << -1 << endl;
        } else {
            cout << res << endl;
        }        
    }

    // void helper(int cur, vector<int> sofar, int cost, int *output) {
    //     int min_val = numeric_limits<int>::max();
    //     for (int i = 0; i < M; ++i) {
    //         min_val = min(min_val, sofar[i]);
    //     }
    //     if (min_val >= X) {
    //         *output = min(*output, cost);
    //         return;
    //     }
    //     if (cur >= N) {
    //         return;
    //     }
    //     helper(cur + 1, sofar, cost, output); // don't choose cur
    //     for (int i = 0; i < M; ++i) {
    //         sofar[i] += arr[cur][i];
    //     }
    //     helper(cur + 1, sofar, cost + costs[cur], output); // choose cur
    // }

    // void solve() {
    //     vector<int> sofar(M, 0);
    //     int output = numeric_limits<int>::max();
    //     helper(0, sofar, 0, &output);

    //     if (output ==  numeric_limits<int>::max()) {
    //         cout << -1 << endl;
    //     } else {
    //         cout << output << endl;
    //     }
    // }
};

int main() {
    Solution sol;
    sol.load();
    sol.solve();
}



Measured memory_bytes: 3200
using System;
using System.Linq;

namespace CF2016CB{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var K = sr.Next<int>();
            var T = sr.Next<int>();
            var A = sr.Next<int>(T);
            var max = A.Max();
            var oth = A.Sum() - max;

            Console.WriteLine(Math.Max(max - oth - 1, 0));
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

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

#define MOD 1000000007
#define INF 1000000007
typedef /*long long*/ int LLI;

int n;
int W;
int myws[201];
int imos[201];
LLI dp[2][11451][201];

int main() {
  scanf("%d%d", &n, &W);
  for (int i=1; i<=n; i++) {
    scanf("%d", &myws[i]);
  }
  sort(myws+1, myws+n+1);

  int src = 0;
  int dst = 1;
  dp[src][0][0] = 1;
  for (int i=1; i<=n; i++) {
    for (int k=1; k<i; k++) {
      for (int j=0; j<=W; j++) {
        dp[dst][j][k] = dp[src][j][k];
      }
    }

    for (int j=0; j<=W; j++) {
      dp[dst][j][i] = dp[src][j][0];
    }

    int w = myws[i];
    for (int j=0; j<=W-w; j++) {
      for (int k=0; k<i; k++) {
        dp[dst][j+w][k] = (dp[dst][j+w][k]+dp[src][j][k]) % MOD;
      }
    }

    swap(src, dst);
    fill(dp[dst][0], dp[dst][W+1], 0);
  }

  /*for (int i=0; i<=n; i++) {
    printf("%d:", i);
    for (int j=0; j<=W; j++) {
      int sum = 0;
      for (int k=0; k<=n; k++) sum += dp[i][j][k];
      printf(" %d", sum);
    }
    puts("");
  }*/
  
  LLI ans = 0;
  for (int k=0; k<=n; k++) {
    int st = 0;
    if (k != 0) st = max(W-myws[k]+1, 0);
    for (int j=st; j<=W; j++) {
      ans = (ans+dp[src][j][k]) % MOD;
    }
  }
  printf("%d\n", ans%MOD);
}

Measured memory_bytes: 18796
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n, d;
    cin >> n >> d;
    int ans = 0;
    int nx = -1;
    rep(i, n){
        if(nx >= i) continue;
        ans++;
        nx = i + 2 * d;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;

	int a[n], b[n], c[n-1];

	rep(i,n)
	{
		cin>>a[i];
	}
	rep(i,n)
	{
		cin>>b[i];
	}
	rep(i,n-1) cin>>c[i];
	int pre = -1;
	int ans=0;
	rep(i,n)
	{
		ans+=b[a[i]-1];
		if (a[i] == pre+1)
		{
			ans+=c[pre-1];
		}
		pre = a[i];
		// debug1(ans);
	}
	cout<<ans;




}


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

using namespace std;

main(){
    int sumSatis = 0;
    int n;
    cin >> n;

    int* dishes = new int[n];
    for(int i = 0; i < n; ++i) cin >> dishes[i];

    int* satis = new int[n];
    for(int i = 0; i < n; ++i) cin >> satis[i];

    int* addiSatis = new int[n - 1];
    for(int i = 0; i < n - 1; ++i) cin >> addiSatis[i];

    for(int i = 0; i < n; ++i) {
        sumSatis += satis[dishes[i] - 1];
        if(i > 0 && dishes[i] - 1 == dishes[i - 1])
            sumSatis += addiSatis[dishes[i - 1] - 1];
    }

    cout << sumSatis;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    int n, q; cin >> n >> q;
    int a[n-1], b[n-1];
    rep(i, n-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    int p[q], x[q];
    rep(i, q){
        cin >> p[i] >> x[i];
        p[i]--;
    }

    int ans[n] = {};
    bool isDone[n] = {};

    vector<int> g[n];
    rep(i, n-1){
        int v1 = a[i];
        int v2 = b[i];

        g[v1].push_back(v2);
        g[v2].push_back(v1);
    }

    rep(i, q){
        ans[p[i]] += x[i];
    }

    queue<int> que;
    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();
        isDone[v] = true;
        
        rep(i, g[v].size()){
            int u = g[v][i];
            if(isDone[u]) continue;

            ans[u] += ans[v];
            que.push(u);
        }
    }

    rep(i, n){
        cout << ans[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 18932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, m, t, a[100005], ctr = 0, val[200005];
bool vis[200005];
vector< ll > adj[200005];
#define ari for( int i = 0 ; i < n ; i++ ) cin >> a[i];
#define ginp for( int i = 0 ; i < m ; i++ ){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u);}
#define pb push_back
#define ss second
#define ff first
#define fs first.second
#define fff first.first
#define sss second.second
#define sf second.first
#define mp make_pair
void printar(vector< ll > ar, ll l, ll r){
	for(int i = l ; i < r ; i++)
		cout << ar[i] << " ";
	cout << endl;
}

void dfs(ll node){
	vis[node] = true;
	for(int i = 0 ; i < adj[node].size() ; i++)
		if( !vis[adj[node][i]] ){
			val[ctr]++;
			dfs(adj[node][i]);
		}
}
	
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    map< pair<ll, ll>, bool > edge;
    cin >> n >> m;
    for(int i = 0 ; i < m ; i++){
    	ll u, v;
    	cin >> u >> v;
    	if( edge[mp(u, v)] )
    		continue;
    	edge[mp(u, v)] = true;
    	edge[mp(v, u)] = true;
    	adj[v].pb(u);
    	adj[u].pb(v);
    }
    for(int i = 1 ; i <= n ; i++)
    	if( !vis[i] ){
    		dfs(i);
    		val[ctr]++;
    		ctr++;
    	}
    ll ans = 0;
    for(int i = 0 ; i < ctr ; i++)
    	ans = max(val[i], ans);
    cout << ans << endl;
	return(0);
}

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

int main() {
    string s;
    cin >> s;
    int n = s.length();
    if (n % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0 && s[i] != 'h') {
            cout << "No" << endl;
            return 0;
        }
        if (i % 2 == 1 && s[i] != 'i') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S{ll y,m,d;};
struct Ma{ll b,ka,t,w,ki;};

//12,1,2,3...11
int M[]={31,28,31,30,31,30,31,31,30,31,30,31};

bool check(ll y){return (y%4==0&&(y%100!=0||y%400==0));}
bool check2(S a){return check(a.y)&&a.m==2;}

S M2S(ll b,ll ka,ll t,ll w,ll ki){
  ka+=b*20;
  t+=ka*20;
  w+=t*18;
  ki+=w*20;
  S res;
  res.y=2012,res.m=12,res.d=21+ki;
  
  while(res.d/(365+check(res.y+1)))res.y++,res.d-=(365+check(res.y));
  if(res.d==0) res.m--,res.d=M[res.m-1];
  if(res.d<=31) return res;

  res.y++,res.m=1,res.d-=31;
  while(res.d/(M[res.m-1]+check2(res))){
    res.d-=(M[res.m-1]+check2(res));
    res.m++;
  }
  if(res.d==0) res.m--,res.d=M[res.m-1]+check2(res);
  return res;
}

Ma S2M(ll y,ll m,ll d){
  y-=2012;
  if(y) d+=10; 
  else d=(d-21);
  
  for(int i=0;i<m-1&&y;i++) d+=(M[i]+(i==1&&check(y+2012)));
  y--;
  while(y>0)d+=(365+check(y+2012)),y--;

  Ma res;
  d%=13*20*20*18*20;
  res.ki=d;
  res.w =res.ki/20; res.ki%=20;
  res.t =res.w/18;  res.w %=18;
  res.ka=res.t/20;  res.t %=20;
  res.b =res.ka/20; res.ka%=20;
  return res;
}

int main(){
  while(1){
    string str;
    cin>>str;
    if(str=="#")break;
    vector <int> a;
    int i=0,num=0;
    while(str[i]){
      if(str[i]=='.')a.push_back(num),num=0;
      else num=num*10+str[i]-'0';
      i++;
    }
    a.push_back(num);
    
    if(a.size()==5){
      S ans=M2S(a[0],a[1],a[2],a[3],a[4]);
      cout << ans.y<<"."<<ans.m<<"."<<ans.d<<endl;
    }
    else {
      Ma ans=S2M(a[0],a[1],a[2]);
      cout<<ans.b<<"."<<ans.ka<<"."<<ans.t<<"."<<ans.w<<"."<<ans.ki<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1212
N, M = [int(_) for _ in input().split()]
ab = [input().split() for _ in range(M)]

goal = {i:0 for i in range(1, N+1)}
N = str(N)

ne = []
for i in ab:
    if i[0] == "1":
        goal[int(i[1])] = 1

for j in ab:
    if goal[int(j[0])] and j[1] == N:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Measured memory_bytes: 85408
#include "bits/stdc++.h"
// #define rep(i, n) for(int i = 0; i < (int)(n); i++)
// #define all(a) (a).begin(),(a).end()
// #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
// int gcd(int a, int b){return b ? gcd(b, a%b) : a;}

#define int long long
#define SIZE 100000

using namespace std;

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

  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  int n; cin >> n;
  int m; cin >> m;

  vector<int> point(m);
  for (auto it = point.begin(); it < point.end(); ++it) cin >> *it;

  if (n >= m) {
    num = 0;
  } else {

    sort(point.begin(), point.end());

    vector<int> diff(m - 1);
    for (int i = 0; i < m - 1; ++i) diff[i] = abs(point[i+1] - point[i]);

    sort(diff.begin(), diff.end());

    for (int i = 0; i < m - 1 - (n - 1); ++i) num += diff[i];
  }
  
  // array<int, 1000000> a;
  // for (auto it = a.begin(); it < a.begin() + n; ++it) cin >> *it;
  // for (auto it = a.begin(); it < a.begin() + n; ++it) num += *it;

  cout << num << endl;
  return 0;
}


Measured memory_bytes: 1792
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn           printf("\n")
#define nl           cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define mod     1000000007
#define Inf     1000000000000000
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    lli N,i;
    cin>>N;
    
    if(N==1)
    {
        cout<<1;
        exit(0);
    }
    
    lli Max=0,Index=0;
    rep(i,1,N+1)
    {
        lli j=i,cnt=0;
        while(j%2==0)
        {
            j/=2;
            cnt++;
        }
        
        if(cnt>=Max)
        {
            Max=cnt;
            Index=i;
        }
    }
    
    cout<<Index;
    








 return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
string s;
int n, c, k;
int main() {
	cin>>s;
	n = s.size();
	for(int i=0; i<n; i++) {
		if(s[i]>='a') c++;
		if(s[i]=='C') k = i+1;
	}
	if(c==n-2 && s[0]=='A' && k>=3 && k<n) cout<<"AC";
	else cout<<"WA";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s;
  cin >> s;
  if(s[0]==s[s.size()-1]^s.size()%2) {
    cout << "First" << endl;
  }
  else cout << "Second" << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cctype>

int main(){
	char ch;
	while (1){
		scanf("%c", &ch);
		if (ch == '\n') break;
		if (islower(ch)) printf("%c", toupper(ch));
		else if (isupper(ch)) printf("%c", tolower(ch));
		else printf("%c", ch);
	}

	printf("\n");
	return 0;
}


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

static const int N = 100;

int main() {
  int n, p[N + 1], m[N + 1][N + 1];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i - 1] >> p[i];
  }

  for (int i = 1; i <= n; i++) m[i][i] = 0;
  for (int l = 2; l <= n; l++) {
    for (int i = 1; i <= n - l + 1; i++) {
      int j = i + l - 1;
      m[i][j] = (1<<21);
      for (int k = i; k <= j - 1; k++) {
        m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
      }
    }
  }

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



Measured memory_bytes: 3120
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


nums = list(map(int, S()))
ans = ''
for i in range(2 ** 3):
    res = nums[0]
    ans = str(nums[0])
    for j in range(3):
        if i >> j & 1:
            res += nums[j + 1]
            ans += f'+{nums[j + 1]}'
        else:
            res -= nums[j + 1]
            ans += f'-{nums[j + 1]}'
    if res == 7:
        ans += '=7'
        break
print(ans)


Measured memory_bytes: 9164
<?php

class Operator
{
    private $operations;
    private $operations_count;

    public function doOperations()
    {
        fscanf(STDIN, '%d', $this->operations_count);
        $this->operations = new \SplDoublyLinkedList();
        for (;$this->operations_count > 0;$this->operations_count -= 1) {
            $operation = trim(fgets(STDIN));
            if ($operation[0] === 'i') {
                $this->operations->unshift(substr($operation, 7));
            } elseif ($operation[6] === 'F') {
                $this->operations->shift();
            } elseif ($operation[6] === 'L') {
                $this->operations->pop();
            } else {
                foreach ($this->operations as $key => $element) {
                    if ($element === substr($operation, 7)) {
                        $this->operations->offsetUnset($key);
                        break;
                    }
                }
            }
        }
    }

    public function getAnswer()
    {
        $keys_operated = array();

        while (1) {
            if (count($this->operations) > 0) {
                $keys_operated[] = $this->operations->shift();
            } else {
                break;
            }
        }
        echo implode(' ', $keys_operated), PHP_EOL;
    }
}

$operator = new Operator();
$operator->doOperations();
$operator->getAnswer();



Measured memory_bytes: 136152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        string[] cin = Console.ReadLine().Split();
        int n = int.Parse(cin[0]);
        int k = int.Parse(cin[1]);
        int[] a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

        var dic = new Dictionary<int, int>();
        for (int i = 0; i < n; i++)
        {
            if (dic.ContainsKey(a[i])) dic[a[i]]++;
            else dic.Add(a[i], 1);
        }

        List<int> b = dic.Values.ToList();
        b.Sort();

        int ans = 0;
        for (int i = 0; i < b.Count - k; i++)
        {
            ans += b[i];
        }
        Console.WriteLine(ans);
    }
}

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

using namespace std;

int main()
{
  string s,s1,s2;
  int l,c=0;
  cin >> s;
  l=s.length();
  if (l%2==0)
  {
    for (int i=0; i<l/2;i++)
    {
      s1=s[i];
      s2=s[l-i-1];
      if(s1 != s2)
      {
        c++;
      }
    }
  }
  else
  {
    for (int i=0; i<(l-1)/2;i++)
    {
      s1=s[i];
      s2=s[l-i-1];
      if(s1 != s2)
      {
        c++;
      }
   	}
  } 
  cout << c;
}  
  

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


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

ll PowMod(ll N,ll P,ll M){
    ll ans = 1;
    while(P >= 1){
        if(P % 2)ans = ans * N % M;
        N = N*N %M;
        P /= 2;
    }
    ans %= M;
    return ans;
}

int main(){
    ll N,K;
    cin>>N>>K;
    ll sum = 0, ans = 0;
    v a(K+1,0);
    for(ll i = K; i>=1; i--){
        ll m = PowMod((K/i),N,MOD);
        sum = 0;
        rep(j,2,K/i+1){
            sum += a[i*j];
        }
        a[i] = m-sum;
        ans += (m-sum) * i;
        ans %=MOD;
    }
    if(ans < 0){
        ans += (((abs(ans)-1)/MOD)+1)*MOD;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>

using namespace std;

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

	vector<double> p(n+1);

	for (int i = 1; i <= n;i++) {
		
		int num = i;
		double p_i = 1.0/n;
		while (num  < k) {
			num *= 2;
			p_i *= 0.5;
		}
		
		p[i] = p_i;

	}

	double sum = 0;
	for (int i = 1; i <= n; i++) {
		sum += p[i];
		
	}
	printf("%.12lf", sum);
}

Measured memory_bytes: 1024
inr = lambda: list(map(int, input().split()))

N, Y = inr()

lmn = [-1, -1, -1]

for x in range(N+1):
    for y in range(N-x+1):
        z = N - x - y
        oto_sum = 10000 * x + 5000 * y + 1000 * z
        if z >= 0 and oto_sum == Y:
            print(x, y, z)
            exit()

print(-1, -1, -1)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
unsigned long long a,b,c,x;
int main()
{
	ios::sync_with_stdio(false);
	cin>>a>>b>>c;
	if(a+b>=c)cout<<"No"; 
	else
	{
		x=(c-a-b)*(c-a-b);
		if(4*a*b<x) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int m = scan.nextInt();
		int min = 0;
		int max = 100001;

		for(int i = 0; i < m; i++) {
			min = Math.max(min, scan.nextInt());
			max = Math.min(max, scan.nextInt());
		}

		System.out.println(Math.max(max - min + 1, 0));
	}
}

Measured memory_bytes: 63100
/// Radoslaw Mysliwiec 2019
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB emplace_back
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int,int>;
using pll = pair<ll,ll>;
using matrix = vector<vll>;

constexpr int INI = -1;
constexpr int INF = 1e9 + 1;
constexpr int IN = 50000 + 10;
constexpr int MOD = 1e9 + 7;
constexpr ld EPS = 1e-9;

string s, t;
ll len, len2, tmp, it, indeks = -1, ile_razy;
vi tab[27];

bool next_char(){
    int ZNAK = t[it] - 'a';
    int IT = upper_bound(ALL(tab[ZNAK]),-1) - tab[ZNAK].begin();
    if (IT == tab[ZNAK].size()) return 1;

    int IT2 = upper_bound(ALL(tab[ZNAK]),indeks) - tab[ZNAK].begin();
    if (IT2 == tab[ZNAK].size()){
        ++ile_razy;
        indeks = tab[ZNAK][IT];
        ++it;
    }
    else{
        indeks = tab[ZNAK][IT2];
        ++it;
    }
    return 0;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);

    cin >> s >> t;
    len = s.length();
    len2 = t.length();

    for (int i=0; i<len; ++i)
        tab[s[i]-'a'].PB(i);

    while(it != len2){
        if (next_char()) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << len*ile_razy + indeks + 1 << endl;
}


Measured memory_bytes: 1228
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

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

  int ans = 0;
  int hmax = 0;

  while (N--) {
    int h;
    cin >> h;
    if (hmax <= h) {
      ans++;
      hmax = h;
    }
  }

  cout << ans << endl;
}

signed main() {
  solve();
  return 0;
}


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

int main()
{
	string str;
	cin >> str;
	int n;
	cin >> n;
	string buf;
	for( int i = 0; i < n; i++ ) {
		cin >> buf;
		if( buf == "replace" ) {
			int a, b;
			string ptn;
			cin >> a >> b >> ptn;
			str.replace( a, b - a + 1, ptn );
		}
		if( buf == "reverse" ) {
			int a, b;
			cin >> a >> b;
			auto itr = str.begin();
			reverse( itr + a, itr + b + 1 );
		}
		if( buf == "print" ) {
			int a, b;
			cin >> a >> b;
			cout << str.substr( a, b - a + 1 ) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
ll a[100005];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    ll f=1e9,tot=0,sum=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]<0) tot^=1;
        f=min(f,abs(a[i]));
        sum+=abs(a[i]);
    }
    if(tot) sum-=2*f;
    printf("%lld\n",sum);
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)

template<class T, class E>
struct SegTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  typedef function<E(E,E)> H;
  typedef function<E(E,int)> P;
  int n;
  F f;
  G g;
  H h;
  P p;
  T d1;
  E d0;
  vector<T> dat;
  vector<E> lazy;
  SegTree(int n_, F f, G g, H h, T d1, E d0, P p=[](E a, int b){ return a; })
    : f(f), g(g), h(h), d1(d1), d0(d0), p(p) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, d1);
    lazy.resize(2 * n - 1, d0);
  }
  void eval(int k, int l, int r) {
    if (lazy[k] == d0) return;
    dat[k] = g(dat[k], p(lazy[k], r - l));
    if (k < n - 1) {
      lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
      lazy[2 * k + 2] = h(lazy[2 * k + 2], lazy[k]);
    }
    lazy[k] = d0;
  }
  void update(int a, int b, E x, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] = h(lazy[k], x);
      eval(k, l, r);
    }
    else {
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
    }
  }
  // return op[a..b)
  // k: node id, [l, r): node interval
  E query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    eval(k, l, r);
    if (r <= a || b <= l) return d1;
    if (a <= l && r <= b) return dat[k];
    E vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    E vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return f(vl, vr);
  }
};

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

  int n, q;
  cin >> n >> q;
  SegTree<int, int> seg(
    n,
    [](int a, int b){ return std::min(a, b); },
    [](int a, int b){ return b; },
    [](int a, int b){ return b; },
    INT_MAX,
    -1);
  rep(i, q) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 0) {
      seg.update(x, x + 1, y);
    }
    else {
      cout << seg.query(x, y + 1) << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 4832
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

import itertools

s = []

for j in range(N):
    s.append(j + 1)

n_P = 0
n_Q = 0

list_seed = list(itertools.permutations(s, N))
list_seed = [list(list_seed[i]) for i in range(len(list_seed))]

for i in range(len(list_seed)):
    if list_seed[i] == P:
        n_P = i + 1
    if list_seed[i] == Q:
        n_Q = i + 1

print(abs(n_P - n_Q))


Measured memory_bytes: 15092
#include <stdio.h>

#define ARR_LIMIT 1000

int Judgment(char* s, char* p);

int main(void) {
	int res;
	char* pRes;
	char s[1000];
	char p[1000];

	scanf("%[^\n]s", s);
	scanf(" %[^\n]s", p);

	res = Judgment(s, p);
	pRes = res == 1 ? "Yes" : "No";

	printf("%s\n", pRes);
}

int Judgment(char* s, char* p) {
	char c;
	int res;
	char* save = s;

	while ((c = *(s++))) {

		char *pPivot = p;
		char *sPivot = s;

		while (1) {
			if (!*sPivot) {
				sPivot = save;
			}

			if (!*pPivot) {
				res = 1;
				break;
			}

			if (*pPivot != *sPivot) {
				res = 0;
				break;
			}

			pPivot++;
			sPivot++;
		}

		if (res == 1) {
			break;
		}
	}

	return res;
}


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

using namespace std ;

  template <typename T>
T Out(vector < T > v,int n)
{
  if(n == 1)
  {
    for(int i = 0; i < v.size(); i++)
    {
      cout << v[i] << endl ;
    }
  }
  else if(n == 2)
  {
    for(int i = 0; i < v.size(); i++)
    {
      cout << v[i] ;
    }
    cout << endl ;
  }
  else
  {
    for(int i = 0; i < v.size(); i++)
    {
      cout << v[i] << " " ;
    }
    cout << endl ;
  }
}

int main()
{
  int N ;
  vector<int> a, b, ans ;
  while(1)
  {
    cin >> N ;
    if(N == 0)
    {
      break ;
    }
    for(int h = 0; h < N ;++h)
    {
      a.resize(4) ;
      b.resize(4) ;
      ans.clear() ;
      ans.resize(4) ;
      for(int i = 0; i < 4; ++i)
      {
        cin >> a[i] ;
      }
      for(int i = 0; i < 4; ++i)
      {
        cin >> b[i] ;
      }
      for(int i = 0; i < 4;++i)
      {
        for(int j = 0; j < 4; ++j)
        {
          if(i == j && i != 0)
          {
            ans[0] -= a[i] * b[j] ;
          }
          else if(i == j && i == 0)
          {
            ans[0] += a[i] * b[j] ;
          }
          else if(i == 0)
          {
            ans[j] += a[i] * b[j] ;
          }
          else if(j == 0)
          {
            ans[i] += a[i] * b[j] ;
          }//
          else if(i == 1 && j == 2)
          {
            ans[3] += a[i] * b[j] ;
          }
          else if(i == 1 && j == 3)
          {
            ans[2] -= a[i] * b[j] ;
          }
          else if(i == 2 && j == 1)
          {
            ans[3] -= a[i] * b[j] ;
          }
          else if(i == 2 && j == 3)
          {
            ans[1] += a[i] * b[j] ;
          }
          else if(i == 3 && j == 1)
          {
            ans[2] += a[i] * b[j] ;
          }
          else if(i == 3 && j == 2)
          {
            ans[1] -= a[i] * b[j] ;
          }
        }
      }
      for(int i = 0; i < 4;++i){
        if(i){
          cout << " ";
        }
        cout << ans[i];
      }
      cout << endl;
    }
  }
  return 0 ;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; ll k; cin >> n >> k;
    vector<ll> a(n); 
    for (int i = 0; i < n; i++) cin >> a[i];

    vector<vector<int>> cnt(40, vector<int>(2));
    for (int i = 0; i < 40; i++) {
        for (int j = 0; j < n; j++) {
            cnt[i][(a[j] >> i) & 1]++;
        }
    }

    vector<vector<ll>> dp(41, vector<ll>(2, -1));
    dp[40][0] = 0;
    for (int i = 39; i >= 0; i--) {
        if ((k >> i) & 1) {
            dp[i][0] = (dp[i + 1][0] << 1) + cnt[i][0];
            dp[i][1] = (dp[i + 1][0] << 1) + cnt[i][1];
        } else {
            dp[i][0] = (dp[i + 1][0] << 1) + cnt[i][1];
        }
        if (dp[i + 1][1] >= 0) {
            dp[i][1] = max(dp[i][1], (dp[i + 1][1] << 1) + max(cnt[i][0], cnt[i][1]));
        }
    }

    cout << max(dp[0][0], dp[0][1]) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    ll n,m;
    cin>>n>>m;
    ll ans=min(n,m/2);
    m-=ans*2;
    ans+=m/4;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1<<30)
#define LINF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,m;
  cin >> n >> m;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  sort(a.rbegin(),a.rend());
  
  double lim = (double)accumulate(a.begin(),a.end(),0LL)/(4*m);
  if(a[m-1] < lim) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n=s.size();
  vector<int> ans(n,0);
  s+='R';
  int now=0;
  while(now<n-1){
      int r=0,l=0;
      while(!(s[now]=='L'&&s[now+1]=='R')){
          if(s[now]=='R') r++;
          else l++;
          now++;
      }
      l++;
      int rl=now-l;
      if((r+l)%2==0){
          ans[rl]=((r+l)/2);
          ans[rl+1]=((r+l)/2);
          now++;
      }
      else if(r%2==1){
          ans[rl]=(((r+l)/2)+1);
          ans[rl+1]=((r+l)/2);
          now++;
      }
      else{
          ans[rl]=(((r+l)/2));
          ans[rl+1]=(((r+l)/2)+1);
          now++;
      }
  }
  rep(i,n) cout << ans[i] << endl;
}

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

namespace abc154_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var A = new HashSet<int>();

      for (int i = 0; i < N; i++)
      {
        A.Add(CIn.ReadInt());
      }

      Console.WriteLine(A.Count == N ? "YES" : "NO");
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


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

using namespace std;

#define ll long long
#define ar array



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

	int n;
	cin >> n;
	vector<int> arr(n);
	int ans = 0;
	for(int i = 0;i < n;i++) {
		cin >> arr[i];
		if(arr[i]&1 && (i+1)&1) ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3636
N = int(input())
v = list(map(int, input().split()))

v = sorted(v, reverse=True)

while True:
    l = len(v)
    a = v.pop()
    b = v.pop()
    mid = (a+b)/2
    v.append(mid)
    v = sorted(v, reverse=True)
    if l==2:
        break

print(sum(v))

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

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

    int x;

    cin>>x;

    if(x<0 || x>1000000000)
    {
        return 0;
    }
    else if (x == 0)
    {
        cout<<"0"<<endl;
        return 0;
    }
    

    int ans;
    int ans1, ans2;
    int a500,a5;
    int cnt=0, cnt2=0;

    ans = x / 500;

    //cout<<ans<<endl;

    ans1 = x - (500*ans);
    a500 = 1000 * ans;

    //cout<<"ans1:"<<ans1<<endl;
    //cout<<"a500:"<<a500<<endl;

    
    ans2 = ans1 / 5;
    a5 = ans2 * 5;

    cout<<a500+a5<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll a;
    cin>>a;
    cout<<a+(a*a)+(a*a*a);

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

ll a[1001][3];
ll ans = 0;
int n, m;

int main() {
	// 최대유량, 앳코더, (종만북(?) 생각)
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	rep(i, 8) { // +++, ++-, +-+, +--, -++, -+-, --+, ---
		vector<ll> v;
		rep(j, n) {
			ll tmp = 0;
			rep(k, 3) {
				if (i & (1 << k)) {
					tmp += a[j][k];
				}
				else {
					tmp -= a[j][k];
				}
			}
			v.push_back(tmp);
		}
		sort(v.begin(), v.end());

		ll cnt = 0;
		for (int j = v.size() - 1; j >= (v.size() - m); --j) {
			cnt += v[j];
			if (j == 0)break;
		}
		ans = max(ans, cnt);
	}

	cout << ans << '\n';



}


Measured memory_bytes: 256
N = int(input())
trains = [list(map(int, input().split())) for _ in range(N-1)]
for i in range(N-1):
    t = 0
    t += trains[i][1] + trains[i][0]
    for j in range(i+1, N-1):
        c, s, f = trains[j]
        if t <= s:
            t = s + c
        elif t % f == 0:
            t += c
        else:
            t += (f-(t%f)) + c
    print(t)
print(0)

Measured memory_bytes: 3188
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
heapq.heapify(a)
bc = sorted(
    [list(map(int, input().split())) for _ in range(m)],
    reverse=True,
    key=lambda x: x[1],
)

for i in bc:
    b, c = i
    for _ in range(b):
        mn = heapq.heappop(a)
        if mn < c:
            heapq.heappush(a, c)
        else:
            heapq.heappush(a, mn)
            break

print(sum(a))

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


int f(int a, int b, int K) {
    return (a + K - 1) / K + (b + K - 1) / K;
}

void solve(ll N, ll K, vector<ll> A) {
    int idx = find(A.begin(), A.end(), 1) - A.begin();
    int ans = 1e9;

    int a = idx;
    int b = N - idx - 1;

    for (int i = 0; i <= K - 1; i++) {
        ans = min<int>(ans, f(a - i, b - (K - 1 - i), K - 1) + 1);
    }
    cout << ans << endl;

}


void main_(istream &cin) {
    ll K;
    ll N;
    cin >> N;
    vector<ll> A(N - 1 + 1);
    cin >> K;
    for (int i = 0; i <= N - 1; i++) {
        cin >> A[i];
    }
    solve(N, K, A);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    ll n,q;
    cin >> n;
    ll a[n];
    
    rep(i,0,n){
        cin >> a[i];
    }
    
    cin >> q;
    ll c,b,e,memo = 0;
    bool flag = true;
    
    rep(i,0,q){
        cin >> c >> b >> e;
        rep(i,b,e){
            if(c == 0){
                if(flag){
                    memo = a[i];
                    flag = false;
                }
                else{
                    memo = min(memo,a[i]);
                }
            }
            else{
                if(flag){
                    memo = a[i];
                    flag = false;
                }
                else{
                    memo = max(memo,a[i]);
                }
            }
        }
        cout << memo << endl;
        flag = true;
    }
    
    
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <cmath>

#define N 200000

using namespace std;

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

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

  int max_profit = -1000000000;
  int min_r = R[0];
  for(int i = 1; i < n; i++) {
    max_profit = max(max_profit, R[i] - min_r);
    min_r = min(min_r, R[i]);
  }

  cout << max_profit << endl;

  return 0;
}


Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main()
{
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3584