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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll X[101],Y[101];

const ll EPS=0;

template<class C> C veccross(pair<C,C> p1,pair<C,C> p2,pair<C,C> p3) {
    p3.first-=p1.first;p2.first-=p1.first;
    p3.second-=p1.second;p2.second-=p1.second;
    return p3.first*p2.second-p2.first*p3.second;
}

template<class C> vector<int> convex_hull(vector< pair<C, C> >& vp) {
    vector<pair<pair<C, C>, int> > sorted;
    vector<int> res;
    int i,k=0,rb;

    if(vp.size()<=2) {
        if(vp.size()>=1) res.push_back(0);
        if(vp.size()>=2 && vp[0]!=vp[1]) res.push_back(1);
        return res;
    }

    FOR(i,vp.size()) sorted.push_back(make_pair(vp[i],i));
    sort(sorted.begin(),sorted.end());

    res.resize(vp.size()*2);
    /* bottom */
    FOR(i,vp.size()) {
        while(k>1 && veccross(vp[res[k-2]],vp[res[k-1]],sorted[i].first)<=-EPS) k--;
        res[k++]=sorted[i].second;
    }
    /* top */
    for(rb=k, i=vp.size()-2;i>=0;i--) {
        while(k>rb && veccross(vp[res[k-2]],vp[res[k-1]],sorted[i].first)<=-EPS) k--;
        res[k++]=sorted[i].second;
    }
    res.resize(k-1);
    return res;
}




void solve() {
    int i,j,k,l,r,x,y; string s;

    cin>>N;
    vector<pair<ll,ll>> V;
    V.push_back({0,0});
    FOR(i,N) {
        cin>>x>>y;
        j=V.size();
        FOR(k,j) V.push_back({V[k].first+x,V[k].second+y});

        vector<int> W=convex_hull(V);

        vector<pair<ll,ll>> V2;
        FORR(w,W) V2.push_back(V[w]);
        swap(V,V2);
    }

    double ma=0;
    FORR(v,V) ma=max(ma,hypot(v.first,v.second));
    _P("%.12lf\n",ma);



}


int main(int argc,char** argv){
    string s;int i;
    if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
    FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
    cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void){
    int a,b,ans,count=1;
    while(scanf("%d %d",&a,&b)!=EOF){
        ans=a+b;
        while(ans>=10){
            ans=ans/10;
            count++;
        }
        printf("%d\n",count);
        count=1;
    }
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
  int a,p;
  std::cin >> a>>p;
  std::cout << (a*3+p)/2 << std::endl;
}

Measured memory_bytes: 256
import sys
import math

#+++++


		
def main():
	n,m = map(int, input().split())
	if m % n ==0:
		return m // n
		
	ll=1
	for i in range(1, int(math.sqrt(m))+1):
		#pa((i,ll))
		if m % i == 0:
			if i >= n:
				ll=max(ll, m // i)
			if m // i >= n:
				ll=max(ll, i)
	return ll
				

#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int d,g;
    int ans = 1e9;
    cin >> d>>g;
    vector<int> p(d);
    vector<int> c(d);
    rep(i,d){
        cin >> p[i] >> c[i];
    }
    rep(i,1<<d){
        int s = 0;
        int cnt = 0;
        rep(j,d){
            if(i&(1<<j)){
                s+=c[j];
                s+=(j+1)*100*p[j];
                cnt += p[j];
            }
        }
        for(int j = d-1;j>=0;j--)
        {
            if(s>=g){
                continue;
            }
            if(i&1<<j){
                continue;
            }
            if(g-s>p[j]*(j+1)*100){
                cnt+=p[j];
                s += p[j] * (j + 1) * 100;
            }
            else{
                cnt += (g - s) / ((j + 1) * 100);
                if((g-s)%((j + 1) * 100)){
                    cnt++;
                }
                s = g+1;
            }
        }
        ans = min(ans,cnt);
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
h = [0] * N
for i in range(N):
    h[i] = int(input())
h.sort()
d_min = h[-1] - h[0]
# print(h)
# print(d_min)
for i in range(0, N - K+1):
    h_min = h[i]
    h_max = h[i + K - 1]
    d = h_max - h_min
    # print(i, h_min, h_max, d)
    if d < d_min:
        d_min = d
    # print('min=', d_min)
print(d_min)


Measured memory_bytes: 7472
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    cout << n / 3 << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    long long n,k;
    cin >> n >> k;
    long long nn=0;

    nn = n%k;
    long long pp=0;
    pp = abs(nn-k);
    if(nn > pp){
        cout<< pp<< endl;
    }else{
          cout << nn <<endl;
    }
  
    return 0;
}


Measured memory_bytes: 256
n , k = map(int, input().split())
hp = list(map(int, input().split()))

sum_hp = 0


hp.sort()


for i in range(k):
    if(len(hp)> 0):
        hp.pop()



for j in hp:
    sum_hp = sum_hp + int(j)

print(str(sum_hp))

Measured memory_bytes: 26024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)

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

	vector<vector<int>> map(2, vector<int>(N));
	rep(i, 2){
		rep(n, N) cin >> map.at(i).at(n);
	}
	int Max = 0;
	rep(i, N){
		int cnt = 0;
		rep(j, i + 1) cnt += map.at(0).at(j);
		for(int k = i; k < N; k++) cnt += map.at(1).at(k);
		Max = max(Max, cnt);
	}
	cout << Max << endl;
}


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

int main() {

	string s;
    cin >> s;
  string a,b;
   a="AAA";
   b="BBB" ;
	if(s==a || s== b) {
      cout << "No" << endl;
    }
    else cout << "Yes" << endl;
 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
        cin>>a[i];
	int dp[n];
	for(int i=0;i<n;i++)
        dp[i]=INT_MAX;
    dp[n-1]=0;
    for(int i=n-2;i>=0;i--)
    {
        for(int j=1;j<=k;j++)
        {
            if(i+j<n)
            {
                dp[i]=min( dp[i], abs(a[i]-a[i+j])+dp[i+j]);
            }
        }
    }
    cout<<dp[0];
    return 0;
}

/*
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
*/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	int n, cnt = 0, tmp = 0, ans;
	bool f[8] = {};
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] < 3200) {
			f[a[i] / 400] = true;
		} else {
			tmp++;
		}
	}
	for (int i = 0; i < 8; i++) {
		if (f[i]) {
			cnt++;
		}
	}
	ans = cnt + tmp;
	if (cnt == 0) {
		cnt++;
	}
	cout << cnt << " " << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ctype.h>
#define int long long int
#define rep(a,b) for(int a=0;a<b;a++)

using namespace std;

int tx[] = {1,0,-1,0};
int ty[] = {0,1,0,-1};
int w,h,chee,sx,sy;
char bases;
int base[1003][1003];

int ice(int x,int y){
    int ans=0;
    if(base[x][y]){
        base[x][y]=0;
        for(int i=0;i<4;i++){
            if(x+tx[i]>=0&&x+tx[i]<w&&y+ty[i]>=0&&y+ty[i]<h){
                ans = max(ans,ice(x+tx[i],y+ty[i])+1);
            }
        }
        base[x][y]=1;

    } return ans;
}

signed main(){
    while(1){
        cin >> w >> h;
        if(!w||!h)break;
        rep(f,h){
            rep(s,w){
                cin >> base[s][f];
            }
        }
        int ans=0;
        rep(f,h){
            rep(s,w){
                if(base[s][f]){
                    ans = max(ans,ice(s,f));
                }
            }
        }
        cout << ans << endl;
    }
return 0;
}

Measured memory_bytes: 1520
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int a,b;
    cin >> a >> b;
    put((a+b)%24);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second
//考虑一个最终状态，假设之后走的链上第i个球有d_i个，显然答案是n - \sum min(c_i, d_i)
//保留尽量多的球不改的话，f_i表示现在链的末端在i的时候\sum min(c_i, d_i)的最大值
//f_i = max(f_j + min(i - j, c_i))
//这个dp式子其实就是[i - c_i + 1,i]的区间覆盖，等于被覆盖的长度
//维护哪些位置被覆盖了即可
const int N = 2e5 + 10;
int n, m, a[N], c[N], s[N];
int main() {
	scanf("%d%d",&n,&m);
	rep(i,1,n) {
		scanf("%d",a + i), c[a[i]]++;
	}
	rep(i,1,n) s[max(1,i - c[i] + 1)]++, s[i + 1]--;
	int ans = 0;
	rep(i,1,n) s[i] += s[i - 1], ans += (s[i] == 0);
	rep(i,1,m) {
		int x, y; scanf("%d%d",&x,&y);
		if (a[x] != y) {
			if (a[x] - c[a[x]] + 1 >= 1) {
				s[a[x] - c[a[x]] + 1]--;
				if (!s[a[x] - c[a[x]] + 1]) ans++;
			}
			c[a[x]]--, c[y]++;
			if (y - c[y] + 1 >= 1) {
				if (!s[y - c[y] + 1]) ans--;
				s[y - c[y] + 1]++;
			}
			a[x] = y;
		}
		printf("%d\n",ans);
	}
	return 0;
}


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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            var aaa = str[1];
            var bbb = aaa[0].ToString();

            Console.WriteLine("A" + bbb + "C");
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<string.h>
int main()
{
    char s[6];
    int l,i;
    gets(s);
    if(s[2]==s[3] && s[4]==s[5])
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

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

int main() {
    int a, b;
    while (true) {
        cin >> a >> b;
        if (a == 0 && b == 0)break;
        else if (a > b) { cout << b << " " << a << endl; }
        else { cout << a << " " << b << endl; }
    }
    return 0;
}

Measured memory_bytes: 1160
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(0, A+1):
    for b in range(0, B+1):
        for c in range(0, C+1):
            if a*500 + b*100 + c*50 == X:
                ans += 1
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <stack>
#include <vector>
#include <utility>
#include <list>
#include <algorithm>
using namespace std;

#define N 1046257

class Hash
{
  private:
    string *a;

    unsigned long long getChar(char ch)
    {
        switch (ch)
        {
        case 'A':
            return 1;
        case 'C':
            return 2;
        case 'G':
            return 3;
        case 'T':
            return 4;
        default:
            return 0;
        }
    }

    unsigned long long getKey(string str)
    {
        unsigned long long x = 0;
        for (unsigned int i = 0; i < str.length(); i++)
        {
            x += getChar(str[i]);
            x *= 5;
        }
        return x;
    }

    int h1(int key)
    {
        return key % N;
    }

    int h2(int key)
    {
        return 1 + (key % (N - 1));
    }

  public:
    Hash()
    {
        a = new string[N];
        for (int i = 0; i < N; i++)
            a[i] = "";
    }

    void insert(string str)
    {
        unsigned long long key = getKey(str);
        unsigned long long h, i;
        for (i = 0;; i++)
        {
            h = (h1(key) + i * h2(key)) % N;
            if (a[h] == str)
            {
                return;
            }
            else if (a[h] == "")
            {
                a[h] = str;
                return;
            }
        }
    }

    bool find(string str)
    {
        unsigned long long key = getKey(str);
        unsigned long long h, i;
        for (i = 0;; i++)
        {
            h = (h1(key) + i * h2(key)) % N;
            if (a[h] == str)
                return true;
            else if (a[h] == "")
                return false;
        }
    }
};

int main()
{
    Hash H;
    int n;
    cin >> n;
    string str;
    for (int i = 0; i < n; i++)
    {
        //cout << i << "\n";
        cin >> str;
        if (str[0] == 'i')
        {
            cin >> str;
            H.insert(str);
        }
        else if (str[0] == 'f')
        {
            cin >> str;
            if (H.find(str))
                cout << "yes\n";
            else
                cout << "no\n";
        }
    }
}


Measured memory_bytes: 27852
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
  int N, M, Q; scanf("%d%d%d", &N, &M, &Q);
  static pair<int,int> queries[100000];
  for(int i = 0; i < Q; ++i) {
    scanf("%d", &queries[i].first); --queries[i].first;
    queries[i].second = i;
  }
  sort(queries, queries+Q);
  // printf("queries = ");
  // for(int i = 0; i < Q; ++i) {
  //   printf("(%d, %d), ", queries[i].first, queries[i].second);
  // }
  // printf("\n");
  static int qidx[100001];
  {
    int i = 0;
    for(int j = 0; j <= M; ++j) {
      while(i < Q && queries[i].first < j) ++i;
      qidx[j] = i;
    }
  }
  // printf("qidx = ");
  // for(int i = 0; i <= M; ++i) {
  //   printf("%d, ", qidx[i]);
  // }
  // printf("\n");
  static int lru_seq[100000];
  for(int i = 0; i < M; ++i) {
    lru_seq[i] = i;
  }
  sort(lru_seq, lru_seq+M, [&](int x, int y) -> bool {
      int xx = (qidx[x] == qidx[x+1]) ? ~x : queries[qidx[x+1]-1].second;
      int yy = (qidx[y] == qidx[y+1]) ? ~y : queries[qidx[y+1]-1].second;
      return xx < yy;
  });
  // printf("lru_seq = ");
  // for(int i = 0; i < M; ++i) {
  //   printf("%d, ", lru_seq[i]);
  // }
  // printf("\n");
  int max_ign = 1;
  while(max_ign < M && lru_seq[max_ign] <= lru_seq[max_ign-1]) ++max_ign;
  // printf("max_ign = %d\n", max_ign);
  static int max_times[100000];
  fill(max_times, max_times+N, Q);
  for(int i = M-1; i >= max_ign; --i) {
    int j = qidx[lru_seq[i]+1]-1;
    int min_j = qidx[lru_seq[i]];
    for(int k = 0; k < N; ++k) {
      while(j >= min_j && queries[j].second > max_times[k]) --j;
      if(j < min_j) {
        printf("No\n");
        return 0;
      }
      max_times[k] = queries[j].second;
      // printf("i=%d: max_times[%d] = %d\n", i, k, max_times[k]);
      --j;
    }
  }
  printf("Yes\n");
  return 0;
}


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;

  if ((B-A+1) <= 2*K) {
    for (int i = A; i <= B; i++) cout << i << endl;
  } else {
    for (int i = A; i <= A+K-1; i++) cout << i << endl;
    for (int i = B-K+1; i <= B; i++) cout << i << endl;
  }

  return 0;

}

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

using namespace std;

#pragma GCC optimize("-O3")
#pragma GCC target("avx2")

#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3652
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

calc :: Int -> Int -> Int -> Double
calc i n k
  | i > n = fromIntegral 0
  | i >= k = fromIntegral (n - i + 1)
  | otherwise = 1 / (2 ^ (fromIntegral (ceiling (logBase 2 ((fromIntegral k) / (fromIntegral i)))))) + calc (i + 1) n k

main = do
  [n, k] <- getIntList
  print $ (calc 1 n k) / (fromIntegral n)


Measured memory_bytes: 5164
#include<bits/stdc++.h>
using namespace std;
int n,dp[1111],ans[1111][1111];
int a4[4][4]={{1,1,3,4},{2,2,3,4},{5,6,7,7},{5,6,8,8}};
int a5[5][5]={{1,1,2,3,0},{0,0,2,3,4},{5,5,6,0,4},{7,0,6,8,8},{7,9,9,10,10}};
int a6[6][6]={{0,0,0,1,2,3},{0,0,0,1,2,3},{4,4,5,5,0,6},{0,0,7,7,8,6},{9,9,10,0,8,0},{11,11,10,0,12,12}};
int a7[7][7]={{0,0,0,0,1,2,3},{0,0,0,0,1,2,3},{0,0,0,0,4,5,6},{0,0,0,0,4,5,6},{7,7,8,8,0,0,9},{10,10,11,11,0,0,9},{12,12,13,13,14,14,0}};
void dfs(int n)
{
	if (!n) return;
	for (int i=4;i<=7;i++)
	{
		if (i<=n && dp[n-i])
		{
			dfs(n-i);
			int xx=n-i+1;
			if (i==4)
			{
				for (int j=0;j<4;j++)
				{
					for (int k=0;k<4;k++)
					{
						ans[xx+j][xx+k]=a4[j][k];
					}
				}
			}
			else if (i==5)
			{
				for (int j=0;j<5;j++)
				{
					for (int k=0;k<5;k++)
					{
						ans[xx+j][xx+k]=a5[j][k];
					}
				}
			}
			else if (i==6)
			{
				for (int j=0;j<6;j++)
				{
					for (int k=0;k<6;k++)
					{
						ans[xx+j][xx+k]=a6[j][k];
					}
				}
			}
			else
			{
				for (int j=0;j<7;j++)
				{
					for (int k=0;k<7;k++)
					{
						ans[xx+j][xx+k]=a7[j][k];
					}
				}
			}
			return;
		}
	}
}
int main()
{
	scanf("%d",&n);
	if (n<=2) 
	{
		printf("-1\n");
		return 0;
	}
	if (n==3)
	{
		printf("..a\n..a\nbb.\n");
		return 0;
	}
	dp[0]=1;
	for (int i=4;i<=n;i++)
	{
		for (int j=4;j<=7;j++)
		{
			if (i>=j && dp[i-j]) dp[i]=1;
		}
	}
	dfs(n);
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			if (!ans[i][j]) putchar('.');
			else putchar('a'+ans[i][j]-1);
		}
		putchar('\n');
	}
	return 0;
}

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

int main(){
    int m;
    long long n;
    cin>>n>>m;
    vector<int> v(m);

    long long sum = 0;
    long long temp;
    for(int i=0; i<m; i++){
        cin>>temp;
        sum += temp;
    }
    if(sum > n){
        cout<<-1<<endl;
    }
    else{
        cout<<n-sum<<endl;
    }

}


Measured memory_bytes: 3672
#include<cstdio>
#include<algorithm>
using namespace std;
int N,A,B,que[300005];
int main(void){
	int i,bl,l,r,t,now=0;
	scanf("%d%d%d",&N,&A,&B);
	if(A+B>N+1||1ll*A*B<N){
		puts("-1");
		return 0;
	}
	r=N,l=r-A+1;
	for(;now<A;)que[++now]=l+now-1;t=1;
	r=l-1,l=max(1,r-A+1);
	while(r&&t+r+1-min(A,r-l+1)>=B){
		for(i=1;i<=A&&l+i-1<=r;++i)que[++now]=l+i-1;++t,r=l-1,l=max(1,r-A+1);
	}
	l=1,r=B-t,bl=r+1;
	for(i=r;i;--i)que[++now]=i;
	for(i=1;now<=N;++i)que[++now]=bl+i-1;
	for(i=1;i<=N;++i)printf("%d ",que[i]);
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <stdlib.h>

using namespace std;


int main()
{
    int a;
    cin>>a;
    int b=a%10;
    a/=10;
    int c=a%10;
    int d=a/10;
    if(b==7||c==7||d==7) cout<<"Yes";
    else cout<<"No";

    return 0;
}


Measured memory_bytes: 3580
import java.util.*;

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

		Scanner sc = new Scanner(System.in);

		String s = sc.nextLine();

		String a[] = { "Sunny", "Cloudy", "Rainy" };
		if (s.equals(a[0])) {
			System.out.println("Cloudy");
		} else if (s.equals(a[1])) {
			System.out.println("Rainy");
		} else if (s.equals(a[2])) {
			System.out.println("Sunny");
		}
	}
}


Measured memory_bytes: 20820
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
bool composite[1000001];
int a,d,n;
int main(void){
  composite[0] = composite[1] = true;
  FOR(i,2,1000001){
    if(!composite[i]){
      for(int k=2; i*k<1000001; k++){
        composite[i*k] = true;
      }
    }
  }
  while(cin>>a>>d>>n){
    if(a==0) break;
    while(n){
      if(!composite[a]) n--;
      if(!n) cout<<a<<endl;
      a+=d;
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstdio>
#define INF 1010001000

using namespace std;

pair<int, int> line[200001];
int n;

int main(void)
{
    int i, j;
    long long ans = 0;
    int w, h;
    int wc, hc;

    scanf("%d %d", &w, &h);
    for (i = 0; i < w; i++) {
        cin >> line[i].first;
        line[i].second = i;
    }
    for (; i < h+w; i++) {
        cin >> line[i].first;
        line[i].second = i;
    }
    sort(line, line+w+h);

    wc = 0;
    hc = 0;
    for (i = 0; i < h+w; i++) {
        int pos = line[i].second;
        if (pos < w) {
            wc++;
            ans += (long long )(h - hc + 1) * (long long )line[i].first;
        } else {
            hc++;
            ans += (long long )(w - wc +1 ) * (long long )line[i].first;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n';
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int k,x; cin >> k >> x;
    for(int i=x-k+1; i<=x+k-1; i++)out(i);

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <iomanip>
#include <utility>
#include <set>
using namespace std;

int n,m,x,q;

int main(){
    scanf("%d %d %d",&n,&m,&x);
    for(int i=0;i<n;i++){
        scanf("%d",&q);
        //x+=m/q+int(m%q>0);
        x+=int(ceil(float(m)/float(q)));
    }
    printf("%d\n",x);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
struct unionfind{
    public:
    vector<ll>par;
    vector<ll>siz;
    unionfind(ll n) :par(n),siz(n,1LL){
        rep(0,i,n)par[i]=i;
    }
    ll root(ll x){
        if(par[x]==x)return x;
        return par[x]=root(par[x]);
    }
    bool merge(ll x,ll y){
        x=root(x);
        y=root(y);
        if(x==y)return false;
        if(siz[x]<siz[y])swap(x,y);
        siz[x]+=siz[y];
        par[y]=x;
        return true;
    }
    bool same(ll x,ll y){
        ll rx=root(x);
        ll ry=root(y);
        return rx==ry;
    }
    ll size(ll x){
        return siz[root(x)];
    }
};
int main(void){
    // Your code here!
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll>>a(m);
    rep(0,i,m){
        cin>>a[i].first>>a[i].second;
        --a[i].first,--a[i].second;
    }
    ll ans[m+1];
    unionfind tree(n);
    ans[m]=n*(n-1)/2;
    rep(0,i,m){
        ll na=a[m-1-i].first,nb=a[m-1-i].second;
        ll sa=tree.size(na),sb=tree.size(nb);
        if(tree.merge(na,nb))ans[m-1-i]=ans[m-i]-sa*sb;
        else ans[m-1-i]=ans[m-i];
    }
    rep(1,i,m+1)cout<<ans[i]<<endl;
}

Measured memory_bytes: 7208
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  vi ans(32);
  ans = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
  int a;
  cin >> a;
  a--;
  cout << ans.at(a);
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (auto& e : a) cin >> e;
  for (auto& e : b) cin >> e;

  for (int k = 0; k < 2; k++) {
    for (int i = 0, j = 1; i < n; i++, j = max(j, i + 1)) {
      if (a[i] != b[i]) continue;
      while (j < n && a[i] == b[j]) j++;
      if (j == n) break;
      swap(b[i], b[j]);
    }
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
  }

  // for (auto e : a) cerr << e << ' ';
  // cerr << endl;
  // for (auto e : b) cerr << e << ' ';
  // cerr << endl;

  bool r = true;
  for (int i = 0; i < n; i++) r = r && a[i] != b[i];

  if (r) {
    cout << "Yes" << endl;
    for (auto e : b) cout << e << ' ';
    cout << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 4836
#include<stdio.h>
int main(){
  int n,m,a,b,k,o,e,i,j,l,mi,min;
  while(scanf("%d %d",&m,&n),n||m){
    int d[2][110][110]={0};
    while(m--){
      scanf("%d %d %d %d",&a,&b,&o,&k);
      d[0][a][b]=d[0][b][a]=o;
      d[1][a][b]=d[1][b][a]=k;
    }
    scanf("%d",&m);
    while(m--){
      int f[110]={0};
      int c[110]={0};
      scanf("%d %d %d",&mi,&e,&l);
      for(i=0;i<n;i++){
	f[mi]=1;
	for(j=1;j<=n;j++){
	  if(f[j]||d[l][mi][j]==0)continue;
	  if(c[j]>c[mi]+d[l][mi][j]||c[j]==0)c[j]=c[mi]+d[l][mi][j];
	}
	min=2100000000;
	for(j=1;j<=n;j++){
	  if(f[j]||c[j]==0)continue;
	  if(min>c[j])min=c[mi=j];
	}
      }
      printf("%d\n",c[e]);
    }
  }
  return 0;
}

Measured memory_bytes: 700
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = Math.max(2*A-1, Math.max(2*B-1,A+B));
        System.out.println(C);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(){
    long long N; 
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i< N; i++) cin >> A[i];
    map<long long, long long> m;
    m[A[0]]++;
    m[0]++;
    for(int i = 1; i < N; i++){
        A[i] += A[i - 1];
        m[A[i]]++;
    }
    long long ans = 0;
    for(auto v: m){
        ans += v.second*(v.second - 1) / 2;
    }
    cout << ans << endl;
}

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

int findSumOfDigits(int n){
  int sum = 0;
  while(n>0){
    sum += n % 10;
    n = n/10;
  }
  return sum;
}

int main(){
  int n,a,b;
  cin >>n >>a >>b;
  
  int total=0;
  for(int i=1;i<=n;i++){
    int sum = findSumOfDigits(i);
    if(sum >= a && sum <= b){
      total += i;
    }
  }
  cout<<total<<endl;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut sides: Vec<usize> = iter.map(|s| s.parse::<usize>().unwrap())
        .collect();
    sides.sort();
    
    let mut sum = 0;
    for i in 0..sides.len()-1 {
        sum += sides[i];
    }
    
    if sides[sides.len()-1] < sum {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
s = input()
table = [0] * 30
o = lambda x: ord(x) - ord('a')
kind = 0
for c in s:
    if table[o(c)] == 0:
        kind += 1
    table[o(c)] += 1

if kind > 2 and s[0] != s[-1]:
    print("First") if len(s) % 2 == 1 else print("Second")
elif kind > 2 and s[0] == s[-1]:
    print("Second") if len(s) % 2 == 1 else print("First")
else:
    print("Second")


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int,int> pii;
#define fi first
#define se second

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

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> field(h);
  rep(i, h) cin >> field[i];

  vector<vector<int> > dist(h, vector<int>(w, -1));
  dist[0][0] = 0;

  queue<pii> que;
  que.push(make_pair(0, 0));

  while(!que.empty()){
    pii pos = que.front();
    int x = pos.fi;
    int y = pos.se;
    que.pop();
    rep(i, 4){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(nx<0 || h<=nx || ny<0 || w<=ny) continue;
      if(field[nx][ny] == '#') continue;
      if(dist[nx][ny] == -1){
        dist[nx][ny] = dist[x][y] + 1;
        que.push(make_pair(nx, ny));
      }
    }
  }
  
  if(dist[h-1][w-1] == -1) cout << -1 << endl;
  else{
    int cnt = 0;
    rep(i, h) rep(j, w) if(field[i][j] == '#') cnt++;
    int ans = h*w - cnt - dist[h-1][w-1] - 1;
    cout << ans << endl;
  }

  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

const ll N_MAX = 3000005;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll) i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll combination(ll C, ll D){
    if(C<D||C<1) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    make();

    ll res = 0;
    for(int i=a;i<=c;i++){
    	res += combination(i+d+1, d);
    	res %= mod;
    	res -= combination(i+b, b-1);
    	res += mod;
    	res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 70528
#include<stdio.h>
int main(void){
int a,i,n,t=0,h=0,x,y;
char hanako[110],tarou[110];
scanf("%d",&a);
for(i=0;i<a;i++){
scanf("%s %s",tarou,hanako);
for(n=0;n<110;n++){
x=tarou[n]-'a';
y=hanako[n]-'a';
if(x>y){t+=3;n=110;}
else if(x<y){h+=3;n=110;}
else if(tarou[n]=='\0'&&hanako[n]=='\0'){h+=1;t+=1;n=110;}
}
}
printf("%d %d\n",t,h);
return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007

const int maxn = 100010;
int dp[maxn][3];
int a[maxn], b[maxn], c[maxn];
int n;
void solve()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[1][0] = a[1];
	dp[1][1] = b[1];
	dp[1][2] = c[1];

	for (int i = 2; i <= n; i++)
	{
		dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
	}
	int ans = max(dp[n][0], max(dp[n][1], dp[n][2]));
	cout << ans;
}

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


Measured memory_bytes: 8264
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll n,l;
  cin >> n >> l;
  ll ans=0,m=INF;
  rep(i,n){
    ans+=l+i;
    if(abs(m)>abs(l+i))m=l+i;
  }
  cout << ans-m << endl;
}


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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

void init(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 2e3+5;

int main()
{
	init();
	double a, b, x;
	cin >> a >> b >> x;
	if(x/a <= b*a/2)
		cout << setprecision(20) << 180 * (atan(b / (2*x / (a*b))) / M_PI);
	else
		cout << setprecision(20) << 180 * (atan((2 * (a*b - (x/a)) /  a) / a) / M_PI);
	return 0;
}


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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	if(a==5&&b==5&&c==7){
		cout<<"YES"<<endl;
		return 0;
	}
	if(a==5&&b==7&&c==5){
		cout<<"YES"<<endl;
		return 0;
	}
	if(a==7&&b==5&&c==5){
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#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()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }
    int state = 1;
    int count = 0;
    rep(i, n){
        if(a[i] == state){
            state++;
            count++;
        }
    }
    cout << (count ? n - count : -1) << endl;
    return 0;
}


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

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

  bool ans = false;
  if (a <= x && a+b > x) ans = true;
  
  cout << ((ans) ? "YES" : "NO") << endl;
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<long long> l(N), r(N);
    long long sum = 0;
    REP(i, N) {
        cin >> l[i] >> r[i];
        sum += r[i] - l[i] + 1;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
v = [int(x) for x in input().split()]
dic0 = {}
dic1 = {}
for i in range(n):
  if i % 2 == 0:
    if v[i] in dic0:
      dic0[v[i]] += 1
    else:
      dic0[v[i]] = 1
  else:
    if v[i] in dic1:
      dic1[v[i]] += 1
    else:
      dic1[v[i]] = 1
list0 = sorted(dic0.items(), key = lambda x : x[1])
list1 = sorted(dic1.items(), key = lambda x : x[1])
l0 = len(list0) - 1
l1 = len(list1) - 1

if list0[l0][0] != list1[l1][0]:
  print(n - list0[l0][1] - list1[l1][1])
else:
  if l0 == 0 and l1 == 0:
    print(n // 2)
  elif l0 == 0:
    print(n - max(list0[0][1] + list1[l1 - 1][1], list1[l1][1]))
  elif l1 == 0:
    print(n - max(list0[l0 - 1][1] + list1[0][1], list0[l0][1]))
  else:
    print(n - max(list0[l0 - 1][1] + list1[l1][1], list0[l0][1] + list1[l1 - 1][1]))


Measured memory_bytes: 20760
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>

int main(int argc, char **argv) {
    int N;
    std::cin >> N;

    std::vector<long long> A;
    for (int i = 0; i < N; i++) {
        long long a;
        std::cin >> a;
        A.push_back(a);
    }

    std::unordered_map<long long, long long> counts;
    for (auto a : A) {
        counts[a]++;
    }

    long long sumAll = 0;
    for (auto c : counts) {
        sumAll += c.second * (c.second - 1) / 2;
    }

    for (int i = 0; i < N; i++) {
        // just adjust that one item
        auto excludeOneOf = A[i];
        long long currSum = sumAll;
        auto c = counts[excludeOneOf];
        currSum -= c * (c - 1) / 2;
        currSum += (c - 1) * (c - 2) / 2;
        std::cout << currSum << std::endl;
    }

    return 0;
}


Measured memory_bytes: 10096
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  int A, B, C;
  cin >> A >> B >> C;
  int ans = 0;

  while (1) {
    if(A%2 != 0 || B%2 != 0 || C%2 != 0)break;
    int a = A;
    int b = B;
    int c = C;
    A = (b+c)/2;
    B = (a+c)/2;
    C = (a+b)/2;
    ans++;
    if(A == B && A == C && B == C) {
      ans = -1;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3644
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
const int maxn = 10;
int n;
int p[maxn] , q[maxn] , t[maxn];
inline void init() {
	for(register int i = 1; i <= n; ++i)
		t[i] = i;
}
inline bool check(int *a) {
	for(register int i = 1; i <= n; ++i)
		if(a[i] != t[i]) return false;
	return true;
}
int main() {
	cin >> n;
	for(register int i = 1; i <= n; ++i) cin >> p[i];
	for(register int i = 1; i <= n; ++i) cin >> q[i];
	init();
	int cnt1 = 0 , cnt2 = 0;
	while(!check(p)) {
		cnt1++;
		next_permutation(t + 1 , t + n + 1);
	}
	init();
	while(!check(q)) {
		cnt2++;
		next_permutation(t + 1 , t + n + 1);
	}
	cout << abs(cnt1 - cnt2) << endl;
	return 0;
} 

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


void solve(long long L){
    double x = L / 3.0;
    printf("%.10f\n", x * x * x);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long L;
    scanf("%lld",&L);
    solve(L);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int i, n, x, l[200], sum = 0;
	scanf("%d %d", &n, &x);
	for (i = 0; i < n; i++)
		scanf("%d", &l[i]);
	for (i = 0; i < n; i++) {
		sum += l[i];
		if (sum > x) {
			printf("%d", i + 1);
			return 0;
		}
	}
	printf("%d", n + 1);
	return 0;
}

Measured memory_bytes: 128
import math
a, b, C = [int(x) for x in input().split()]

S = a * b * math.sin(math.radians(C)) / 2
h = b * math.sin(math.radians(C))
L = math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.radians(C)))
print(S)
print(a + b + L)
print(h)


Measured memory_bytes: 5720
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int n,w,dp[N];
    cin>>n>>w;
    pii a[n];
    for (int i = 0; i < n; ++i)
        cin>>a[i].ff>>a[i].ss;
    for (int i = 0; i < N; ++i)
        dp[i] = MOD;
    dp[0] = 0;
    int ans(0);
    for (int i = 0; i < n; ++i)
    {
        for(int j = N ; j>=0; j--)
        {
            if(j-a[i].ss>=0)
            {
                dp[j] = min(dp[j], dp[j-a[i].ss] + a[i].ff );
            }
        }
    }
    for (int i = 0; i < N; ++i)
    {
        if(dp[i]<=w)
            ans = i;
    }

    cout<<ans;
    printclock;
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int w,h,x,y,r;
	std::string answer;

	std::cin >> w >> h >> x >> y >> r;

	// ???
	if ((y + r) > h) {
		answer = "No";
	}
	// ???
	else if ((y - r) < 0) {
		answer = "No";
	}
	// ???
	else if ((x + r) > w) {
		answer = "No";
	}
	// ???
	else if ((x - r) < 0) {
		answer = "No";
	}
	else {
		answer = "Yes";
	}
	std::cout << answer << std::endl;

	return 0;
}

Measured memory_bytes: 1196
from math import sqrt,cos,atan2

class Ufo:
	def __init__(self,px,py,d,vd,ui):
		self.pd=sqrt(px**2+py**2)
		self.px=float(px)
		self.py=float(py)
		self.fpd=self.pd
		self.fpx=self.px
		self.fpy=self.py
		self.ex=self.fpx/self.fpd
		self.ey=self.fpy/self.fpd
		self.d=float(d)
		self.vd=float(vd)
		self.vx=-self.vd*self.ex
		self.vy=-self.vd*self.ey
		self.i=ui
	def move(self):
		self.pd -= self.vd
		self.px += self.vx
		self.py += self.vy



while True:
	R,ul=tuple(map(int,raw_input().split()))
	if(R==0 and ul==0): break
	us=[]
	for ui in xrange(ul):
		px,py,d,vd = tuple(map(int,raw_input().split()))
		u = Ufo(px,py,d,vd,ui)
		us.append(u)

	re=0
	while True:
		for u in us: u.move()
		us.sort(key=lambda u: u.pd)

		for u in us[:]:
			if u.pd<=R:
				re+=1
				us.remove(u)
				#print u.i, "due to invade"
				continue
			else:
				break
		if len(us)==0: break

		neu=us.pop(0)
		#print "focus",neu.i
		#print neu.i,"due to hit"

		for u in us[:]:
			d = u.pd*abs(neu.fpx*u.fpy-neu.fpy*u.fpx)/neu.fpd/u.fpd	#u kara laser ni orosita suisen no nagasa
			if d<u.d:
				if u.pd*cos(atan2(u.fpy,u.fpx)-atan2(neu.fpy,neu.fpx)) + sqrt(u.d**2-d**2) > R:
					us.remove(u)
					#print u.i, "due to hit"
		if len(us)==0: break

	print re

Measured memory_bytes: 4692
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
inf=10**9
def dfs(d,a,b,c):
    if d==N:#合成完了
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf #無からは作れない#0に合成するのにmpは使わないので-30
    ret0=dfs(d+1,a,b,c)#l[d]を使わない
    ret1=dfs(d+1,a+l[d],b,c)+10#l[d]をAに
    ret2=dfs(d+1,a,b+l[d],c)+10#l[d]をBに
    ret3=dfs(d+1,a,b,c+l[d])+10#l[d]をCに
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))

Measured memory_bytes: 3064
n,m,c = map(int,input().split())

b = list(map(int,input().split()))
a = [list(map(int,input().split())) for _ in range(n)]

count = 0
for ai in a:
  s = sum([bi*aii for bi, aii in zip(b,ai)]) + c  
  if s > 0:
    count += 1

print(count)    

Measured memory_bytes: 3064