akhauriyash/Code-Regression huggingface dataset:
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;

struct BipartiteMatching
{
    vector<vector<int>> graph;
    vector<int> match, alive, used;
    int timestamp;

    BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {}

    void add_edge(int u, int v)
    {
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    bool dfs(int idx)
    {
        used[idx] = timestamp;
        for (auto &to : graph[idx])
        {
            int to_match = match[to];
            if (alive[to] == 0)
                continue;
            if (to_match == -1 || (used[to_match] != timestamp && dfs(to_match)))
            {
                match[idx] = to;
                match[to] = idx;
                return true;
            }
        }
        return false;
    }

    int bipartite_matching()
    {
        int ret = 0;
        for (int i = 0; i < graph.size(); i++)
        {
            if (alive[i] == 0)
                continue;
            if (match[i] == -1)
            {
                ++timestamp;
                ret += dfs(i);
            }
        }
        return ret;
    }

    void output()
    {
        for (int i = 0; i < graph.size(); i++)
        {
            if (i < match[i])
            {
                cout << i << "-" << match[i] << endl;
            }
        }
    }
};

//BipartiteMatching(n)　頂点n個
//add_edge(s,t)
//bipartite_matching()最大マッチング数
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    VP vec1(n);
    VP vec2(n);
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        vec1[i] = {a, b};
    }
    rep(i, n)
    {
        ll a, b;
        cin >> a >> b;
        vec2[i] = {a, b};
    }
    BipartiteMatching g(n + n);
    rep(i,n){
        rep(j,n){
            if (vec2[j].F > vec1[i].F && vec2[j].S > vec1[i].S){
                g.add_edge(i, j + n);
            }
        }
    }
    cout << g.bipartite_matching() << endl;
}


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

int main() {
    ll N;
    cin >> N;
    int ans = 0;
    rep(i,N){
      ll a = 0;
      cin >> a;
      while(a%2 == 0){
        a/=2;
        ans++;
      }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let c = (0..n).filter(|&i| i % 2 == 0 && a[i] % 2 == 1).count();
    puts!("{}\n", c);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int k;
	string S;
	cin >> k >> S;

	if ((int)S.size() > k)
		cout << S.substr(0, k) + "..." << endl;
	else
		cout << S << endl;
}



Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[]ss = S.toCharArray();
    String A = sc.next();
    char[]a = A.toCharArray();
 
    if(ss[0] == a[0]){
        System.out.println("H");    
     }else{
        System.out.println("D");
}
}
}


Measured memory_bytes: 35648
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int M = sc.nextInt();
        int D = sc.nextInt();
        int count = 0;
        int d1=0;
        int d10=0;
            
            for(int i=4; i<=M; i++){
                for(int j =22; j<=D; j++){
                    d1 = j%10;
                    d10 = j/10;
                    if(d1>=2 && d10 >=2 && d1*d10 == i){
                        count++;
                    }
                }
            }
            
            System.out.println(count);
    } 
}


Measured memory_bytes: 35820
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int n = sc.nextInt();
        String s = "No";

        for (int i = 1; i<=9; i++){
            for (int j = 1; j<=9; j++){
                if (i*j == n){
                    s = "Yes";
                    break;
                }
            }
        }
        System.out.println(s);
    }
}

Measured memory_bytes: 35784
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

#define int ll

bool has[100];

signed main() {
    #ifdef LOCAL
    assert(freopen("c.in", "r", stdin));
    #else
    #endif
    int n;
    cin >> n;
    int x = 0;
    forn (i, n) {
        int a;
        cin >> a;
        x ^= a;
        int k = 1;
        while (a % 2 == 0)
            a >>= 1, ++k;
        has[k] = true;
    }
    int res = 0;
    for (int i = 33; i >= 0; --i) {
        if (x & (1ll << i)) {
            if (!has[i + 1]) {
                cout << -1 << '\n';
                return 0;
            }
            ++res;
            x ^= (1ll << (i + 1)) - 1;
        }
    }
    assert(x == 0);
    cout << res << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define int long long
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main() {
  int x,a=100,c=0;
  cin >> x;
  while(a<x){
    a+=a/100;
    c++;
  }
  cout << c;
}

Measured memory_bytes: 3556
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 100010
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int tmp[N],n,k;
void per(int *a,int *p)
{
	for(int i=1;i<=n;i++)	tmp[i]=a[p[i]];
	for(int i=1;i<=n;i++)	a[i]=tmp[i];
}
int p[N],q[N],bs[6][N],a[N],g[N],b[N],ip[N],iq[N],ig[N],ans[N];
int main()
{
	n=read(),k=read()-1;
	for(int i=1;i<=n;i++)	bs[0][i]=p[i]=read(),ip[p[i]]=i;
	for(int i=1;i<=n;i++)	bs[1][i]=q[i]=read(),iq[q[i]]=i;
	for(int k=2;k<6;k++)
		for(int i=1;i<=n;i++)	bs[k][bs[k-2][i]]=bs[k-1][i];
	int mi=k/6;
	for(int i=1;i<=n;i++)	g[i]=i,b[i]=i;
	per(b,q); per(b,ip); per(b,iq); per(b,p);
	while(mi)
	{
		if(mi&1)	per(g,b);
		per(b,b); mi>>=1;
	}
	for(int i=1;i<=n;i++)	ig[g[i]]=i;
	for(int i=1;i<=n;i++)	ans[i]=i;
	per(ans,g); per(ans,bs[k%6]); per(ans,ig);
	for(int i=1;i<=n;i++)	printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
const int INF = 100100100;
int used[1000];
int deg[1000];

int dfs(int i, vector<vector<pair<int, int> > > &adj){

    int res = 0;
    int n = (int)adj.size();
    //cout << i << endl;
    for(int j = 0; j < adj[i].size(); j++){
        if(deg[adj[i][j].second] != 1 && used[adj[i][j].second] == false){
            used[adj[i][j].second] = true;
            res = max(res, dfs(adj[i][j].second, adj) + adj[i][j].first);
            used[adj[i][j].second] = false;
        }
    }

    //cout << res << endl;

    return res;
}

int main(){

    while(1){
        int n; cin >> n;
        if(!n) break;
        vector<vector<pair<int, int> > > adj(n);
        memset(deg, 0, sizeof(deg));
        vector<int> p(n - 1);
        vector<int> d(n - 1);
        for(int i = 0; i < n - 1; i++) cin >> p[i];
        for(int i = 0; i < n - 1; i++) cin >> d[i];


        for(int i = 0; i < n - 1; i++){
            adj[i + 1].push_back({d[i], p[i] - 1});
            adj[p[i] - 1].push_back({d[i], i + 1});
            
            //G[i + 1][p[i] - 1] = G[p[i] - 1][i + 1] = d[i];
            deg[i + 1]++;
            deg[p[i] - 1]++;
        }

        int ans = 0;

        //cout << "tya" << endl;

        //deg = 1の頂点をとりのぞく
        for(int i = 0; i < n; i++){

            if(deg[i] == 1){

                for(int j = 0; j < adj[i].size(); j++){
                
                    ans += adj[i][j].first;
                    
                }
            }
        
        }

        //取り除いた後の橋の重みの三倍を足していく
        for(int i = 0; i < n; i++){

            for(int j = 0; j < adj[i].size(); j++){

                if(i >= adj[i][j].second) continue;

                if(deg[i] == 1 || deg[adj[i][j].second] == 1) continue;

                ans += 3 * adj[i][j].first;
            }

        }

        //木の直径を求める
        int dis = 0;

        //cout << "wa" << endl;
        //cout << ans << endl;
        for(int i = 0; i < n; i++){
            if(deg[i] == 1) continue;

            //cout << i << endl;
            memset(used, false, sizeof(used));
            used[i] = true;
            dis = max(dis, dfs(i, adj));
        }

        ans -= dis;
        cout << ans << endl;
    
    }
    
    return 0;
}


Measured memory_bytes: 3192
#include <stdio.h>


int main(void)
{
	char n[3];

	scanf("%s", n);

	for (int i = 0; i < 3; i++){
		if (n[i] == '1'){
			n[i] = '9';
		}
		else if (n[i] == '9'){
			n[i] = '1';
		}
	}

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

	return 0;
}



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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(x, a);

    cout << ((x < a) ? 0 : 10) << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
        
    def bipartite_graph(edge,N,M):
        dist = [-1 for _ in range(N)]
        col = [0 for _ in range(N)]
        dist[0],col[0] = 0,1
        q = deque([(0,1)])
        while q:
            now,nc = q.popleft()
            for fol in edge[now]:
                if col[fol] == 0:
                    col[fol] = -1*nc
                    q.append((fol,-1*nc))
                elif col[fol] == nc:
                    return (N*(N-1))//2-M
        a = col.count(1)
        return a*(N-a)-M

    N,M = map(int,input().split())
    edge = [[] for _ in range(N)]
    for _ in range(M):
        a,b = map(int,input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
        
    print(bipartite_graph(edge,N,M))
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 25716
import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        
        // input
        int num = scan.nextInt();
        int sum = 0;
        for(int i = 0; i < num; i++){
            sum += scan.nextInt() - 1;
        }

        // answer
        System.out.println(sum);

    }
}

Measured memory_bytes: 26712
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(1, n-1):
    if (p[i] > p[i-1]) and (p[i+1] > p[i]):
        ans += 1
    elif (p[i] < p[i-1]) and (p[i+1] < p[i]):
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define len(x) x.size()
#define endl "\n"
#define m_p make_pair
#define int long long
using namespace std;

typedef long double ld;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pari;
ld PI = 3.14159265358979323846;


struct Point{
    int x,y;
};


void volodya22(){
    #ifdef THERE
        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(20);
    cout << fixed;
}


ld a,b;
const int N = 1e6;
const int INF = 1e18+7;
const int MOD = 1e9+7;

string s;


void input(){
    cin >> a >> b;
}


void solve(){
    cout << a/b;
}

signed main(){
    volodya22();
    input();
    solve();
}


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

int main()
{
  int n,r;
  for(;cin>>n>>r,n;)
    {
      vector<int> a;
      for(int i=n;i>0;i--)
	a.push_back(i);
      for(;r--;)
	{
	  int p,c;
	  cin>>p>>c;
	  vector<int> b;
	  for(int i=0;i<c;i++)
	    {
	      b.push_back(a[p-1]);
	      a.erase(a.begin()+p-1);
	    }
	  for(int i=0;i<a.size();i++)
	      b.push_back(a[i]);
	  a=b;
	}
      cout<<a[0]<<endl;
    }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;


struct Problem{
    int n;
    vector<int> a,b;
    set<pair<int,int>> st;
    vector<vector<int>> g;
    vector<int> vis;
    Problem(LL n):n(n),a(n),b(n){};

    void solve(){
        int xa=0,xb=0;
        for(int i=0; i<n; ++i){
            cin >> a[i];
            xa^=a[i];
        }
        for(int i=0; i<n; ++i){
            cin >> b[i];
            xb^=b[i];
        }
        vector<int> a2(a),b2(b);
        a2.push_back(xa);
        b2.push_back(xb);
        sort(a2.begin(),a2.end());
        sort(b2.begin(),b2.end());
        if(a2!=b2){
            cout << -1 <<endl;
            return;
        }
        a2.erase(unique(a2.begin(),a2.end()),a2.end());
        b2.erase(unique(b2.begin(),b2.end()),b2.end());

        a.push_back(xa);
        b.push_back(xb);
        for(int i=0; i<a.size(); ++i){
            a[i]=lower_bound(a2.begin(),a2.end(),a[i])-a2.begin();
            b[i]=lower_bound(b2.begin(),b2.end(),b[i])-b2.begin();
        }
        g.resize((int)a2.size());
        vis.resize((int)a2.size());
        int ans=0;
        for(int i=0; i<n; ++i){
            DBG(a[i],b[i])
            if(a[i]!=b[i]){
                ans++;
                st.insert({b[i],a[i]});
                g[b[i]].push_back(a[i]);
            }
        }
        int now=a.back();
        DBG(g,st)
        DBG(now)
        while(1){
            DBG(now,st)
            dfs(now);
            if(st.size()==0)break;
            ans++;
            now=st.begin()->first;
        }
        cout << ans <<"\n";
    }
    void dfs(int s){
        vis[s]=1;
        for(int x:g[s]){
            st.erase({s,x});
            if(!vis[x])dfs(x);
        }
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



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

int main(){
  int N, M, i;
  scanf("%d%d", &N, &M);
  vector<pair<int, int>> xy(M);
  for(i = 0; i < M; i++){
    scanf("%d%d", &xy[i].first, &xy[i].second);
    xy[i].second--;
  }
  sort(xy.begin(), xy.end());
  vector<vector<int>> used(N - 1, vector<int>(0)), up(N - 1, vector<int>(0)), down(N - 1, vector<int>(0));
  for(i = 0; i < M; i++){
//    printf("i = %d\n", i);
    int j = xy[i].second;
//    printf("j = %d\n", j);
    if(j == 0){
      up[j].push_back(0);
    }
    else if(used[j - 1].size() == 0){
      up[j].push_back(j);
    }
    else{
      up[j].push_back(up[j - 1][used[j - 1].size() - 1]);
    }
    if(j + 1 == N - 1){
      down[j].push_back(N - 1);
    }
    else if(used[j + 1].size() == 0){
      down[j].push_back(j + 1);
    }
    else{
      down[j].push_back(down[j + 1][used[j + 1].size() - 1]);
    }
    used[j].push_back(xy[i].first);
  }
//  printf("output\n");
  for(i = 0; i < N; i++){
//    printf("i = %d\n", i);
    int l, r;
    if(i == 0){
      l = 0;
    }
    else if(used[i - 1].size() == 0){
      l = i;
    }
    else{
      l = up[i - 1][used[i - 1].size() - 1];
    }
//    printf("l = %d\n", l);
    if(i == N - 1){
      r = N - 1;
    }
    else if(used[i].size() == 0){
      r = i;
    }
    else{
//      printf("test5\n");
      r = down[i][used[i].size() - 1];
    }
//    printf("r = %d\n", r);
    printf("%d", r - l + 1);
    if(i < N - 1){
      printf(" ");
    }
    else{
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25064
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
std::string a[510];
ll ans = INF;

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

  rep( i, N )
    std::cin >> a[i];

  ll cnt = 0;
  bool white = true;

  rep( j, N ) {
    bool fl = true;
    
    rep( i, N )
      fl &= a[i][j];

    if( !fl )
      ++cnt;

    rep( i, N )
      white &= a[i][j] == '.';
  }

  if( white ) {
    std::cout << -1 << std::endl;

    return 0;
  }

  rep( i, N ) {
    bool fl = false;

    rep( j, N ) {
      fl |= a[j][i] == '#';
    }

    ll sum = 0;

    if( !fl )
      ++sum;

    rep( j, N )
      sum += a[i][j] == '.';

    chmin( ans, sum );
  }

  if( ans == INF ) {
    std::cout << -1 << std::endl;

    return 0;
  }

  ans += cnt;

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3992
s = input()
answer = "Yes"
if "N" in s and "S" not in s:
	answer = "No"
elif "S" in s and "N" not in s:
	answer = "No"
elif "W" in s and "E" not in s:
	answer = "No"
elif "E" in s and "W" not in s:
	answer = "No"
print(answer)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long int n, a, b;
  cin >> n >> a >> b;
  long long int x[n], diff[n]={};
  long long int ans=0;
  for(int i=0; i<n; i++){
    cin >> x[i];
    if(i==0) continue;
    if((x[i]-x[i-1])*a<b) ans += (x[i]-x[i-1])*a;
    else ans += b;
  }
  
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1920
const lines=[];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

reader.on('line', function (line) {
  lines.push(line);
});

//入力後の処理
reader.on('close', function () {
    const input = (lines[0] as string).split(" ");
    const a = +input[0];
    const b = +input[1];

    if (a == b) {
        console.log(1);
        return;
    } 
    let res = 0;
    let numSockets = 1;
    while(numSockets < b){
        numSockets =(numSockets - 1) + a;
        res++;
    }
    console.log(res);
});

Measured memory_bytes: 30120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef priority_queue<ll, vector<ll>, greater<ll>> Queue;
const ll MOD = 1e9 + 7;
ll a[100000];
bool vis[100000];
vector<int> G[100000];
void dfs(int v, int p, Queue &q) {
    vis[v] = true;
    q.push(a[v]);
    for (int to : G[v]) {
        if (to == p) continue;
        dfs(to, v, q);
    }
}
int main() {
    int N, M;
    cin >> N >> M;
    if (M == N - 1) {
        cout << 0 << endl;
        return 0;
    }
    if (2 * (N - M - 1) > N) {
        cout << "Impossible" << endl;
        return 0;
    }
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    ll ans = 0;
    Queue tot;
    for (int i = 0; i < N; i++) {
        if (vis[i]) continue;
        Queue q;
        dfs(i, -1, q);
        ans += q.top(); q.pop();
        while (!q.empty()) {
            tot.push(q.top());
            q.pop();
        }
    }
    for (int i = 0; i < N - M - 2; i++) {
        ans += tot.top();
        tot.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 8952
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
	int n;
	cin >> n;
	vector<int> a(n/2),b(n/2);
	for(int i=0; i<n/2; i++)cin >> a[i] >> b[i];
	int odd_max=0,even_max=0,odd_key=a[0],even_key=b[0];
	int count=1,odd_second=0,even_second=0;
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	for(int i=1; i<n/2; i++){
		if(a[i-1]==a[i])count++;
		else {
			if(count>odd_max){
				odd_second=odd_max;
				odd_max=count;
				odd_key=a[i-1];
			}else odd_second=max(odd_second,count);
			count=1;
		}
	}
	if(count>odd_max){
		odd_second=odd_max;
		odd_max=count;
		odd_key=a[n/2-1];
	}else odd_second=max(odd_second,count);
	if(odd_max==0)odd_max=n/2;
	count=1;
	for(int i=1; i<n/2; i++){
		if(b[i-1]==b[i])count++;
		else {
			if(count>even_max){
				even_second=even_max;
				even_max=count;
				even_key=b[i-1];
			}else even_second=max(even_second,count);
			count=1;
		}
	}
	if(count>even_max){
		even_second=even_max;
		even_max=count;
		even_key=b[n/2-1];
	}else odd_second=max(odd_second,count);
	if(even_max==0)even_max=n/2;
	int ans=0;
	if(even_key==odd_key)ans=min(n-odd_max-even_second,n-even_max-odd_second);
	else ans=n-odd_max-even_max;
	cout << ans << endl;
	return 0;
}	

Measured memory_bytes: 640
import sys
def input():
    return sys.stdin.readline()[:-1]
x=int(input())
while 1:
    flag=0
    for i in range(2,int(x**(1/2))):
        if x%i==0:
            flag=1
            break
    if flag==0:
        break
    x+=1
print(x)

Measured memory_bytes: 38640
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[22][(1<<20)+5];
int n,K;
int f[22][(1<<20)+5],g[22][(1<<20)+5];
inline int dp(int x,int y,int z){return f[x][y+(z<<(n-x))];}
int main(){
	scanf("%d%d",&n,&K);
	for(int i=0;i<=n;i++)scanf("%s",s[i]);
	for(int i=0;i<(1<<n);i++)
		if(s[n][i]=='1')g[0][i]=1;
	for(int i=n-1;i>=0;i--){
		swap(f,g);
		for(int k=0;k<(1<<i);k++){
			g[0][k]=f[0][k<<1]+f[0][(k<<1)|1]+(s[i][k]=='1');
			for(int j=1;i+j<=n;j++)
				for(int l=0;l<(1<<j);l++)
					if(l&(1<<(j-1)))
						g[j][ k+(l<<(n-j)) ]=dp(j,k<<1,l)+dp(j-1,(k<<1)|1,l^(1<<(j-1)));
					else
						g[j][ k+(l<<(n-j)) ]=dp(j-1,k<<1,l)+dp(j,(k<<1)|1,l);
		}
	}
	for(int i=n;i>0;i--){
		for(int j=0;j<(1<<i);j++)if(g[i][j<<(n-i)]>=K){
			for(int k=(i-1);k>=0;k--)putchar('0'+((j>>k)&1));
			puts("");
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 202880
#include <iostream>
#include <map>
using namespace std;
int main() {
    int n,m,k;
    cin>>n>>m>>k;
    if(m-n+1<2*k){
    	for(int i=n;i<=m;i++){
    		cout<<i<<endl;
		}
	}else{
		for(int i=n;i<=n+k-1;i++){
    		cout<<i<<endl;
		}
		for(int i=m-k+1;i<=m;i++){
    		cout<<i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**9

s = input()
l = len(s)
f = True
for i in range(l-2):
    if s[i] == s[i+1] or s[i] == s[i+2] or s[i+1] == s[i+2]:
        print('{0} {1}'.format(i+1, i+3))
        f = False
        break
if f:
    if l > 1 and s[-1] == s[-2]:
        print('{0} {1}'.format(l-1, l))
    else:
        print('-1 -1')


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

int main()
{
 string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if (s == u)
    cout << a-1 << " " << b << endl;
  else
    cout << a << " " << b-1 << endl;
}

Measured memory_bytes: 256
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())

ABCD = []
for _ in range(Q):
    a, b, c, d = map(int, input().split())
    a, b = a - 1, b - 1  # 0-indexed
    ABCD.append((a, b, c, d))

ans = 0
for combi in combinations_with_replacement(list(range(1, M + 1)), N):
    # print(combi)
    s = 0
    for a, b, c, d in ABCD:
        if combi[b] - combi[a] == c:
            # print('a, b, c, d', a, b, c, d)
            s += d
    # print('s', s)
    ans = max(ans, s)
print(ans)


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

using namespace std;
using int64 = long long;
//const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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 F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

static constexpr uint32_t mul_inv(uint32_t n, int e = 5, uint32_t x = 1) {
  return e == 0 ? x : mul_inv(n, e - 1, x * (2 - x * n));
}


int main() {
  int64 N, D;
  cin >> N >> D;
  D *= D;
  int ret = 0;
  for(int i = 0; i < N; i++) {
    int64 x, y;
    cin >> x >> y;
    int64 d = x * x + y * y;
    ret += d <= D;
  }
  cout << ret << endl;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprrev(i, a, b) for (int i = b - 1; i >= a; i--) // [a, b)
#define reprev(i, n) reprrev(i, 0, n)


using namespace std;
double length_road(pair<double, double> a, pair<double, double> b) {
  double distance = sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
  return distance;
}

int main() {
  int N; cin >> N;
  int ave = 1;
  for(int i = 1; i <= N; i++) {
    ave *= i;
  }
  vector<pair<double, double>> L;
  rep(i, N) {
    double a, b;
    cin >> a >> b;
    L.emplace_back(a, b);
  }

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


  double sum = 0;
  do {
    for(int i = 0; i < N-1; i++) {
      auto a = L.at(i);
      auto b = L.at(i+1);
      sum += length_road(a, b);
    }
  } while(next_permutation(L.begin(), L.end()));

  cout << fixed << setprecision(10) << sum/ave << endl;
}

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

const long long MOD = 5;
const string YES = "YES";
const string NO = "NO";

int solve(long long A, long long B, long long C)
{
    for (int i = 1; i <= B; i++)
    {
        if (A * i % B == C)
        {
            puts("YES");
            return 0;
        }
    }

    puts("NO");
    return 0;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

typedef long double ld;

int main() {
  ld a,l,x;
  while(cin>>a>>l>>x) {
    ld h = sqrt(x*x+2.0*l*x) / 2.0;
    ld h2 = sqrt(l*l - (a/2.0) * (a/2.0));
    ld area = l * h + a * h2 / 2.0;
    cout<<setprecision(10)<<fixed<<area<<endl;
  }
  return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define ss second
#define ff first
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,A,B) for(int i=A;i<=B;i++)
#define mod 998244353
#define MOD (1000*1000*1000+7)
#define v1d vector<int>
#define v2d vector<vector<int>>
#define vip vector<pair<int,int> >
#define v1s vector<string>
#define pa pair<int,int>
#define print(v) for(auto i:v)cout<<i<<" ";cout<<"\n";
#define endl '\n'
#define input(b,n) for(int i=1;i<=n;i++)cin>>b[i];
#define Sort(v) sort(v.begin(),v.end())
#define RSort(v)   sort(v.rbegin(),v.rend())
#define all(v) v.begin(),v.end()
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//string s= bitset<64>(a).to_string();

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define fbo find_by_order // iterator to the kth element
#define ook order_of_key  //number of items that are strictly smaller than our item k
#define T pair<int, int>
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>

bool pallin(string s){
    int n = s.length();
    int i = 0, j = n-1;
    while(i <= j){
        if(s[i] != s[j])return false;
        i++;
        j--;
    }
    return true;
}

void solve(){
    string s;cin>>s;
    int n = s.length();
    int l = n/2;
    int r = l+2;
    string s1 = s.substr(0,l);
    string s2 = s.substr(l+1);
    if(pallin(s) && pallin(s1) && pallin(s2)){
        cout<<"Yes";
    }
    else cout<<"No";
    
}

int32_t  main(){ 
    IOS;
    int t=1;//cin>>t;
    while(t--){
        solve();
    }








}

Measured memory_bytes: 256
/*
 A Submission by $%U%$
 at time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FILE_IN "text.out"
#define FILE_OUT "result.out"
#define ofile freopen(FILE_IN,"r",stdin);freopen(FILE_OUT,"w",stdout)
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nfio cin.tie(0);cout.tie(0)
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))
#define ord(a,b,c) ((a>=b)and(b>=c))
#define MOD (ll(1000000007))
#define MAX 300001
#define mag 320
#define p1 first
#define p2 second.first
#define p3 second.second
#define fi first
#define se second
#define pow2(x) (ll(1)<<x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define piii pair<int,pii>
#define For(i,__,___) for(int i=__;i<=___;i++)
#define Rep(i,__,___) for(int i=__;i>=___;i--)
#define ordered_set tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update>
#define bi BigInt
#define pi 3.1415926535897
typedef long long ll;
//------------xúc xích normie tám muoi tám phan tram não----------//
int n,m,k,c[2001],t,t1,i,j,minn,maxx,cur,lu,lv;
bitset<4000001> dp;
int main() {
//	ofile;
	fio;
	cin>>n;
	dp[0]=1;
	for (i=1;i<=n;i++) {
	cin>>c[i];
	dp|=(dp<<c[i]);
	t+=c[i];
	}
	if (t%2==0)
	for (i=0;i<=t/2;i++) 
	{
		if (dp[t/2+i]) return cout<<t/2+i,0;
		if (dp[t/2-i]) return cout<<t/2-i,0;
	}
	else
	for (i=0;i<=t/2;i++) 
	{
		if (dp[t/2+i+1]) return cout<<t/2+i+1,0;
		if (dp[t/2-i]) return cout<<t/2-i,0;
	}
}


Measured memory_bytes: 5096
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    n /= 4;
    int c = 0;
    while (n--) {
      int x;
      cin >> x;
      c += x;
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 3044
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int X;
    cin >> X;
    for (int a = 1; a < 200; a++) {
        for (int b = -200; b < a; b++) {
            if ( pow(a, 5) - pow(b, 5) == X) {
                cout << a << " " << b;
                return 0;
            }
        }
    }

    return 0;
}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    string ans;
    int t_vic = c / b + 1;
    int a_vic = a / d + 1;
    if (c % b == 0)
        t_vic--;
    if (a % d == 0)
        a_vic--;
    if (t_vic <= a_vic)
        ans = "Yes";
    else
        ans = "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main(){
  long long N,M;
  cin >> N >> M;
  long long ans = 0LL;
  if(N==1LL&&M==1LL){
    ans+= 1LL;
  }
  else if(M==1LL||N==1LL){
      ans += max(N,M) -2LL;
   }
    else {
      ans += (N-2LL)*(M-2LL);
    }
    cout << ans << endl;
  }

Measured memory_bytes: 256
def eratosthenes(n):
    is_prime = [True for i in range(n+1)]
    is_prime[0], is_prime[1] = False, False
    prime = []
    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2*i, n+1, i):
                is_prime[j] = False
    return prime
    

Q = int(input())
N = 10**5

prime = eratosthenes(N)
prime_num = [0 for i in range(N+1)]
for p in prime:
    prime_num[p] = 1
    
count = 0
ans = [0 for i in range(N+1)]
for i in range(1, N+1, 2):
    if prime_num[i] == 1 and prime_num[(i+1)//2] == 1:
        count += 1
    ans[i] = count
    
for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r] - ans[l-2])

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var B = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            long ans = 0;
          
            for(var i = 0; i < N; i++)
            {
                var defeatedMonster = Math.Min(A[i], B[i]);

                A[i] -= defeatedMonster;
                B[i] -= defeatedMonster;
                ans += defeatedMonster;

                if (B[i] > 0)
                {
                    defeatedMonster = Math.Min(A[i + 1], B[i]);
                    A[i + 1] -= defeatedMonster;
                    B[i] -=defeatedMonster;
                    ans += defeatedMonster;
                }
            }

            Console.WriteLine(ans);

        }
    }
}

Measured memory_bytes: 45364
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sss =sc.nextInt();
        int a = sc.nextInt();
        int sum=0;
        for(int i=0;i<a;i++){
            int b = sc.nextInt();
            sum+=b;
            }
        if(sss<sum){
            System.out.println(-1);
        }
        else{
            System.out.println(sss-sum);
        }
        }

    }


Measured memory_bytes: 46516
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <stack>
#define N 1005
using namespace std;
typedef long long ll;
int main()
{
    char s[50];
    scanf("%s",s);
    int len=strlen(s);
    printf("2018");
    for(int i=4;i<len;i++)
        printf("%c",s[i]);
    printf("\n");
}


Measured memory_bytes: 256
N,K = map(int,input().split())

ans = []
n = (N+1)//2
if N%2==1:
    for i in range(1,n+1):
        a = i
        b = 4*n-2*i
        c = a+b+n-1
        a += K-1
        b += K-1
        c += K-1
        ans.append([a,b,c])
    for i in range(1,n):
        a = n+i
        b = 4*n-1-2*i
        c = a+b+n-1
        a += K-1
        b += K-1
        c += K-1
        ans.append([a,b,c])
else:
    for i in range(1,n+1):
        a = i
        b = 4*n+2-2*i
        c = a+b+n-1
        a += K-1
        b += K-1
        c += K-1
        ans.append([a,b,c])
        a = n+i
        b = 4*n+1-2*i
        c = a+b+n
        a += K-1
        b += K-1
        c += K-1
        ans.append([a,b,c])

if K>n:
    print(-1)
else:
    for a,b,c in ans:
        print(a,b,c)

Measured memory_bytes: 58968
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <tuple>

int main(int /*argc*/, char** /*argv*/)
{
	int D, T, S;
	std::cin >> D >> T >> S;
	if (T*S >= D) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)


int main() {

int S; cin >> S ;

ll ans=0;

numrep(i,S){
  numrep(j,S){
    numrep(k,S){
      int x=gcd(i,j);
      ans+=gcd(x,k);
    }
  }
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int a[maxn];
int main()
{
    int n,maxx=0;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i],maxx=max(maxx,a[i]);
    int minx=0;
    while(a[minx]==maxx) minx++;
    for(int i=minx+1;i<n;i++)
        if(abs(a[minx]-maxx/2)>abs(a[i]-maxx/2)&&a[i]!=maxx)
            minx=i;
    cout<<maxx<<' '<<a[minx]<<endl;
}


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

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

  vi a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  int cnt = 0;
  ll ans = 0;
  cnt++;
  ans += a.at(0);
  cnt++;
  REP(i,1,n){
    if (cnt == n) break;
    ans += a.at(i);
    cnt++;
    if (cnt == n) break;
    ans += a.at(i);
    cnt++;
    if (cnt == n) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4052
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    s=input()
    N=len(s)
    ans=[-1,-1]
    for i in range(N-1):
        if s[i]==s[i+1]:
            ans=[i+1,i+2]
            break
        
    for i in range(N-2):
        if s[i]==s[i+2]:
            ans=[i+1,i+3]
            
    print(' '.join(map(str, ans)))

main()


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

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


int n;
ll a[2000005];

int main()
{
    sf(n);

    for(int i=0;i<n;i++)
    {
        sfl(a[i]);
    }
    sort(a,a+n);
    reverse(a,a+n);
    int i=1,j=n-1;
    ll c=0;

    while(j>=i)
    {
        if(i<n)
        {
            c+=a[i-1];
        }
        if(j>i)
        {
            c+=a[i];
        }
        i++,j--;
    }
    pf("%lld\n",c);
}


Measured memory_bytes: 5348
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	int h,w;
	cin>>h>>w;
	char c[h+5][w+5];
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin>>c[i][j];
	for(int i=0;i<=w+1;i++)  c[0][i]=c[h+1][i]='.';
	for(int i=0;i<=h+1;i++)  c[i][0]=c[i][w+1]='.';	
	bool f=1;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			if(c[i][j]=='#' && (c[i-1][j]=='.' && c[i+1][j]=='.' && c[i][j+1]=='.' && c[i][j-1]=='.')){
				f=0;
			}			
	if(f==1)  cout<<"Yes";
	else  cout<<"No";
	return 0;	
}

Measured memory_bytes: 256