akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
// ------ Classes ------ //
class Point {
public:
	long double px, py;
	Point() : px(0), py(0) {};
	Point(long double px_, long double py_) : px(px_), py(py_) {};
	friend bool operator==(const Point& p1, const Point& p2) { return p1.px == p2.px && p1.py == p2.py; }
	friend bool operator!=(const Point& p1, const Point& p2) { return p1.px != p2.px || p1.py != p2.py; }
	friend bool operator<(const Point& p1, const Point& p2) { return p1.px < p2.px ? true : (p1.px == p2.px && p1.py < p2.py); }
	friend bool operator>(const Point& p1, const Point& p2) { return p1.px > p2.px ? true : (p1.px == p2.px && p1.py > p2.py); }
	friend bool operator<=(const Point& p1, const Point& p2) { return !(p1 > p2); }
	friend bool operator>=(const Point& p1, const Point& p2) { return !(p1 < p2); }
	friend Point operator+(const Point& p1, const Point& p2) { return Point(p1.px + p2.px, p1.py + p2.py); }
	friend Point operator-(const Point& p1, const Point& p2) { return Point(p1.px - p2.px, p1.py - p2.py); }
	friend Point operator*(const Point& p1, long double d) { return Point(p1.px * d, p1.py + d); }
	friend Point operator*(long double d, const Point& p1) { return p1 * d; }
	friend Point operator/(const Point& p1, long double d) { return Point(p1.px / d, p1.py / d); }
	Point& operator+=(const Point& p1) { px += p1.px; py += p1.py; return *this; }
	Point& operator-=(const Point& p1) { px -= p1.px; py -= p1.py; return *this; }
	Point& operator*=(long double d) { px *= d; py *= d; return *this; }
	Point& operator/=(long double d) { px /= d; py /= d; return *this; }
};
// ------ Functions ------ //
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point& a) { return sqrtl(norm(a)); }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
long double area(vector<Point> v) {
	long double ret = 0.0L;
	for (int i = 0; i < v.size(); i++) ret += crs(v[i], v[(i + 1) % v.size()]);
	return ret / 2;
}
// ------ Main ------ //
int n, c; vector<Point> v;
int main() {
	while(scanf("%d", &n), n) {
		v.resize(n);
		for(int i = 0; i < n; i++) cin >> v[i].px >> v[i].py;
		printf("%d %.1Lf\n", ++c, abs(area(v)));
	}
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define pri 1000000007
#define nonod 1000001
#define pr pair <ll,ll>
#define mnx  1000001
#define inf 100000000000000001
#define prin(x) cout<<setprecision(9)<<fixed<<x<<endl;
using namespace std;





void masterstroke(ll ta){
string a;
cin>>a;
ll ans=0;

ll n=a.length();
ll p2[n+1],p3[n+1];
p2[0]=1;
p3[0]=1;
for(ll i=1;i<=n;i++){
	p2[i]=(p2[i-1]*2)%pri;
	p3[i]=(p3[i-1]*3)%pri;
}
ll c=0;
for(ll i=0;i<n;i++){
	if(a[i]=='1'){
		ans=(ans+p2[c]*p3[n-1-i])%pri;
		c++;
	}
}
ans=ans+p2[c];
cout<<ans%pri<<endl;


}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)masterstroke(i);
}

Measured memory_bytes: 2000
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

char X, Y;

int main(void){
    
    cin >> X >> Y;
    
    if(X - 'A' > Y - 'A') printf(">\n");
    else if(X - 'A' < Y - 'A') printf("<\n");
    else printf("=\n");
    
    return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
if n == 1 and m == 0:
    print(0)
    exit()
ans = ["-" for _ in range(n)]

for _ in range(m):
    s, c = map(int, input().split())
    if n == m == 1 and s == 1 and c == 0:
        print(0)
        exit()
    if s == 1 and c == 0:
        print(-1)
        exit()
    if ans[s - 1] == "-":
        ans[s - 1] = c
    else:
        if ans[s - 1] != c:
            print(-1)
            exit()

for i, a in enumerate(ans):
    if i == 0:
        if a == "-":
            print(1, end="")
        else:
            print(a, end="")
    else:
        if a == "-":
            print(0, end="")
        else:
            print(a, end="")



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

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

    vector<vector<int>> to(N), cost(N);
    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        to[u].push_back(v);
        cost[u].push_back(w);
        to[v].push_back(u);
        cost[v].push_back(w);
    }

    vector<int> ans(N, -1);
    queue<int> q;
    ans[0] = 0;
    q.push(0);

    while (!q.empty()) {
        int v = q.front();
        q.pop();
        rep(i, to[v].size()) {
            int u = to[v][i];
            int w = cost[v][i];
            if (ans[u] != -1) continue;
            ans[u] = (ans[v] + w) % 2;
            q.push(u);
        }
    }

    for (int i = 0; i < N; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 11904
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N;
  cin >> N;
  if(N<=8){
    cout << (N%6 + N/6) << endl;
    return 0;
  }

  int dp[N+1];
  REP(i, N+1) dp[i] = i;
  dp[1]=1;
  dp[6]=1;
  dp[9]=1;
  int six, nine;
  for(int i = 2; i<=N; ++i){
    six = 6;
    nine = 9;
    while(i>=six){
      dp[i] = min(dp[i], dp[i-six]+1);
      six *= 6;
    }
    while(i>=nine){
      dp[i] = min(dp[i], dp[i-nine]+1);
      nine *= 9;
    }
  }
  cout << dp[N] << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static double solve(int n, int[] prob) {
      int limit = 301;
      double[][][] dp = new double[limit][limit][limit];
      
      for(int i = 0; i < limit; i++) {
        for(int j = 0; j < limit; j++) {
          for(int k = 0; k < limit; k++) {
            dp[i][j][k] = -1;
          }
        }
      }
      
      double result = dfs(dp, n, prob[1],prob[2],prob[3]);
      
      return result;
    }
  
  	private static double dfs (double[][][] dp, int n, int a, int b, int c){
      if(a == 0 && b ==0 && c ==0){
        return 0;
      }
      if(dp[a][b][c] != -1) {
        return dp[a][b][c];
      }
      
      double prob = (double) n / (a + b + c);
      double result = 0;
      
      if(a > 0){
        result += (prob + dfs(dp, n, a - 1, b, c)) * a / (a + b + c);
      }
      if(b > 0){
        result += (prob + dfs(dp, n, a + 1, b - 1,c)) * b / (a + b + c);
      }
      if(c > 0){
        result += (prob + dfs(dp, n, a, b + 1,c-1)) * c / (a + b + c); 
      }
      
      dp[a][b][c] = result;
      return result;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        
      	int[] vals = new int[4];
        for (int i = 0; i < n; i++) {
          int val = scanner.nextInt();
          vals[val]++;
        }

      	double result = solve(n, vals);
      
        System.out.println(result);
    }
}


Measured memory_bytes: 308152
#include <bits/stdc++.h>
using namespace std;
 
typedef vector<int>  vi;
typedef set<char> setchar;
typedef set<int> sett;
typedef deque <int> dq;
typedef long long ll;
#define vec(a)  a.begin(),a.end()
#define pb     push_back
#define pf     push_front
#define mem(a,b) memset(a,b,sizeof(a));
#define inI(a)  scanf("%d",&a);
#define inT(a,b)  scanf("%d %d",&a,&b);
#define inL(a)  scanf("%lld",&a);
#define SWAP(a,b) a= a^b, b=a^b, a=a^b
 
//int fx[]={+0,-1,-1,-1,+0,+1,+1,+1};
//int fy[]={-1,-1,+0,+1,+1,+1,+0,-1};
int fx[]= {0,-1,0,+1};
int fy[]= {-1,0,+1,0};
 
 
 
int main()
{
 
    //freopen("input.txt","r",stdin);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<"\n";
 
 
 
    return 0;
 
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
	int a,b,c,n;
int main(){

	cin>>a>>b;
	c=b;
	while(c>0){
		c/=10;
		n++;
	}
	a=a*pow(10,n)+b;
	if(sqrt(a)==floor(sqrt(a)))
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define display(v) for (auto x : v) cout << x << ", "
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define endl '\n'
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
 
// DEBUG TEMPLATE by livw
void __print(int x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifdef INCLUDEWHENOFFLINE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main()
{
    fastio;
    ll n;
    cin >> n;
    ll ans = (n / 500) * 1000;
    n %= 500;
    ans += (n / 5) * 5;
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	int[] dx,dy;
	int n,x,y;
	Scanner stdin=new Scanner(System.in);
	
	void Solve(){
		while(true){
			n=stdin.nextInt();
			if(n==0) break;
			if(n==1){
				System.out.println("1 1");
			
			}else{
				dx=new int [n];
				dy=new int [n];
				
				
				
				for(int i=1;i<n;i++){
					int j=stdin.nextInt();
					int k=stdin.nextInt();
					set(i,j,k);
				}
				
				dx[0]=Integer.MAX_VALUE;
				dy[0]=Integer.MAX_VALUE;
				
				
				Arrays.sort(dx);
				Arrays.sort(dy);
				if(dx[0]*dx[n-2]>0){
					x=dx[n-2]-dx[0]+2;
				}else x=dx[n-2]-dx[0]+1;
				
				if(dy[0]*dy[n-2]>0){
					y=dy[n-2]-dy[0]+2;
				}else y=dy[n-2]-dy[0]+1;
				
				System.out.println(x+" "+y);
			}
		}
	}
	
	void set(int i,int j,int k){
		switch(k){
		case 0:
			dx[i]=dx[j]-1;
			dy[i]=dy[j];
			break;
		case 1:
			dx[i]=dx[j];
			dy[i]=dy[j]-1;
			break;
		case 2:
			dx[i]=dx[j]+1;
			dy[i]=dy[j];
			break;
		case 3:
			dx[i]=dx[j];
			dy[i]=dy[j]+1;
			break;
			
			
	
		}
		
	}
	
	
	public static void main(String args[]){
		Main m=new Main();
		m.Solve();
	}
	
	
	
}

Measured memory_bytes: 34240
//#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1e9 + 7;
const ll infll = 1e18 + 9;
const int infint = 1e9 + 7;
const int MAXN = 1e5 + 7;
const double eps = 1e-9;
const long double pi = 3.1415926535897932384626433832795;
const long double e = 2.71828182845904523536028747135266;
inline ll read()
{
    ll kr = 1, xs = 0;char ls;ls = getchar();
    while (!isdigit(ls)){
        if (!(ls ^ 45)) kr = -1;
        ls = getchar();
    }
    while (isdigit(ls)){
        xs = (xs << 1) + (xs << 3) + (ls ^ 48);ls = getchar();
    }return xs * kr;
}
// inline __int128 read128()
// {
//     __int128 kr=1,xs=0;char ls;ls=getchar();
//     while(!isdigit(ls)){
//         if(!(ls^45)) kr=-1;ls=getchar();
//     }
//     while(isdigit(ls)){
//         xs=(xs<<1)+(xs<<3)+(ls^48);ls=getchar();
//     }
//     return xs*kr;
// }
inline ull readull()
{
    ull xs = 0;char ls;ls = getchar();
    while (!isdigit(ls))ls = getchar();
    while (isdigit(ls)){
        xs = (xs << 1) + (xs << 3) + (ls ^ 48);ls = getchar();
    }return xs;
}
inline void writeull(ull x)
{
    if (x < 0){
        x *= -1;putchar('-');
    }
    if (x >= 10) writeull(x / 10);
    putchar('0' + x % 10);
}
inline void write(ll x)
{
    if (x < 0){
        x *= -1;putchar('-');
    }
    if (x >= 10) write(x / 10);
    putchar('0' + x % 10);
}
// inline void write(__int128 x){
//     if(x<0){x*=-1;putchar('-');}
//     if(x>=10) write(x/10);
//     putchar('0'+x%10);
// }
///////////////////////////////////////////////////////////////////////////////////////
int a[109],b[109];
int main()
{
    int t=1;
    // t = read();
    while(t--){
        int n=read();
        for (int i=1;i<=n;i++){
            a[i]=read(),b[i]=read();
        }
        int flag=0;
        for (int i=1;i<=n-2;i++){
            if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
                cout << "Yes" << endl;
                flag=1;
                break;
            }
        }
        if(!flag) cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N, ans;
    cin >> N;
    vector<vector<int>> whoIsHonest(N, vector<int>(0));
    vector<vector<int>> whoIsUnkind(N, vector<int>(0));
    rep(i, N){
        int A;
        cin >> A;
        rep(j, A){
            int c,d;
            cin >> c >> d;
            if(d == 1){
                whoIsHonest[i].push_back(c - 1);
            } else {
                whoIsUnkind[i].push_back(c - 1);
            }
        }
    }

    ans = 0;
    for(int i = (1 << N) - 1; i > 0; i--){
        bool canBeAnswer = true;
        bitset<15> bit(i);
        rep(j, N){
            bool isReasonable = true;
            if(bit.test(j)){
                for(int x: whoIsHonest[j]){
                    if(!bit.test(x)){
                        isReasonable = false;
                        break;
                    }
                }
                for(int x: whoIsUnkind[j]){
                    if(bit.test(x)){
                        isReasonable = false;
                    }
                }
                if(!isReasonable) {
                    canBeAnswer = false;
                    break;
                }
            }
        }
        if(canBeAnswer){
            int cnt = 0;
            rep(j, N){
                if(bit.test(j)) cnt++;
            }
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
<?php

$n = (int)trim(fgets(STDIN));
$s = trim(fgets(STDIN));



$animal = ['S','W'];

for ($i=0; $i < 2; $i++) { 
	for ($j=0; $j < 2; $j++) { 
		$t = $animal[$i] . $animal[$j];
		for ($k=1; $k < $n; $k++) { 
			$tmp_str = $s[$k];
			$tmp_anm = $t[$k];
			if ($tmp_anm === 'S') {
				if ($tmp_str === 'o') {
					$t .= $t[$k-1];
				}else{
					$t .= not($t[$k-1]);
				}
			}else{
				if ($tmp_str === 'o') {
					$t .= not($t[$k-1]);
				}else{
					$t .= $t[$k-1];
				}
			}
		}
		$start_str = $s[0];
		$start_anm = $t[0];
		if ($start_anm === $t[$n]) {
			if ($start_anm === 'S') {
				if($start_str === 'o' && $t[$n-1] === $t[1] || $start_str === 'x' && $t[$n-1] !== $t[1]){
					echo substr($t, 0, $n);
					exit(0);
				}
			}else{
				if($start_str === 'o' && $t[$n-1] !== $t[1] || $start_str === 'x' && $t[$n-1] === $t[1]){
					echo substr($t, 0, $n);
					exit(0);
				}
			}
		}
	}
}
echo '-1';

function not($str){
	if ($str === 'S') {
		return 'W';
	}
	return 'S';
}

Measured memory_bytes: 4728
/************************Code by Hardik Aggarwal!!!!***********************************/

#include<bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;

int main()
{
      

    IOS
    ll n;
    cin>>n;
    pll a[n];
    ll ans[n];
    for(ll i=0;i<n;i++)
        {cin>>a[i].ff;
            a[i].ss=i;}
    sort(a,a+n);
    for(ll i=0;i<n;i++)
    {
        if(i<n/2)
            ans[a[i].ss]=(a[n/2].ff);
        else 
            ans[a[i].ss]=a[(n/2)-1].ff;

    }


    for(ll i=0;i<n;i++) cout<<ans[i]<<endl;
}
    
 
    
    



Measured memory_bytes: 6912
#include <stdio.h>
#define N 52

int main() {
    int H, W;
    scanf("%d %d", &H, &W);

    char s[N][N] = {{0}};
    for (int i = 1; i <= H; i++)
       scanf("%s", s[i] + 1);

    for (int i = 1; i <= H; i++)
       for (int j = 1; j <= W; j++)
          if (s[i][j] == '#' && s[i][j+1] != '#' && s[i][j-1] != '#'
                  && s[i-1][j] != '#' && s[i+1][j] != '#') {
              printf("No\n");
              return 0;
          }

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


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define int ll
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }

template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const {
        return F::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class F>
constexpr decltype(auto) funcs(F &&f) {
    return FixPoint<F>{std::forward<F>(f)};
}

template <class T>
std::vector<T> vecs(int n, T &&val) {
    return std::vector<T>(std::forward<int>(n), std::forward<T>(val));
}

template <class... Args>
decltype(auto) vecs(int n, Args &&... args) {
    return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...));
}

template <class V, class T>
void fill(V &x, const T &val) {
    x = val;
}

template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    string s, t;
    cin >> s >> t;
    if (t.substr(0,sz(t) - 1) == s)
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main(void) {
  int n, d, x;
  int ans=0;
  cin>>n>>d>>x;
  for(int i=0; i<n; i++) {
    int a;
    cin>>a;
    ans+=(d-1)/a+1;
  }
  cout<<ans+x<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int K;
    cin >> K;
    int tmp = 1, left = 1;
    int size = S.size();
    if (size == 1) {
        printf("%d\n", K/2);
        return 0;
    }
    for (int i = 1; i < size; ++i) {
        if (S[i] == S[i-1]) {
            tmp += 1;
        } else {
            if (i == tmp) left = tmp;
            ans += tmp/2;
            tmp = 1;
        }
    }
    if (size == tmp) left = tmp;
    ans += tmp/2;
    ans *= K;
    if (S[0] == S[size-1] && tmp%2 == 1 && left % 2 == 1) {
        if (size == left) {
            ans += K/2;
        } else {
            ans += K - 1;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;
typedef long long int ll;
int main(void){
    int n , y ;
    int x , f , z ;
    x = -1 ;
    f = -1 ; 
    z = -1 ;
    cin >> n >> y ;
    for(int i = 0 ; i <= n ; i++){
        for(int j = 0; j <=n ; j++){
            int k = n - i - j;
            if(10000 * i + 5000 * j + 1000 * k == y ){
                if(k < 0){
                    x = -1 ; f = -1 ; z = -1 ;
                }else{
                x = i ;
                f = j ;
                z = k ;
                }               
            }
        }

    }

        cout << x << " " << f << " " << z << endl;
  
    return 0;

}

Measured memory_bytes: 256
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=200000+10;
const int mod=1e9+7;

inline int qpow(int a,int b) { int c=1;
    for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) c=1ll*c*a%mod;
    return c;
}

int fac[N],ifac[N];
inline void init(int n) {
    fac[0]=1;
    for (re int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=qpow(fac[n],mod-2);
    for (re int i=n;i;--i) ifac[i-1]=1ll*ifac[i]*i%mod;
}
inline int calc(int n,int m) {
    return 1ll*fac[n+m]*ifac[n]%mod*ifac[m]%mod;
}

int H,W,A,B;
int main() {
    init(200000);
    H=read(),W=read(),A=read(),B=read();
    int ans=0;
    for (re int x=H-A,y=B+1;x>=1&&y<=W;--x,++y)
        ans=(ans+1ll*calc(x-1,y-1)*calc(H-x,W-y))%mod;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<bool> vb;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sq(x) ((x)*(x))
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<"\n"
#define fi first
#define se second
const double pi = 3.14159265358979323846;
#define uni(c) (c).resize(unique(all(c))-(c).begin())
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//pair <int, int> w[4] = {mp(-1, 0), mp(0, -1), mp(1, 0), mp(0, 1)};   // for matrix movement:
void cp()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
void solve()
{
	ll n; cin >> n;
	string s; cin >> s;
	ll c = 0, cr = 0, cw = 0;
	for (char c : s)
		if (c == 'R')
			cr++;
		else
			cw++;
	for (int i = 0; i < cr; i++)
	{
		if (s[i] == 'W')
			c++;
	}
	cout << c;

}
int main()
{
	fast;
	//cp();
	ll t = 1;
	//cin >> t;
	while (t--)
		solve();


	return 0;
}

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


int main(){
  vector<int> a(5);
  int k;
  for(int i=0;i<5;++i)
    cin >> a.at(i);
  cin >> k;
  if(abs(a.at(0)-a.at(4))>k)
    cout << ":(";
  else
    cout << "Yay!";
}


Measured memory_bytes: 256
#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> P;

int main() {
    int N; cin >> N;
    vector<int> a(N);
    ll sunuke = 0;
    ll arai = 0;
    ll total = 0;
    rep(i, N){
        cin >> a[i];
        total += a[i];
    }

    sunuke = a[0];
    arai = total - a[0];
    ll ans = abs(sunuke - arai);

    for (int i = 1; i < N-1; i++){
        sunuke += a[i];
        arai -= a[i];
        ll now = abs(sunuke - arai);
        ans = min(ans, now);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  string t;
  cin>>t;
  bool res=true;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i])
      res=false;
  }
  if(res)
  cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

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

int main(void) {
  int n;
  cin>>n;
  long long t[100];

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

 sort(t, t+n);
 for(int i=0; i<n-1; i++) {
    long long x=t[i];
    long long y=t[i+1];
    while(x!=0) {
      long long tmp=y;
      y=x;
      x=tmp%x;
    }
    t[i+1]=(t[i+1]/y)*t[i];
  }
  cout<<t[n-1]<<endl;
  return 0;
}


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

int main(){
    long long int a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if(v > w && (v-w) * t >= abs(a-b)) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		Console.WriteLine("{0}",s[0]<10&&s[1]<10?s[0]*s[1]:-1);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13140
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;

int main()
{
	int n;
	double b;
	cin>>n;
	int *a = new int[n];
	int *B = new int[n];
	rep(i,n){
		cin>> a[i];
		B[i] = a[i] - (i+1);
	}
	sort(B,B+n);
	//rep(i,n)cout<<B[i]<<" ";
	//cout<<endl;
	if( n % 2 == 0){
		b = ( B[n/2] + B[(n/2)-1])/2;
	}else{
		b = B[ (n-1)/2];
	}
	//cout<<b<<endl;
	int b1,b2;
	b1 = ceil(b);
	b2 = floor(b);
	ll sum1 = 0,sum2 = 0;
	for(int i = 0; i < n; i++){
		sum1 += abs( a[i] - (i+1+b1));
		sum2 += abs( a[i] - (i+1+b2));
	}
	cout<<min(sum1,sum2)<<endl;
	//cout<<"sum1:"<< sum1<<" sum2:"<<sum2<<endl;
	return 0;
}



Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 10;
const int mod = 1e9 + 7;

inline int madd( int x, int y ){
	return (x + y) % mod;
}

inline int mult( int x, int y ){
	return int( (ll(x) * ll(y)) % ll(mod) );
}

inline int sub( int x, int y ){
	return madd( x, mod - y );
}

int fpot( int x, int y ){
	if ( !y ) return 1;
	if ( y & 1 ) return mult(x, fpot(x, y ^ 1));
	int h = fpot(x, y >> 1);
	return mult(h, h);
}

int div( int x, int y ){
	return mult( x, fpot(y, mod - 2));
}

int n, a[MAXN];
vector<int> v[MAXN];
int lo, hi, in, out, f[MAXN], sol, l , r;

int povrh( int X, int Y ){
	if ( X < Y ) return 0;
	return mult( f[X], fpot( mult(f[Y], f[X-Y]), mod - 2 ) );
}

int main(){
	scanf("%d", &n);
	f[0] = 1;
	for ( int i = 1; i <= n; i++ )
		f[i] = mult( f[i-1], i );
	for ( int i = 0; i <= n; i++ ){
		scanf("%d", a + i);
		v[--a[i]].push_back(i);
	}
	for (int i = 0; i < n; i++ )
		if ( int(v[i].size()) == 2 ){
			lo = v[i][0];
			hi = v[i][1];
		}
	in = hi - lo - 1;
	out = n - in - 1;
	l = lo;
	r = n - hi;
	
	for ( int k = 1; k <= n + 1; k++ ){
		
		sol = 0;
		
		// NONE OF DOUBLES
		sol = madd( sol, povrh( in + out, k ) );
		//printf("%d\n", sol);
		
		// ONE OF DOUBLES
		sol = madd( sol, sub( mult( povrh(in + out, k - 1), 2 ), povrh(out, k - 1) ) );
		//printf("%d\n", sol);
		
		// BOTH OF DOUBLES
		if ( k > 1 )
			sol = madd( sol, povrh(in + out, k - 2) );
		
		printf("%d\n", sol);
		
	}
	
	return 0;
}


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

int main() {
    int N;
    int tmp;
    int cnt = 0;
    cin >> N;
    int a[105];
    for(int i = 0; i < N ; i++) cin >> a[i];

    sort(a, a + N, greater<int>()); // 大きい順
    
    for(int i = 0; i < N ; i++) {
        if(i != N-1 && a[i] != a[i+1]) ++cnt;
    }
    cout << ++cnt << endl;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,M = I()
a = [l() for _ in range(N)]
b = [l() for _ in range(M)]
for i in range(N):
    num1 = INF
    num2 = 0
    for j in range(M):
        if abs(b[j][0]-a[i][0])+abs(b[j][1]-a[i][1]) < num1:
            num1 = abs(b[j][0]-a[i][0])+abs(b[j][1]-a[i][1])
            num2 = j+1
    print(num2)

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

using namespace std;
const int maxn=100005;
const int mod=1e9+7;

int n,k,a[maxn],dp[105][maxn];

int main()
{
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int i=0;i<=n;i++) dp[i][0]=1;
	for(int i=0;i<n;i++){
		for(int j=1;j<=k;j++){
			if(j-1-a[i]>=0) dp[i+1][j]=((dp[i+1][j-1]+dp[i][j]-dp[i][j-1-a[i]])%mod+mod)%mod;
			else dp[i+1][j]=(dp[i+1][j-1]+dp[i][j])%mod;
		}
	}
	printf("%d\n",dp[n][k]);
}

Measured memory_bytes: 40960
n, d = gets.split.map(&:to_i)
x = readlines.map {|l| l.split.map(&:to_i) }
c = 0
m = []

x.each_with_index do |y, i|
  break if i == (x.length - 1)
  m [i] ||= []
  n.times do |j|
    m[j] ||= []
    next if m[i][j] == 1 || m[j][i] == 1
    next if i == j
    z = y.zip(x[j])
    p = Math.sqrt(z.inject(0) {|r,e| r += (e.first - e.last).abs ** 2; r })
    c += 1 if Math.sqrt(z.inject(0) {|r,i| r += (i.first - i.last).abs ** 2; r }).to_s.match(/\.0$/)
    m[i][j] = 1
    m[j][i] = 1
  end
end

puts c

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <sstream>
#include <functional>
#include <algorithm>
using namespace std;

#define mem(a,n) memset(a,n,sizeof(a))
#define memc(a,b) memcpy(a,b,sizeof(b))
#define rep(i,a,n) for(int i=a;i<n;i++) ///[a,n)
#define dec(i,n,a) for(int i=n;i>=a;i--)///[n,a]
#define pb push_back
#define fi first
#define se second
#define IO ios::sync_with_stdio(false)
#define fre freopen("in.txt","r",stdin)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double e = 2.718281828459045;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int MOD = 258280327;
const int N = 1e3 + 5;
const ll maxn = 5e4;
const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };
int n, m;
bool vis[N];
int match[N];
bool a[N][N];
int dfs(int x)
{
	for (int y = 1; y <= n; y++)
	{
		if (!vis[y] && a[x][y])
		{
			vis[y] = 1;
			if (match[y] < 0 || dfs(match[y]))
			{
				match[y] = x;
				return true;
			}
		}
	}
	return false;
}

	int solve()
	{
		int ans = 0;
		memset(match, -1, sizeof(match));
		for (int i = 1; i <= n; i++)
		{
			mem(vis, 0);
			if (dfs(i))ans++;
		}
		return ans;
	}

int main()
{
	IO;

	cin >> n;
	int t1[n + 1];
	int t2[n + 1];
	int t3[n+1];
	int t4[n+1];
	for (int i = 1; i <= n; i++)
	{
		cin >> t1[i];
		cin >> t2[i];
	}
	for (int i = 1; i <= n; i++)
	{
		cin >> t3[i];
		cin >> t4[i];
	}

		memset(a, 0, sizeof(a));
		for (int i = 1; i <= n; i++)
            for(int j=1;j<=n;j++)
		{
			if(t1[i]<t3[j]&&t2[i]<t4[j])
				{
				    a[i][j] = 1;
			}
		}


	cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
  string S, T;
  cin >> S;
  cin >> T;

  map<char, char> StoT;
  map<char, char> TtoS;

  int length = S.length();

  bool ans = true;
  for (int i = 0; i < length; i++) {
    if (StoT.count(S[i]) == 0) {
      StoT[S[i]] = T[i];
    } else {
      if (StoT[S[i]] != T[i]) {
        ans = false;
      }
    }

    if (TtoS.count(T[i]) == 0) {
      TtoS[T[i]] = S[i];
    } else {
      if (TtoS[T[i]] != S[i]) {
        ans = false;
      }
    }
  }

  if (ans) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 776
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


int n, ans = 1;
int main() {
	cin >> n;
	for (int i = 2; i <= sqrt(n); ++i) {
		for (int j = pow(i, 2); j <= n; j *= i) { ans = max(ans, j); }
	}
	cout << ans << endl;
}

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

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

int n;

string rec(string s, int repeat) {
  repeat = min(repeat,1000000);
  int f = 0;                 // f : 0.ÈñÅàÈ¢ 1.ÊíÌ¶ñ 2. 3.Êà
  int start = 0;
  int re = 0;
  int nest = 0;
  string res;
  REP(i,s.size()) {
    if (f == 0) {
      if (isalpha(s[i])) {
        start = i;
        f = 1;
      } else if (isdigit(s[i])) {
        start = i;
        f = 2;
      }
    } else if (f == 1) {
      if (isdigit(s[i])) {
        res += s.substr(start, i-start);
        f = 2;
        start = i;
      }
    } else if (f == 2) {
      if (isalpha(s[i])) {
        re = atoi(s.substr(start, i-start).c_str());
        res += string(re,s[i]);
        f = 0;
      } else if (s[i] == '(') {
        re = atoi(s.substr(start, i-start).c_str());
        f = 3;
        start = i;
        nest = 1;
      }
    } else if (f == 3) {
      if (s[i] == '(') nest++;
      else if (s[i] == ')') nest--;
      if (nest == 0) {
        res += rec(s.substr(start+1, i-start-1), re);
        f = 0;
      }
    }
    if (res.size() > n) return res;
  }
  if (f == 1) {
    res += s.substr(start, s.size()-start);
  }
  string tmp = res;
  REP(i, repeat-1) {
    if (res.size() > n) return res;
    res += tmp;
  }
  return res;
}

int main() {
  string s;
  while(cin>>s>>n,s!="0"||n) {
    string res = rec(s,1);
    if (res.size() > n) {
      cout << res[n] << endl;
    }else
      cout << 0 << endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

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

    void solve(Scanner sc) {
        int oddCount = 0;
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (a % 2 == 1) {
                oddCount++;
            }
        }
        System.out.println(oddCount % 2 == 0 ? "YES" : "NO");
    }
}


Measured memory_bytes: 48276
#include<iostream>
	using namespace std;
	#define fo(i,n) for(int i=0;i<n;i++)
	#define pb push_back
	#define mp map<int,int>
	#define ump unordered_map<int,int>
	#define vi vector<int>
	#define M INT_MAX
	#define MI INT_MIN
	#define ll long long int
	#define pii pair<int,int>
	#define F first
	#define S second
	#define fall(i,a,b) for(int i=a;i<b;i++)
	#define pi 3.1415926535
	void solve()
	{
			int n,m;
			cin>>n>>m;
			fo(i,m)
			{
				int x;
				cin>>x;
				n-=x;
			}
			if(n<0)cout<<"-1"<<endl;
			else
			cout<<n<<endl;
	}
	int main()
	{
		solve();
	}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <cmath>

int main() {
  std::string str;
  std::cin >> str;
  int zero_num = 0;
  for (auto& ch : str) {
    if (ch == '0')
      ++zero_num;
  }
  std::cout << std::min(zero_num, (int)str.size() - zero_num) * 2 << std::endl;
  return 0;
}


Measured memory_bytes: 512
n=int(input())
xy=[]
for _ in range(n):
	x,y=map(int,input().split())
	xy.append([x,y])
ans=0
for i in range(n):
	for j in range(n):
		ans+=((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**0.5
print(ans/n)

Measured memory_bytes: 3188
n, m = map(int, input().strip().split())

num = [0]*n
nn = [-1]*n
WA = 0
AC = 0

for i in range(m):
  text = input().strip().split()
  p = int(text[0])
  s = text[1]
  
  if nn[p-1] == -1:
    if s == 'AC':
      AC += 1
      WA += num[p-1]
      nn[p-1] = 1
    elif s == 'WA':
      num[p-1] += 1
      
print(AC, WA)

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  int a;
  cin >> a;
  cout << a + a * a + a * a * a;

  return 0;
}


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

int main(){
  int u[210][3];
  int n,a[210][3],ans[210];

  cin >> n;
  for(int i=0;i<=100;i++)
    for(int j=0;j<3;j++)u[i][j] = 0;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++)cin >> a[i][j];
    ans[i] = 0;
  }

  for(int i=0;i<3;i++){
    for(int j=0;j<n;j++)u[a[j][i]][i]++;
    
    for(int j=0;j<n;j++)
      if(u[a[j][i]][i]==1)ans[j] += a[j][i];
  }

  for(int i=0;i<n;i++)cout << ans[i] << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
// Macros for easier access
#define ll long long
#define endl '\n'
#define F first
#define S second
#define umap unordered_map
#define uset unordered_set
#define test ll cases; cin>>cases; for(ll testCase = 1; testCase <= cases; testCase++)   //test cases
#define fill(name, val) memset(name, val, sizeof(name));
#define mop(a, op, b)    (a%mod op b%mod)%mod
#define error(x) fixed<<setprecision(x) //cout<<error(5)<<someDouble    -> example - 3.14159
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define get(a, n)    for(ll i = 0; i < n; i++)    cin>>a[i];
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug(x) cerr << #x << " : " << (x) << endl
// Constants
#define MX 100001
#define mod 1000000007LL
#define inf 1000000000000000000LL
void init(){
	boost;
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

/*	Author: 🆉🅴🅽🅾🅻🆄🆂	*/

int main(){
	init();
	ll a, b, n, x;	cin>>a>>b>>n;
	if(n >= b)	x = b-1;
	else	x = n;
	cout<<(a*x/b) - a*(x/b)<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353

using namespace std;

int main() {
	ll k;
	string s;
	cin >> k >> s;
	if (s.length() <= k) {
		cout << s << endl;
	}
	else {
		cout << s.substr(0, k) << "..." << endl;
	}

}

Measured memory_bytes: 3548
H,W=map(int,input().split())
S=[input() for _ in range(H)]
for i in range(H):
  T=''
  for j in range(W):
    if S[i][j] == '#':
      T+='#'
    else:
      T+=str(sum([x[max(0,j-1):min(j+2,W)].count('#') for x in S[max(0,i-1):min(i+2,H)]]))
    
  print(T)   


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 1e9

int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    int ans;
    if (a>=b&&a>=c){
        ans=b*c;
    }
    if (b>=a&&b>=c) ans=a*c;
    if (c>=a&&c>=b) ans=a*b;

    cout<<ans/2<<endl;


        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    ll q;
    cin >> q;
    vector<ll>b(q);
    for(ll i=0;i<q;i++){
        cin >> b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ll ans=0;
    for(ll i=0;i<q;i++){
        for(ll j=0;j<n;j++){
            if(b[i]==a[j]){
                ans++;
                break;
            }
            if(b[i]<a[j]){
                break;
            }
        }
    }
    cout << ans << endl;
}


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

int main(){
	int n;cin>>n;
	long long int v_ans=0,ans=0;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		v_ans=0;
		while(a[i]%2==0){
			a[i]=a[i]/2;
			v_ans++;
			
		}
		ans+=v_ans;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable mod = 10^^9 + 7;
immutable inf = 10^^9 + 7;

void main() {
    int q, h, s, d;
    int n;

    scan(q, h, s, d);
    scan(n);

    auto a = new int[](3);
    a[0] = 4 * q;
    a[1] = 2 * h;
    a[2] = s;

    a.sort();

    long ans;

    if (a[0] * 2 < d) {
        ans = 1L * a[0] * n;
    }
    else {
        if (n & 1) {
            ans = a[0] + 1L * d * (n / 2);
        }
        else {
            ans = 1L * d * (n / 2);
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
} 

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

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <typename X> inline X abs(const X &a) {return a < 0 ? -a : a;}
template <typename X> inline X sqr(const X &a) {return a * a;}

const int INF = int(1e9) + 300;
const li INF64 = li(1e18);
const ld EPS = 1e-9;
const ld PI = acosl(ld(-1));

mt19937 mt(time(NULL));

const int N = 100 * 1000 + 13;
int n;
int a[N], b[N];

inline bool read() {
	if (scanf ("%d", &n) != 1)
		return false;
		
	forn (i, n)
		assert(scanf ("%d", &a[i]) == 1);
	forn (i, n)
		assert(scanf ("%d", &b[i]) == 1);		

	return true;
}

int res[N];
int maxVal[N];

const int MOD = 1000 * 1000 * 1000 + 7;

inline void solve() {
	memset(res, -1, sizeof res);

	forn (i, n)
	{
		if (i == 0 || a[i] != a[i - 1])
		{
			res[i] = a[i];
			maxVal[i] = INF;
		}
		else
			maxVal[i] = a[i];	
	}
	
	ford (i, n)
	{
		if (i == n - 1 || b[i] != b[i + 1])
		{
			if ((res[i] != -1 && res[i] != b[i]) || b[i] > maxVal[i])
			{
				//cerr << i << ' ' << res[i] << ' ' << b[i] << ' ' << maxVal[i] << endl;
				puts("0");
				return;
			}
			
			res[i] = b[i];
		}
		else
		{
			maxVal[i] = min(maxVal[i], b[i]);
		}
	}
	
	int ans = 1;
	forn (i, n)
		if (res[i] == -1)
			ans = int(ans * 1ll * maxVal[i] % MOD);
			
	cout << ans << endl;
}

int main() {
#ifdef SU2_PROJ
	assert(freopen("input.txt", "r", stdin));
	assert(freopen("output.txt", "w", stdout));
#endif

	cout << setprecision(25) << fixed;
	cerr << setprecision(10) << fixed;
	
	assert(read());
	solve();

#ifdef SU2_PROJ
	cerr << "TIME: " << clock() << endl;
#endif
	return 0;
}

Measured memory_bytes: 1792