akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct data{
	int bit,v;
	double cost;
	data(){}
	data(int bb,int vv,double cc){
		bit=bb;
		v=vv;
		cost=cc;
	}
	bool operator<(const data &d)const{
		return d.cost<cost;
	}
};

int n,m;
P za[201][2];
P factory[15];
double dist[1<<15][15];
double dp[15][15];
double stf[201][2][15];

struct graph_scc{
	int V;
	vector<int> G[501];
	vector<int> rG[501];
	vector<int> vs;
	bool used[501];
	int cmp[501];
	void init(int n){
		V=n;
		for(int i=0;i<V;i++){
			G[i].clear();
			rG[i].clear();
		}
		vs.clear();
		memset(cmp,0,sizeof(cmp));
	}
	void add_edge(int from,int to){
		G[from].push_back(to);
		rG[to].push_back(from);
	}

	void dfs(int v){
		used[v]=true;
		for(int i=0;i<G[v].size();i++){
			if(!used[G[v][i]])dfs(G[v][i]);
		}
		vs.push_back(v);
	}
	void rdfs(int v,int k){
		used[v]=true;
		cmp[v]=k;
		for(int i=0;i<rG[v].size();i++){
			if(!used[rG[v][i]])rdfs(rG[v][i],k);
		}
	}

	int scc(){
		memset(used,0,sizeof(used));
		vs.clear();
		for(int v=0;v<V;v++){
			if(!used[v])dfs(v);
		}
		memset(used,0,sizeof(used));
		int k=0;
		for(int i=vs.size()-1;i>=0;i--){
			if(!used[vs[i]]){
				rdfs(vs[i],k++);
			}
		}
		return k;
	}
};

graph_scc sc;

bool C(double v){
	sc.init(n*2);
	for(int i=0;i<n;i++){
		for(int j=0;j<2;j++){
			for(int k=i+1;k<n;k++){
				for(int l=0;l<2;l++){
					bool flag=false;
					for(int a=0;a<m;a++){
						for(int b=0;b<m;b++){
							double diss=stf[i][j][a];
							diss+=stf[k][l][b];
							diss+=dp[a][b];
							if(diss<=v)flag=true;
						}
					}
					if(!flag){
						sc.add_edge(i+j*n,k+(1-l)*n);
						sc.add_edge(k+l*n,i+(1-j)*n);
					}
				}
			}
		}
	}
	int k=sc.scc();
	for(int i=0;i<n;i++){
		if(sc.cmp[i]==sc.cmp[i+n])return false;
	}
	return true;
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d%d%d%d",&za[i][0].first,&za[i][0].second,&za[i][1].first,&za[i][1].second);
	}
	for(int i=0;i<m;i++){
		scanf("%d%d",&factory[i].first,&factory[i].second);
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<(1<<m);j++){
			for(int k=0;k<15;k++){
				dist[j][k]=1e9;
			}
		}
		dist[(1<<i)][i]=0.0;
		priority_queue<data> que;
		que.push(data(1<<i,i,0.0));
		while(que.size()){
			data d=que.top();
			que.pop();
			if(dist[d.bit][d.v]<d.cost)continue;
			for(int j=0;j<m;j++){
				int valx=(factory[j].first-factory[d.v].first);
				int valy=(factory[j].second-factory[d.v].second);
				double ncost=sqrt(valx*valx+valy*valy)+d.cost;
				if(dist[d.bit|(1<<j)][j]>ncost){
					dist[d.bit|(1<<j)][j]=ncost;
					que.push(data(d.bit|(1<<j),j,ncost));
				}
			}
		}
		for(int j=0;j<m;j++){
			dp[i][j]=dist[(1<<m)-1][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<m;k++){
				int valx=(za[i][j].first-factory[k].first);
				int valy=(za[i][j].second-factory[k].second);
				stf[i][j][k]=sqrt(valx*valx+valy*valy);
			}
		}
	}
	double l=0.0,r=114514.0;
	for(int i=0;i<50;i++){
		double mid=(l+r)/2.0;
		if(C(mid))r=mid;
		else l=mid;
	}
	printf("%.9f\n",r);
	return 0;
}

Measured memory_bytes: 12944
/// 1行の文字を空白で分割してVec<T>にする。
fn read_split<T : std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

fn read_one<T : std::str::FromStr>() -> T {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().parse().ok().unwrap()
}

fn main() {
    let n : i32 = read_one();
    let mut h : Vec<i64> = read_split();
    h.reverse();
    if n == 1 {
        println!("Yes");
        return;
    }
    let mut ans = true;
    for i in 0..(n - 1) {
        let p = i as usize;
        if h[p] < h[p + 1] { h[p+1] -= 1 };
        if h[p] < h[p + 1] {
            ans = false;
            break;
        }
    }
    println!("{}", if ans {"Yes"} else {"No"});
}

Measured memory_bytes: 8444
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
		LinkedList<string> answer = new LinkedList<string>();
		foreach(var c in Console.ReadLine()){
		    answer.AddLast(c.ToString());
		}
		bool reverse = false;
		
		long Q = long.Parse(Console.ReadLine());
		for(var i = 0; i < Q; i++){
		    var input = Console.ReadLine().Split(' ');
		    switch(input[0]){
		        case "1":
		            reverse = !reverse;
		            continue;
		        case "2":
		            if(input[1] == "1" ^ reverse){
		                answer.AddFirst(input[2]);
		            }else{
		                answer.AddLast(input[2]);
		            }
		            break;
		        default :
		            break;
		    }
		}
		
		var ans = answer.ToArray();
		var sb = new StringBuilder();
		if(reverse) {
		    for(var i = ans.Length - 1; i >= 0; i--){
		        sb.Append(ans[i]);
		    }
		}else{
		    for(var i = 0; i < ans.Length; i++){
		        sb.Append(ans[i]);
		    }
		}
		Console.WriteLine(sb.ToString());
	}
}

Measured memory_bytes: 45340
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}

int main() {
  int n;
  cin>>n;
  int vec[n];
  ll a[n+2];
  for(int i=0;i<n+2;i++){
    a[i]=0;
  }
  for(int i=0;i<n;i++){
    cin>>vec[i];
    a[vec[i]]++;
  }
  ll ans=0;
  for(int i=0;i<n+2;i++){
    if(a[i]>=2){
      ans+=(a[i]*(a[i]-1))/2;
    }
  }
  //cout<<ans<<endl;
  for(int i=0;i<n;i++){
    if(a[vec[i]]==2){
      cout<<ans-1<<endl;
      continue;
    }
    if(a[vec[i]]>=2){
      cout<<ans-(a[vec[i]]-1)<<endl;
      continue;
    }
    else{
      cout<<ans<<endl;
    }
  }
}

Measured memory_bytes: 4864
from heapq import heappop,heappush

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

hq = []
for i,(ai,bi) in enumerate(zip(a,b)):
    if(bi > ai):
        heappush(hq,(bi*-1,i))
    elif(bi < ai):
        print(-1)
        exit()

ans = 0
while(hq):
    _,ind = heappop(hq)
    side = b[(ind-1)%n] + b[(ind+1)%n]
    if(b[ind] <= side):
        print(-1)
        exit()
    cand = b[ind]%side
    if( cand > a[ind]):
        ans += (b[ind] - cand)//side
        b[ind] = cand
        heappush(hq,(-1*cand,ind))
    else:
        if(cand == a[ind]%side):
            cand = a[ind]
            ans += (b[ind] - cand)//side
            b[ind] = cand
        else:
            print(-1)
            exit()

print(ans)

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

bool my_binary_search(const vector<int>& S, int T, int l, int r){
    if (l > r) return false;
    int pos = (l + r) / 2;
    if (T == S[pos]) return true;
    if (T > S[pos])  return my_binary_search(S, T, pos + 1, r);
    return my_binary_search(S, T, l, pos - 1);

}

int main(){
    int n;
    cin >> n;
    vector<int> S(n);
    for (auto& s : S) cin >> s;
    int q;
    cin >> q;
    int cnt = 0;
    for (int i = 0; i < q; i++) {
        int T;
        cin >> T;
        if (my_binary_search(S, T, 0, n - 1)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3160
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);

// defines...
#define MP make_pair
#define PB push_back
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

int gcd(int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a*b/gcd(a, b));
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


int n, m, pop, ans=0;
bool used_row[7], used_col[7];
string s[6];
void backtrack(int k, int x, bool f)
{
	//cout << k << ' ' << x << ' ' << f << ' ' << ans << "\n";
	
	if(k==m+1 && f){
		int mid = 0;
		
		//for(int K=1; K<=n; K++) cout << used_row[K] << ' ';
		//cout << "\n";
		//for(int K=1; K<=m; K++) cout << used_col[K] << ' ';
		//cout << "\n";
		
		for(int K=0; K<n; K++){
			if(used_row[K+1]) continue;
			
			for(int L=0; L<m; L++){
				if(used_col[L+1]) continue;
				
				if(s[K][L]=='#') mid++;
				//cout << "[" << K << "][" << L << "] ";
			}
		}
		
		if(mid==pop) ans++;
		//cout << ans << "\n";
		return;
	}
	
	if(k==n+1 && !f){
		k = 1;
		x = m;
		f = 1;
	}
	
	//for(int K=k; K<=x; K++){
		backtrack(k+1, x, f);
		
		
		if(!f) used_row[k] = 1;
		else used_col[k] = 1;
		
		backtrack(k+1, x, f);
		
		if(!f) used_row[k] = 0;
		else used_col[k] = 0;
	//}
}

void task()
{
    //code here...
    
    cin >> n >> m >> pop;
    
    for(int K=0; K<n; K++) cin >> s[K];
    
    memset(used_col, 0, sizeof used_col);
    memset(used_row, 0, sizeof used_row);
    
    backtrack(1, n, 0);
    
    cout << ans << "\n";
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    return 0;
}




Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	ll N;
  	cin >> N;

    ll ans = 0;
  	for(ll i=1;i<=N;i++){
      if( (i%5!=0) && (i%3!=0) ){
        ans+= i;
      }
    }

    cout << ans <<endl;

  	return 0;
}

Measured memory_bytes: 3640
n = int(input())
#a,b = input().split()
#a = list(int(i) for i in input().split())

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

s = factorization(n)
lis_num = len(s)
ans = 0
cout = 1

if n == 1:
	print(ans)
else:
	for i in range(lis_num):
		while s[i][1]-cout >=0:
			s[i][1]-=cout
			cout+=1
			ans+=1
		cout = 1
	print(ans)

Measured memory_bytes: 9508
#include <iostream>
#include <string>
#include <bitset>
  
class Baseball{
    u_int score, out_count;
    std::bitset<4> runners; 
public:
    Baseball() : score(), out_count(){} //initializer list
    ~Baseball() = default;
    void hit();
    void homerun();
    void out() {++out_count;}
    u_int get_score() {return score;}
    u_int get_out() {return out_count;}
};
 
void Baseball::hit(){
    runners <<= 1; //shift
	runners.set(0); //set runner
    if(runners.test(3)){
        ++score;
        runners.reset(3);
    }
}
 
void Baseball::homerun(){
    score += runners.count() + 1;
    runners.reset();
}
 
int main(){
    u_int inning;
    std::cin >> inning;
    for(u_int i = 0; i < inning; ++i){
        Baseball game;
        while(game.get_out() != 3){
            std::string event;
            std::cin >> event;
            if(event == "HIT"){
                game.hit();
            }
            else if(event == "HOMERUN"){
                game.homerun();
            }
            else if(event == "OUT"){
                game.out();
            }
        }
        std::cout << game.get_score() << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
    string s;
    cin >> s;
    ll n = s.size();
    map<char, bool> mp;
    for (ll i = 0; i < 26;i++){
        mp[i + 'a'] = false;
    }
        for (ll i = 0; i < n; i++) {
            mp[s.at(i)] = true;
        }
    for (auto i:mp){
        if(!i.second) {
            cout << i.first << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}


Measured memory_bytes: 512
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 3000005;
/**********************************************************************************************/

vector<int> p;
void pre() {
	p.clear(); p.resize(N, -1);
	p[0] = 0; p[1] = 1;
	for (int i = 2; i < N; i++) {
		if (p[i] == -1) {
			for (int j = i; j < N; j += i) p[j] = i;
		}
	}
}

void solve() {
	pre();
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int g = a[0];
	for (int i = 1; i < n; i++)
		g = __gcd(g, a[i]);
	if (g != 1) {
		cout << "not coprime\n";
		return;
	}
	unordered_set<int> vis;
	int one = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == 1) one++;
		else vis.insert(p[a[i]]);
	}
	if (vis.size() + one == n) cout << "pairwise coprime\n";
	else cout << "setwise coprime\n";
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

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

vector<vector<int>> edges;


int dfs(int edge,int N,vector<bool>visited){
    // cerr <<"target="<< edge << endl;
    bool allVisited = true;
    for(int i =0;i<N;i++){
        if(!visited[i]){
            // cerr << i <<"is not visited" << endl;
        allVisited = false;
        }
    }
    if(allVisited){
        // cerr << "all_visited!" << endl;
        return 1;
    }
    int ret =0;
    if(edges[edge].size()==0){
        // cerr << "no destination"  << endl;
        return 0;
    }
    for(int to: edges[edge]){
        if(visited[to]){
            // cerr << "to="<< to << "is already visited" << endl;
            continue;
        }
        visited[to] = true;
        ret += dfs(to,N,visited);
        visited[to] = false;
    }
    return ret;
    
    

}

int main(){
    int N,M;
    cin >> N >>M;
    edges.resize(N);

    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >>b;
        a--;b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    vector<bool> visited(N,false);
    visited[0] = true;
    cout << dfs(0,N,visited) << endl;
    

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,q=map(int,input().split())
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(input()) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
for time, query, number in event:
  if query == 0:
    heapq.heappush(hq,number)
    S.add(number)
  elif query == -1:
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heapq.heappop(hq)
    if not hq:
      print(-1)
    else:
      print(hq[0])




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

int n,a[10005][10005],now[10005],ans=0,tmp[10005],ok;

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

int main(void){
	n=read();
	for(int i=1;i<=n;i++){
		now[i]=1;
		tmp[i]=-1;
		for(int j=1;j<n;j++)
		a[i][j]=read();
	}
	ok=n*(n-1)/2;
	while(1){
		bool check=0;
		int p=0;
		for(int i=1;i<=n;i++){
			int u=a[i][now[i]];
			if(tmp[u]==ans||tmp[i]==ans)continue;
			if(a[u][now[u]]!=i)continue;
			check=1;
			tmp[i]=ans;
			tmp[u]=ans;
			now[u]++;
			now[i]++;
			p+=2;
			ok--;
			if(n-p<2)break;
		}
		ans++;
		if(ok==0)break;
		if(check==0&&ok!=0){
			printf("-1\n");
			return 0;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 39424
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007
#define inf 1000000000000000000ll
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x,ll y, ll md=inf){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;


#define endl '\n'
#define int ll

signed main() {
	fast;

	int h,w;
	cin>>h>>w;

	pii v[200002];
	for(int i=0;i<h;i++) cin>>v[i].f>>v[i].s;

	map<int,int> mp;
	for(int i=1;i<=w;i++) mp[i] = 0;

	map<int,int> mini = {{0,w}};

	for(int i=0;i<h;i++) {
		int l = v[i].f;
		int r = v[i].s;

		auto it = mp.lower_bound(l);
		int mn = inf;

		while(it!=mp.end() && it->f <= r) {
			mn = min(mn, r+1-(it->f)+(it->s));
			auto it1 = it++;
			mini[it1->s]--;
			if(mini[it1->s]==0) mini.erase(it1->s);
			mp.erase(it1);
		}

		if(r+1<=w && mn<inf) {
			if(it!=mp.end() && it->f == r + 1) {
				if(it->s > mn) {
					mini[it->s]--;
					if(mini[it->s]==0) mini.erase(it->s);
					mini[mn]++;
					it->s = mn;
				}
			}
			else {
				mp.insert({r+1,mn});
				mini[mn]++;
			}
		}

		if(mini.size()) cout<<mini.begin()->f+i+1<<endl;
		else cout<<-1<<endl;

	}
}

Measured memory_bytes: 19240
n = gets.to_i
sts = []

(n-1).times do
  sts << gets.split(" ").map(&:to_i)
end

cost = sts[0][1]
(n-1).times do |i|
  cost += sts[i][0]
  ((i+1)...(n-1)).each do |j|
    if cost <= sts[j][1]
      cost = sts[j][1]
    else
      short = cost - sts[j][1]
      if short % sts[j][2] == 0
        cost = sts[j][1] + (short / sts[j][2]) * sts[j][2]
      else
        cost = sts[j][1] + ((short / sts[j][2]) + 1) * sts[j][2]
      end
    end
    cost += sts[j][0]
  end
  puts cost
  cost = sts[i+1] ? sts[i+1][1] : 0
end

puts 0

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main() {

	int x, a, b;
	cin >> x >> a >> b;

	if (a >= b)
	{
		cout << "delicious" << endl;
	}
	else if (a + x >= b)
	{
		cout << "safe" << endl;
	}
	else
	{
		cout << "dangerous" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
n, tt = map(int, input().split())

min_cost = 10000
for i in range(n):
    c, t = map(int, input().split())
    if t <= tt:
        min_cost = min(min_cost, c)

if min_cost < 10000:
    print(min_cost)
else:
    print('TLE')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;

int powMOD(int n,int r){
    if(r==0)return 1;
    if(r%2==0)return powMOD(n,r/2)*powMOD(n,r/2)%MOD;
    if(r%2==1)return powMOD(n,r-1)*n%MOD;
}

int modFAC(int x){
    if(x==1) return 1;
    return x*modFAC(x-1)%MOD;
}

int COM(int n,int r){
    int ret=1;
    REP(i,r){
        ret *= (n-i);
        ret %=MOD;
    }
    return ret*powMOD(modFAC(r),1e9+5)%MOD;
}

signed main(){
    int n,m;cin>>n>>m;
    int x[m];
    REP(i,m)cin>>x[i];
    sort(x,x+m);
    int dist[m-1];
    REP(i,m-1) dist[i]=x[i+1]-x[i];
    sort(dist,dist+m-1);
    int ans=0;
    REP(i,m-n)ans+=dist[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void)
{
    int a, b, ans = 0;
    cin >> a >> b;
    for (int i = 0; i < 2; i++)
    {
        if (a < b)
        {
            ans += b;
            b--;
        }
        else
        {
            ans += a;
            a--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  int count=0,max=0;
  for (int i=0;i<S.size();i++) {
    if (S.at(i)=='A' ||
        S.at(i)=='T' ||
        S.at(i)=='C' ||
        S.at(i)=='G') {
      count++;
      if (i==S.size()-1) {
        if (max<count) {
          max = count;
        }
      }
    }
    else {
      if (max<count) {
        max = count;
      }
      count=0;
    }
  }
  
  cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll combination (ll n, ll r) {
    if (n == r || r == 0) {
        return 1;
    } else if (r == 1) {
        return n;
    } else if (n < r || n <= 0) {
        return 0;
    } else {
        return combination(n - 1, r - 1) + combination(n - 1, r);
    }
}
int main (void) {
    int N;

    cin >> N;
    ll A[N];
    ll S[N + 1];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    S[0] = 0;
    for (int i = 0; i < N; i++) {
        S[i + 1] = S[i] + A[i];
    }

    sort(S, S + N + 1);
    ll ans = 0;
    ll n = S[0];
    ll cnt = 1;
    for (int i = 1; i < N + 1; i++) {
        if (i == N) {
            if (S[i] == n) {
                cnt++;
                ans += combination(cnt, 2);
            } else {
                ans += combination(cnt, 2);
            }
        } else {
            if (S[i] == n) {
                cnt++;
            } else {
                ans += combination(cnt, 2);
                n = S[i];
                cnt = 1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <math.h>
#include <iomanip>

using namespace std;

#define FOR(i,m,M) for(int i = m;i<M;i++)

int main()
{
	long double a, b, x;
	long double theta;
	cin >> a >> b >> x;
	double t = (2.0 / a) * (b - (x / (a * a)));
	if (t < b/a)
		theta = atan(t)*180.0/M_PI;
	else theta = atan((a*b*b/(2.0*x))) * (180.0 / M_PI);
	cout <<setprecision(12) <<theta;
}


Measured memory_bytes: 256
/*
СТРОИМ СТЕНУ РАБОТЯГИ!
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
int cnt[1007];
int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		int x = i;
		for (int j = 2; j <= i; j++)
		{
			while (x % j == 0)
			{
				cnt[j]++;
				x /= j;
			}
		}
	}
	ll res = 1;
	for (int i = 1; i < 1007; i++)
	{
		res = (res * (cnt[i] + 1)) % (1000 * 1000 * 1000 + 7);
	}
	printf("%lld\n", res);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string s;cin>>s;
    int a=1,z=s.size();
    REP(i,s.size()){
        if(s[i]=='A')break;
        a++;
    }
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='Z')break;
        z--;
    }
    cout<<z-a+1<<endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
	int n;
	short matrix[11][11];

	while(cin >> n, n)
	{
		for(int i=0; i < n; i++) matrix[n][i] = matrix[i][n] = 0;
		matrix[n][n] = 0;
		for(int y=0; y < n; y++) {
			for(int x=0; x < n; x++) {
				cin >> matrix[y][x];
				matrix[n][x] += matrix[y][x];
				matrix[y][n] += matrix[y][x];
				matrix[n][n] += matrix[y][x];
			}
		}
		int nn = n + 1;
		for(int y=0; y < nn; y++) {
			for(int x=0; x < nn; x++) {
					printf("%5d", matrix[y][x]);
			}
			printf("\n");
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;
typedef pair<int, string> P;


void solve()
{
	int n;
	while (cin >> n, n)
	{
		cin.ignore();
		string str;
		map<string, int> Map;
		while (n--)
		{
			getline(cin, str);
			str += " ";
			string s;
			for (int i = 0; i < str.size(); ++i)
			{
				if (str[i] == ' ')
				{
					Map[s]++;
					s.clear();
				}
				else
				{
					s += str[i];
				}
			}
		}
		char c;
		cin >> c;
		vector<P> word;
		map<string, int>::iterator it = Map.begin();
		while (it != Map.end())
		{
			if (it->first[0] == c)
			{
				word.push_back(P(-it->second, it->first));
			}
			++it;
		}
		if (word.empty())
		{
			cout << "NA" << endl;
			continue;
		}
		sort(word.begin(), word.end());
		int displaySize = min((int)word.size(), 5);
		bool isFirst = true;
		for (int i = 0; i < displaySize; ++i)
		{
			if (!isFirst)
			{
				cout << " ";
			}
			isFirst = false;
			cout << word[i].second;
		}
		cout << endl;
	}
}

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

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

amari = 0
defeat = 0
for i in range(n):
    a_ = a[i]
    b_ = b[i]
    d1 = min(a_, amari)
    d2 = min(a_-d1, b_)
    defeat += (d1 + d2)
    amari = max(b_-d2, 0)

defeat += min(amari, a[-1])
print(defeat)


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(string S){
    int a = (S[0]-'0')*10 + S[1]-'0';
    int b = (S[2]-'0')*10 + S[3]-'0';
    if(1 <= a && a <= 12 && 1 <= b && b <= 12) cout << "AMBIGUOUS" << endl;
    else if(1 <= a && a <= 12) cout << "MMYY" << endl;
    else if(1 <= b && b <= 12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
}

int main(){
    string S;
    cin >> S;
    solve(S);
    return 0;
}


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

int main(){
    int n,m,a,b;
    cin>>n>>m;
    vector<int> v(n);
    map<int,vector<int> > m1;
    for(int i=0;i<n;i++) cin>>v[i];
    for(int i=0;i<m;i++){
        cin>>a>>b;
        m1[a].push_back(b);
        m1[b].push_back(a);
    }
    int ans=n-m1.size();
    for(auto x:m1){
        int flag=1;
        int aa=x.first;
        vector<int> v1=x.second;
        for(auto y:v1) if(v[y-1]>=v[aa-1]) flag=0;
        if(flag) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13260
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define ra read_alpha()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline char read_alpha() { char c = ge; while(!isalpha(c) && c != EOF) c = ge; return c; }
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

const int MAXN = 10010;

inline ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }

int tot;
int pri[MAXN];
int chk[MAXN];
ll a[510][510];

inline void Sieve(int n) {
	for(int i = 2; i <= n; i++) {
		if(!chk[i]) pri[++tot] = i;
		for(int j = 1; j <= tot; j++) {
			if(i * pri[j] > n) break;
			chk[i * pri[j]] = 1;
			if(i % pri[j] == 0) break;
		}
	}
}

unordered_map<int, int>id1, id2, vis;

int main() {
#ifdef LOCAL
	FILE("");
#endif
	Sieve(10000);
	int n = ri, N = 0, t = n - (n & 1); ++n;
	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= n; j++)
			a[i][j] = 1;
	for(int i = 1; i <= t; i++) id1[i << 1 | 1] = ++N;
	for(int i = 1; i <= t; i++) id2[t + 1 - i * 2] = ++N;
	for(int i = 1; i < n; i++)
		for(int j = 1; j < n; j++)
			if((i + j) & 1)
				a[i][j] = pri[id1[i + j]] * pri[id2[i - j]];
	for(int i = 1; i < n; i++) {
		for(int j = 1; j < n; j++)
			if((i + j) & 1) printf("%lld ", a[i][j]);
			else {
				ll x = lcm(lcm(a[i + 1][j], a[i - 1][j]), lcm(a[i][j + 1], a[i][j - 1])), y = x + 1;
				while(vis[y]) y += x; vis[y] = 1;
				printf("%lld ", y);
			}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 10148
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<map>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int x,y;
	cin>>x>>y;
	int s;
	s=x*y-x-y+1;
	cout<<s<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int a,b,c;

int main() {
  INCANT;
  cin >> a >> b >> c;
  string ans = a+b==c || a+c==b || b+c==a?"Yes":"No";
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
import math
nums = list(map(int, input().split()))

cell = nums[0] * nums[1]

if nums[0] == 1 or nums[1] == 1:
  print(1)
elif cell % 2 == 0:
  print(int(cell / 2))
else:
  print(int(math.ceil(cell / 2)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
ll n, arr[maxn], b[maxn];

int main() {
    cin>>n;
    ll minv = LLONG_MAX;
    ll sums = 0LL;
    for(int i=1;i<=n;i++) {
        cin>>arr[i];
        b[i] = arr[i];
        if(arr[i] < 0) b[i] *= (-1LL);
        sums += b[i];

        minv = min(minv, b[i]);
    }

    ll sum = 0LL;
    for(int i=1;i<n;i++) {
        if(arr[i] < 0) {
            arr[i] *= (-1LL);
            arr[i+1] *= (-1LL);
        }
        sum += arr[i];
    }

    if(arr[n] >= 0) {
        sum += arr[n];
        cout<<sum<<"\n";
    }
    else {
        cout<<sums-2*minv<<"\n";
    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	char c;
	cin>>a>>c>>b; 
	if(c == '+') cout<<a+b;
	else if(c == '-') cout<<a-b;
	else if(c == '*') cout<<a*b;
	else if(c == '/') cout<<a/b;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/******* MY EVERY AC WILL BE A TRIBUTE TO SSR ********/
#define vi vector
#define lli long long int
#define vli vi<lli>
#define pb push_back
#define pll pair<lli,lli>
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).begin(),(x).end(),greater<lli>()
#define clear(x) x.clear()
#define rep(i,n) for(lli i=0;i<(lli)n;i++)
#define rep1(i,n) for(lli i=1;i<=(lli)n;i++)
#define rep2(i,n) for(lli i=1;i<(lli)n;i++)
#define refor(i,n) for(lli i=(lli)n;i>=0;i--)
#define range(i,l,r) for(lli i=(lli)l;i<=(lli)r;i++)
#define big(x,y) (x>y)?x:y
#define small(x,y) (x<y)?x:y
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
using namespace std;
lli gcd(lli a,lli b) {return b==0?a:gcd(b,a%b);}
lli lcm(lli a,lli b) {return (a*b)/gcd(a,b);}
bool isprime(lli x) {for(lli i=2;i<=sqrt(x);i++) { if(x%i == 0) return false;} return true;}
lli modpow(lli x,lli y) {x%=mod;lli res=1;while(y>0){if(y&1) res*=x%mod; y=y>>1; x=x*x%mod;} return res%mod;}
lli ncr(lli n,lli k) {lli res=1; if(k>n-k) k=n-k; rep(i,k){res*=(n-i);res/=(i + 1);} return res;}
lli bintodec(lli n) {lli decimal=0,i=0,rem;while (n!=0){rem = n%10;n/=10;decimal += rem*pow(2,i);++i;}return decimal;}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    double n,d;
    cin>>n>>d;
    lli c=0;
    while(n--)
    { 
	  double x,y;
      cin>>x>>y;
      double xx=x*x;
      double yy=y*y;
      double res=xx+yy;
      if(sqrt(res)<=d)
        c++;
    
       
    	
	}
	cout<<c<<'\n';    

    return 0;
}











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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  map<int, ll> m;
  for (int v : a) m[v]++;
  ll base = 0ll;
  for (auto p : m) { base += p.second * (p.second - 1) / 2ll; }
  vector<ll> ans;
  for (int i = 0; i < n; i++) { cout << base - (m[a[i]] - 1) << endl; }
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 10368
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[A + 1];
		int[] b = new int[B + 1];

		int minA = 1000000;
		int minB = 1000000;

		for (int i = 1; i <= A; i++) {
			a[i] = sc.nextInt();
			minA = minA < a[i] ? minA : a[i];
		}
		for (int i = 1; i <= B; i++) {
			b[i] = sc.nextInt();
			minB = minB < b[i] ? minB : b[i];
		}

		int min = minA + minB;

		for (int i = 1; i <= M; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int c = sc.nextInt();
			int p = a[x] + b[y] - c;
			min = min < p ? min : p;
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 134268
program test
implicit none
integer::i,N
real(8)::ans
real(8),allocatable::a(:)
ans=0
read*,N
allocate(a(N))
read(*,*)(a(i),i=1,N)
    	do i=1,N
        	ans=ans+1.0/a(i)
        end do
ans=1.0/ans
print*,ans
end program test

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
ll INF=1000000007;

int main(){
    int n;
    cin >> n;
    ll f[n][10];
    rep(i,n){
        rep(j,10) cin >> f[i][j];
    }
    ll p[n][10];
    rep(i,n){
        rep(j,11) cin >> p[i][j];
    }
    ll ans=-(1<<30);
    for(int bit=1;bit<(1<<10);bit++){
        ll cur=0;
        rep(i,n){
            ll num=0;
            rep(j,10){
                if(f[i][j] && (bit>>j)&1) num++;
            }
            cur+=p[i][num];
        }
        ans = max(ans,cur);
    }
    cout << ans << endl;
}

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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 3e3 + 100;
const int maxN = 1e16;
const int oo = 1e18;
const int mod  = 998244353;
const int base = 26;
const double PI = 3.14159265358979323846;


signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("spm.out", "w", stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, m; cin >> n >> m;
    int sum = 0;
    FOR(i, 1, m) { int x; cin >> x; sum += x; }
    if(sum > n) { return cout << "-1", 0;}
    cout << n - sum;
}


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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;



void one_case() {
    int n;
    cin >> n;
    set<char> a;
    while (n--) {
        char c;
        cin >> c;
        a.insert(c);
    }
    cout << (a.size() == 3 ? "Three\n" : "Four");

}


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


    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, A, B; cin >> N >> A >> B;
	string s; cin >> s;
	int cnt = 0, b = 0;
	rep(i, 0, s.size()) {
		if (s[i] == 'a') {
			if (cnt < A + B) {
				puts("Yes");
				++cnt;
			}
			else puts("No");
		}
		else if (s[i] == 'b') {
			++b;
			if (cnt < A + B && b <= B) {
				puts("Yes");
				++cnt;
			}
			else puts("No");
		}
		else puts("No");
	}

	return 0;
}

Measured memory_bytes: 848
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	int n, r, ans;
	cin >> n >> r;
	ans = n < 10 ? r + 100 * (10 - n) : r;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input().strip())

numbers = [int(i) for i in input().strip().split(" ")]

if len(numbers) != N:
    print("invalid input data")
    exit

count = 0

def is_all_even(arr):

    for i in arr:

        if i % 2 == 1:
            return False
    
    return True

while(is_all_even(numbers)):

    numbers = [ i // 2 for i in numbers]
    count += 1

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000000000000000
#define mod 1000000007
#define rep(a,b,c) for(ll c=a;c<b;c++)
#define omarshagar                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);// freopen("output.txt","w",stdout);freopen("input.txt","r",stdin);
using namespace std;	
	
	ll gcd(ll a,ll b)
	{
		if(b==0)return a;
		return gcd(b,a%b);
	}
	
int main()
{
	omarshagar
	int n;
	cin>>n;
	int arr[n][3];
	for(int i=0;i<n;i++)
	{
		for(int ii=0;ii<3;ii++)
		{
			cin>>arr[i][ii];
		}
	}
	ll dp[n][3];
	memset(dp,-1,sizeof dp);
	dp[n-1][0]=arr[n-1][0];
	dp[n-1][1]=arr[n-1][1];
	dp[n-1][2]=arr[n-1][2];
	for(int i=n-2;i>=0;i--)
	{
		for(int ii=0;ii<3;ii++)
		{
			for(int iii=0;iii<3;iii++)
			{
				if(ii==iii)continue;
				dp[i][ii]=max(dp[i][ii],dp[i+1][iii]+arr[i][ii]);
			}
		}
	}
	cout<<max(dp[0][0],max(dp[0][1],dp[0][2]));
	return 0;
}

Measured memory_bytes: 3840
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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; }


int counter(int x){
    if(x==0) return 0;
    return counter(x >> 1) + (x & 1);
}


void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    ll minsum = INF;
    ll a = 0;
    ll b = 0;
    for (int i = 1; i <= pow(n,0.5)+1; i++) {
        if(n%i==0) minsum = min(minsum,n/i+i);
    }
        
    cout << minsum - 2 << endl;
    
 
}



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



Measured memory_bytes: 256
// luogu-judger-enable-o2
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 105;
char s[maxn];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin >> s + 1;
	int i = 0;
	while (s[++i]) if (s[i] == 'C')break;
	if (!s[i]) { printf("No\n"); return 0; }
	while (s[++i]) if (s[i] == 'F')break;
	if (!s[i]) { printf("No\n"); return 0; }
	printf("Yes\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int Mo=998244353;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar();}
	while(c>='0'&&c<='9') {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	if(f) x=-x;
	return x;
}
inline void write(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}
char s1[200],s2[200];
char s3[401];
int main()
{
	int cnt=0;
	int n=read();
	cin>>s1>>s2;
	for(int i=0;i<n;i++)
	s3[++cnt]=s1[i],s3[++cnt]=s2[i];
	for(int i=1;i<=cnt;i++)
	cout<<s3[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256