akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  for( i=1 ; i < n ; i++){
    key = A[i];
    j = i-1;
    while( j >=0 && A[j] > key ){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
    trace(A, n);
  }

  return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const int N     = 100;
const int INFTY = (1 << 21);

int n, M[N][N];
int d[N];  // 距離で訪問状態(color)を管理する。

void bfs(int s) {
    queue<int> q;  //標準ライブラリのqueueを使用。
    q.push(s);
    rep(i, n) d[i] = INFTY;
    d[s]           = 0;
    int u;
    while (!q.empty()) {
        u = q.front();
        q.pop();
        rep(v, n) {
            if (M[u][v] == 0) continue;
            if (d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    rep(i, n) {
        cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    int u, k, v;
    cin >> n;
    rep(i, n) { rep(j, n) M[i][j] = 0; }
    rep(i, n) {
        cin >> u >> k;
        u--;
        rep(j, k) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    bfs(0);

    return 0;
}



Measured memory_bytes: 3224
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vvi e(N+1, vi(1,0));
    FOR(i,1,N+1){
        FOR(j,1,N+1) {
            if (j == i) e[i].push_back(0);
            else e[i].push_back(j);
        }
    }

    int sum = 0;
    for(int i : e[N]) {
        sum += i;
    }
    if (N % 2 == 0) sum--;

    FOR(i,1,N+1) {
        int s = 0;
        for(int j : e[i]) {
            s += j;
        }
        if (s > sum) {
            e[i].erase(e[i].begin() + (s - sum));
        }
    }

    int M = 0;
    vvi ans(N+1);
    FOR(i,1,N+1) {
        for (int j=0; j < e[i].size(); j++) {
            if (e[i][j] != 0 && i < e[i][j]) {
                ans[i].push_back(e[i][j]);
                M++;
            }
        }
    }

    cout << M << endl;
    FOR(i,1,N+1) {
        for(int j : ans[i]){
            cout << i << " " << j << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <cmath>
#include <vector>
using namespace std;


int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++) cin >> h[i];

  const int INF = 1 << 30;
  vector<int> dp(N, INF);
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);

  for (int i = 2; i < N; i++) {
    dp[i] = min(
      dp[i-1] + abs(h[i] - h[i-1]),
      dp[i-2] + abs(h[i] - h[i-2])
    );
  }
  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 3932
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.stream.LongStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.OptionalLong;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AIceTeaStore solver = new AIceTeaStore();
        solver.solve(1, in, out);
        out.close();
    }

    static class AIceTeaStore {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            long q = in.ints(), h = in.ints(), s = in.ints(), d = in.ints();
            int n = in.ints();
            long min2 = IntMath.min(8 * q, 4 * h, 2 * s, d);
            long min1 = IntMath.min(4 * q, 2 * h, s);
            out.println(n / 2 * min2 + n % 2 * min1);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }

    static final class IntMath {
        private IntMath() {
        }

        public static long min(long... v) {
            return Arrays.stream(v).min().orElseThrow(NoSuchElementException::new);
        }

    }
}



Measured memory_bytes: 27476
// linux???????????????C++????????????????????????????????????
// <bits/stdc++.h>????????????????????????????????¨??§?????????????????????????????§??????
#include <bits/stdc++.h>

// C++????????????????????°???void????????\??????
int main() {
  int x, y, s;
  for(;;) {
    // ??\?????¨????????????
    // C++??§???"&&"?????£?????????"and", "||"?????£?????????"or", "!"?????£?????????"not"????????????
    scanf("%d %d %d", &x, &y, &s);
    if( x == 0 and y == 0 and s == 0 ) break;
    // ??§??£?????¨??¢?´¢
    // ICPC????????????1??????/2???????????????????????¨??¢?´¢????????????????????????????????§
    // ??¨??????????????¨??¢?´¢???????????????????????????????????????
    // ??????????¨???????????????????????????????????????¨??¨??????????¶???????s????????????????????????????????????
    // m1  := 1???????????????????¨????????????? (????????????s)
    // m2  := 2???????????????????¨????????????? (????????????s)
    // max := ?±????????????§???
    int max = -1;
    for(int m1 = 1; m1 < s; ++m1) {
      for(int m2 = 1; m2 < s; ++m2) {
        // prev := ??????????????????????????????m1, m2?????¨???????¨????x%?????¨??????????¨???????
        int prev = m1 * (100 + x) / 100 + m2 * (100 + x) / 100;
        // prev???s??§???????????????????????????
        if( prev != s ) continue;
        // next := ?¨????y%?????¨??????????¨???????
        int next = m1 * (100 + y) / 100 + m2 * (100 + y) / 100;
        // C++??§???????????¨?????????????????§???????±?????????¨??????std::max()???????????????????????????
        max = std::max(max, next);
      }
    }
    printf("%d\n", max);
  }

  return 0;
}

Measured memory_bytes: 3200
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		
		solve();flush();
		
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		myout(one.get(0) == one.get(1) ? "Yes" : "No");
	}
	//Method addition frame start



	//Method addition frame end
}


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

#define mod 1000000007
using ll = long long;

int main(){

  int n,k;
  cin >> n >> k;

  if(n==k){
    ll ans = 1;
    ll num;
    for(int i=0;i<n;i++){
      cin >> num;
      ans=ans*num%mod;
    }
    cout << (ans+mod)%mod;
    return 0;
  }

  priority_queue<ll> pos;
  priority_queue<ll> neg;
  ll num;
  for(int i=0;i<n;i++){
    cin >> num;
    if(num>=0){
      pos.push(num);
    }else{
      neg.push(-num);
    }
  }


  if(k%2==1 && pos.empty()){
    ll ans=1;
    ll num;
    for(int i=0;i<n;i++){
      num=-neg.top();
      neg.pop();
      if(i>=n-k){
        num=num%mod;
        ans=ans*num%mod;
      }
    }
    cout << (ans+mod)%mod << endl;
    return 0;
  }


  ll ans=1;
  ll posnum=1;
  ll negnum=1;
  ll count=0;
  priority_queue<ll> que;
  if(k%2==1){
    ans=pos.top()%mod;
    pos.pop();
    count++;
  }

  while(pos.size()>=2){
    posnum=pos.top();
    pos.pop();
    posnum=posnum*pos.top();
    pos.pop();
    que.push(posnum);
  }

  while(neg.size()>=2){
    negnum=neg.top();
    neg.pop();
    negnum=negnum*neg.top();
    neg.pop();
    que.push(negnum);
  }

  ll s;
  while(1){
    if(count==k){
      cout << (ans+mod)%mod << endl;
      return 0;
    }
    s=que.top();
    s=s%mod;
    que.pop();
    ans=ans*s%mod;
    count+=2;
  }

}

Measured memory_bytes: 6664
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


vector<int>E[330];
ll dist[330][330];
int N, M, L;
ll check(int s, int t) {
	ll ans = inf;

	if (dist[s][t] <= L)return 0;
	for (int i = 0; i < N; i++) {
		if (i != s && i != t) {
				if (dist[i][t] <= L) {
					ans = min(ans,(dist[s][i]+L-1)/L);
				}
		}
	}
	return ans;
}

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

	cin >> N >> M >> L;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			dist[i][j] = (i == j)?0:inf;
		}
	}

	for (int i = 0; i < M; i++) {
		int A, B, C;
		cin >> A >> B >> C;
		A--, B--;
		if (C <= L) {
			dist[A][B] = C;
			dist[B][A] = C;
		}
	}

	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	for (int i = 0; i < N; i++)for (int j = 0; j < N; j++) {
		dist[i][j] = (dist[i][j] <= L)?1:inf;
	}

	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}


	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int s, t;
		cin >> s >> t;
		s--, t--;
		if (dist[s][t] < 1e15)puts(dist[s][t]-1);
		else puts(-1);
	}


	return 0;
}


Measured memory_bytes: 1280
#include <math.h>
#include <stdio.h>

#define N 8

int next(int n, int *pp) {
	int i, j, tmp;

	for (i = n - 2; i >= 0; i--)
		if (pp[i] < pp[i + 1])
			break;
	if (i < 0)
		return 0;
	for (j = n - 1; j >= 0; j--)
		if (pp[i] < pp[j])
			break;
	tmp = pp[i], pp[i] = pp[j], pp[j] = tmp;
	for (i++, j = n - 1; i < j; i++, j--)
		tmp = pp[i], pp[i] = pp[j], pp[j] = tmp;
	return 1;
}

int main() {
	static int xx[N], yy[N], ii[N];
	int n, i, fac;
	double ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d%d", &xx[i], &yy[i]);
	for (i = 0; i < n; i++)
		ii[i] = i;
	ans = 0;
	do {
		for (i = 0; i + 1 < n; i++)
			ans += hypot(xx[ii[i]] - xx[ii[i + 1]], yy[ii[i]] - yy[ii[i + 1]]);
	} while (next(n, ii));
	fac = 1;
	while (n--)
		fac *= (n + 1);
	printf("%.10f\n", ans / fac);
	return 0;
}

Measured memory_bytes: 384
n, d = map(int,input().split())

a = 0
X = []

while a < n :
    X.append(input().split())
    a += 1

i = 0
j = 0
p = 0
wa = 0
count = 0

while i < n :
    p = 1
    while i + p < n :
        wa = 0
        j = 0
        while j < d :
            wa += pow(int(X[i][j]) - int(X[i + p][j]), 2)
            j += 1
        p += 1
        if (wa ** .5).is_integer() :
            count += 1
    i += 1

print(count)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int n, a[N];
int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++)scanf("%d", a+i);
	int ans=1e9;
	for(int i=-100; i<101; i++){
		int t=0;
		for(int j=0; j<n; j++){
			t+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans, t);
	}
	printf("%d\n", ans);
	return 0;
}

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

#define forsn(i,s,n) for(tint i=(s);i<(tint)(n); i++)
#define forn(i,n) forsn(i,0,n)
#define dforn(i,n) for(tint i = tint(n)-1; i >= 0; i--)
#define debug(x) cout << #x << " = "  << x << endl

using namespace std;

typedef long long tint;

random_device rd;
mt19937 gen(rd());

uniform_int_distribution<tint> dis(1, 10000);

void imprimirVector (vector<tint> v)
{
	if (!v.empty())
	{ 
		tint p = tint(v.size());
		cout << "[";
		forn(i,p-1)
			cout << v[i] << ",";
		cout << v[p-1] << "]" << endl;
	}
	else
		cout << "[]" << endl;
}

tint h,w,k;
const tint MAXH = 16;
const tint MAXW = 1024;
const tint INF = MAXH*MAXW+1;
tint bar[MAXH][MAXW];
tint acc[MAXH][MAXW];

tint solve1D (const vector<vector<tint> > &rows)
{
	tint ans = 0;
	//~ imprimirVector(last);
	tint n = tint(rows.size());
	vector<tint> total_white(n);
	
	forn(j,w)
	{
		bool any = false;
		forn(i,n)
		{
			total_white[i] += rows[i][j];
			if (total_white[i] > k)
				any = true;
		}
		if (any)
		{
			forn(i,n)
			{
				total_white[i] = rows[i][j];
					if (total_white[i] > k)
						ans = INF;
			}
		}
		
		ans += tint(any);
	}
	//~ debug(ans);
	//~ debug(k);
	return ans;
}

tint solve(tint mask)
{
	
	tint total = __builtin_popcountll(mask);
	mask |= (1L << h);
	//~ cout << "------" << endl;
	//~ cout << mask << endl;
	vector<tint> last (w,0);
	vector<vector<tint> > rows;
	forn(i,h+1)
	{
		if ((1L << i) & mask)
		{	
			rows.push_back(last);
			forn(j,w)
				last[j] = 0;
		}
		if (i < h)
		{
			forn(j,w)
				last[j] += bar[i][j];
		}
		
	}
	total += solve1D(rows);
	return total;
}


int main()
{
	#ifdef ACMTUYO
		assert(freopen("entrada.in", "r", stdin));
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	while (cin >> h >> w >> k)
	{
		forn(i,h)
		{
			string s;
			cin >> s;
			forn(j,w)
				bar[i][j] = tint(s[j] == '1');	
		}
		tint mini = INF;
		forn(mask,(1L << h))
			mini = min(mini,solve(mask));
		cout << mini << "\n";
		
		 
	}
	
	
	return 0;
}





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

int main(){
	string seg[10] =
	{
	"0111111","0000110","1011011","1001111","1100110",
	"1101101","1111101","0100111","1111111","1101111"
	};
	int n;
	while(1){
		cin >> n;
		if(n == -1) break;
		int cou = n;
		string now;
		while(cou--){
			int num; cin >> num;
			if(cou == n-1) {
				cout << seg[num] << endl;
				now = seg[num];
			}
			else {
				for(int i=0;i<7;i++){
					if(now[i] == seg[num][i]) cout << "0";
					else cout << "1";
				}
				cout << endl;
				now = seg[num];
			}
		}
	}
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"
using namespace std;

long long N;

int DFS(long long X) {
	int res = 0;
	long long Y = X;
	bool check3 = false, check5 = false, check7 = false;
	while (Y != 0) {
		if (Y % 10 == 3) check3 = true;
		if (Y % 10 == 5) check5 = true;
		if (Y % 10 == 7) check7 = true;
		Y /= 10;
	}
	if (check3 && check5 && check7) res++;
	if (X * 10 + 3 <= N) res += DFS(X * 10 + 3);
	if (X * 10 + 5 <= N) res += DFS(X * 10 + 5);
	if (X * 10 + 7 <= N) res += DFS(X * 10 + 7);
	return res;
}

int main() {
	cin >> N;
	cout << DFS(0);
}

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

int main()
{
    int n,m;
    std::cin>>n>>m;
    long long ans;
    if(n==1 && m==1)ans = 1;
    else if(n==1 || m==1)ans = std::max(std::max(n,m) - 2,0);
    else{
        ans = (long long)(n-2) * (long long)(m-2);
    }
    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int>d(n);
  for(int i = 0; i < n; i++)
    cin >> d[i];
  
  sort(d.begin(), d.end());
  int ans = d[d.size()/2] -d[d.size()/2 -1];
  cout << ans;
}

Measured memory_bytes: 3688
use proconio::input;
use proconio::marker::{Chars};

fn main() {
    input!{
        s: Chars,
    }
    let mut ans = 0;
    let mut count = 0;
    for iter in s {
        if iter == 'S' {
            count = 0;
        }
        else {
            count += 1;
        }
        if count > ans {
            ans = count;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2108
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define rt return
using dbl = double;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

const int INF = INT_MAX / 3;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;

    vi a(n), cnt(n + 1), cov(n + 1);
    rep(i, n) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int ans = 0;
    FOR(i, 1, n + 1) {
        rep(j, cnt[i]) {
            if (i - j > 0)cov[i - j]++;
            else break;
        }
    }
    FOR(i, 1, n + 1)if (cov[i] == 0)ans++;

    while (m--) {
        int x, y;
        cin >> x >> y;
        x--;
        if (a[x] - cnt[a[x]] + 1 > 0) {
            if (--cov[a[x] - cnt[a[x]] + 1] == 0)ans++;
        }
        cnt[a[x]]--;
        
        a[x] = y;
        cnt[y]++;
        if (y - cnt[y] + 1 > 0) {
            if (++cov[y - cnt[y] + 1] == 1)ans--;
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
int fa[100001],sizes[100001];
int root(int node){
    while(node!=fa[node]){
        fa[node]=fa[fa[node]];
        node=fa[node];
    }
    return(node);
}
void link(int i,int j){
    i=root(i);j=root(j);
    if(i==j) return;
    if(sizes[i]>sizes[j]) swap(i,j);
    sizes[j]+=sizes[i];
    fa[i]=j;
    return;
}

void solve(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        fa[i]=i;
        sizes[i]=1;
    }
    while(m--){
        int a,b,c;
        cin>>a>>b>>c;
        link(a,b);
    }
    int cnt=0;
    for(int i=1;i<=n;i++) if(i==fa[i]) cnt++;
    cout<<cnt;
    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


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

int main(int argc, const char * argv[]) {
    int N, M;
    cin >> N;
    cin >> M;
    
    int sum = 0;
    vector<int> A;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        sum += tmp;
        A.push_back(tmp);
    }
    
    int threshold = (int)ceil(((float)sum / (4.0f * (float)M)));
    
    int count = 0;
    for (int a : A) {
        if (threshold <= a) {
            count++;
        }
        if (count >= M) {
            std::cout << "Yes" << endl;
            return 0;
        }
    }
    
    std::cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  char s[100];
  scanf("%s", s);

  int length;
  for (int i = 0; i < 100; i++) {
    if (s[i] < 'a' || s[i] > 'z') {
      length = i;
      break;
    }
  }

  int first_length = (length-1)/2;

  char first[first_length];
  for (int i = 0; i < first_length; i++) {
    first[i] = s[i];
  }

  char first_rev[first_length];
  for (int i = 0; i < first_length; i++) {
    first_rev[i] = first[first_length-1-i];
  }

  int flag = 1;
  for (int i = 0; i < first_length; i++) {
    if (first[i] != first_rev[i]) {
      flag = 0;
      break;
    }
  }

  char s_rev[length];

  if (flag == 1) {
    for (int i = 0; i < first_length; i++) {
      s_rev[i] = first[i];
    }
    s_rev[first_length] = s[first_length];
    for (int i = 0; i < first_length; i++) {
      s_rev[first_length+1+i] = first_rev[i];
    }
    for (int i = 0; i < length; i++) {
      if (s[i] != s_rev[i]) {
        flag = 0;
        break;
      }
    }
  }

  if (flag == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int N, M;
Graph G(100100, vector<int>());
vector<vector<ll>> dp(100100, vector<ll>());
vector<ll> ans(100100);

ll dfs1(int v, int p) {
    ll res = 1;
    for (int u = 0; u < G[v].size(); u++) {
        if (G[v][u] != p) {
            dp[v][u] = dfs1(G[v][u], v);
            res *= (dp[v][u] + 1);
            res %= M;
        }
    }
    return res;
}

void dfs2(int v, int p, ll dp_p) {
    int n = G[v].size();

    for (int i = 0; i < G[v].size(); i++) {
        if (G[v][i] == p) {
            dp[v][i] = dp_p;
            break;
        }
    }

    vector<ll> l(n), r(n);

    for (int i = 0; i < n; i++) {
        l[i] = r[i] = (dp[v][i] + 1) % M;
    }

    for (int i = 1; i < n; i++) {
        l[i] *= l[i - 1];
        l[i] %= M;
    }
    for (int i = n - 2; i >= 0; i--) {
        r[i] *= r[i + 1];
        r[i] %= M;
    }

    for (int i = 0; i < n; i++) {
        int nv = G[v][i];
        if (nv == p) continue;

        ll dp_v = 1;
        if (i != 0) {
            dp_v *= l[i - 1];
            dp_v %= M;
        }
        if (i != n - 1) {
            dp_v *= r[i + 1];
            dp_v %= M;
        }
        dfs2(nv, v, dp_v);

    }
}


int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    cin >> N >> M;

    G.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    dp.resize(N);
    for (int i = 0; i < N; i++) {
        dp[i].resize(G[i].size());
    }

    dfs1(0, -1);
    dfs2(0, -1, 0);

    REP(i, N) {
        ll ans = 1;
        for (ll dp_i: dp[i]) {
            ans *= (dp_i + 1);
            ans %= M;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 23040
/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
**************************
Codeforces Java Template 
made by Ray Bai
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         int N = input.length();
         //process
         int[] arr = new int[N];
         for(int i=0; i < N; i++)
         {
            char c = input.charAt(i);
            if(c == '?')
               arr[i] = -1;
            else
               arr[i] = Integer.parseInt(c+"");
         }
         long[][] dp = new long[N+1][13];
         long MOD = 1000000007L;
         //base
         if(arr[0] >= 0)
         {
            int rem = power(10, N-1, 13);
            rem *= arr[0];
            rem %= 13;
            dp[0][rem] = 1L;
         }
         else
            for(int i=0; i <= 9; i++)
            {
               int rem = power(10, N-1, 13);
               rem *= i;
               rem %= 13;
               dp[0][rem] = 1L;
            }
         for(int i=1; i < N; i++)
         {
            int var = arr[i];
            if(var >= 0)
               for(int r=0; r < 13; r++)
               {
                  int val = power(10, N-1-i, 13);
                  val *= var;
                  dp[i][(val+r)%13] += dp[i-1][r];
                  dp[i][(val+r)%13] %= MOD;
               }
            else
               for(int v=0; v <= 9; v++)
                  for(int r=0; r < 13; r++)
                  {
                     int val = power(10, N-1-i, 13);
                     val *= v;
                     dp[i][(val+r)%13] += dp[i-1][r];
                     dp[i][(val+r)%13] %= MOD;
                  }
         }
         System.out.println(dp[N-1][5]);
      }
      public static int power(long x, long y, long p) 
       { 
           // Initialize result 
           long res = 1L;
           // Update x if it is more   
           // than or equal to p 
           x = x % p;  
         
           while (y > 0) 
           { 
               // If y is odd, multiply x 
               // with result 
               if((y & 1)==1) 
                   res = (res * x) % p; 
         
               // y must be even now 
               // y = y / 2 
               y = y >> 1;  
               x = (x * x) % p;  
           } 
           return (int)res; 
       } 
   }

Measured memory_bytes: 49876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll MOD = 1e9 + 7;
const ll dx[4] = { -1,1,0,0 };
const ll dy[4] = { 0,0,-1,1 };
const ll MAX = 1e5 + 50 ;
const ll oo = 1e16;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
long long gcd(long long  a, long long  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll n , m , ans , k ; string s ;
ll a[1010],b[1010],c[1010];

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

    int x , y , z , p ;
    cin >> x >> y >> z >> p ;

    for(int i = 0 ; i < x ; ++i)
        cin >> a[i];
    for(int j = 0 ; j < y ; ++j)
        cin >> b[j];
    for(int p = 0 ; p < z ; ++p)
        cin >> c[p];


    vector < ll > sums ;

    for(int i = 0 ; i < x ; ++i)
        for(int j = 0 ; j < x ; ++j)
            sums.pb(a[i] + b[j]);

    sort(all(sums));
    reverse(all(sums));
    vector < ll > res ;
    for(int i = 0 ; i < min(3010 , (int)sums.size()) ; ++i)
        for(int j = 0 ; j < z ; ++j)
            res.pb(c[j] + sums[i]);

    sort(all(res));
    reverse(all(res));

    for(int i = 0 ; i < p ; ++i)
        cout << res[i] << '\n';

     return 0;
}


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

int main(void){
 string S;
  cin >> S;
  if((int)S[3] <= 8 + 48){
    cout << "Heisei";
  }
  else if(S[3] == '9' && S[5] == '0'  && (int)S[6] <= 4 + 48){
    cout << "Heisei";
  }
  else cout << "TBD";
  return 0;
}

Measured memory_bytes: 256
height,width = map(int, input().split())
map_list = []
for i in range(height):
    map_list.append(list(input()))
    map_list[i].append('0')
map_list.append(['0'] * width)

for h in range(height):
    for w in range(width):
        if map_list[h][w] == '#':
            if '#' in [map_list[h-1][w], map_list[h+1][w], map_list[h][w-1], map_list[h][w+1]]:
                continue
            else:
                print("No")
                exit()

print("Yes")


Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>

using namespace std;

static const int INF = 1e9 + 7;
vector<long long> fact;
vector<long long> revfact;

long long powMod(long long x, int k){
    if(k == 0) return 1;
    if(k % 2 == 0) return powMod(x * x % INF, k / 2);
    else	return x * powMod(x, k - 1) % INF;
}

void setfact(int N){
    fact.resize(N + 1);
    revfact.resize(N + 1);
    fact[0] = 1;
    for(int i = 1; i < N + 1; i++){
        fact[i] = fact[i - 1] * i;
        fact[i] %= INF;
    }
    revfact[N] = powMod(fact[N], INF - 2);
    for(int i = N - 1; i >= 0; i--){
        revfact[i] = revfact[i + 1] * (i + 1);
        revfact[i] %= INF;
    }
}

long long getC(int a, int b){
    return (((fact[a] * revfact[b]) % INF) * revfact[a - b]) % INF;
}

int main(){
    long long x, y;
    cin >> x >> y;
    long long a = 2 * y - x, b = 2 * x - y;
    if(a < 0 || b < 0 || a % 3 || b % 3){
        cout << 0 << "\n";
        return 0;
    }
    a /= 3;
    b /= 3;
    setfact(a + b + 15);
    cout << getC(a + b, a) << "\n";
}

Measured memory_bytes: 10624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main(){
  int n,k;
  while(1){
    cin >> n >> k;
    if(n+k==0)break;
    vector<int> numbers;
    vector<int> answers;
    rep(i,n){
      int x;
      cin >> x;
      numbers.push_back(x);
    }
    for(int bit=0;bit<(1<<n);bit++){
      vector<int> use;
      for(int i=0;i<n;i++){
        if(bit&(1<<i)){
          use.push_back(numbers[i]);
        }
      }
      if(use.size()!=k)continue;
      sort(use.begin(),use.end());
      do{
        string ans="";
        rep(i,use.size()){
          ans += to_string(use[i]);
        }
        //cout << ans << endl;
        if(ans!=""){
          answers.push_back(stoi(ans));
        }
      }while(next_permutation(use.begin(),use.end()));
    }
    sort(answers.begin(),answers.end());
    int a = answers[0];
    int res=1;
    rep(i,answers.size()){
      //cout << answers[i] << endl;
      if(a != answers[i]){
        a = answers[i];
        res++;
      }
    }
    cout << res << endl;
    //cout << "LOOPEND" << endl;
  }

      

  return 0;
}


Measured memory_bytes: 3284
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>

int main(void) {
    int N;
    int M;
    std::string target;
    bool discovery; 
    bool door = false;

    std::cin >> N;
    std::vector<std::string> U(N);
    for (int i = 0; i < N; i++) {
        std::cin >> U[i];
    }
    std::cin >> M;
    for (int i = 0; i < M; i++) {
        discovery = false;
        std::cin >> target;
        for (int j = 0; j < N; j++) {
            if (target == U[j]) {
               discovery = true; 
               break;
            }
        }

        if (discovery == true && door == false) {
            std::cout << "Opened by " << target << std::endl;
            door = true;
        } else if (discovery == true && door == true){
            std::cout << "Closed by " << target << std::endl;
            door = false;
        } else {
            std::cout << "Unknown " << target << std::endl;
        }
    }
    
    return EXIT_SUCCESS;
}

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

int comp(const void* a, const void* b)  
{ return *(int*)a > *(int*)b ; }  
  
int findNumberOfTriangles(int arr[], int n)  
{  
    qsort(arr, n, sizeof( arr[0] ), comp);  
  
    int count = 0; 

    for (int i = 0; i < n - 2; ++i)  
    {  
     
        int k = i + 2;  
  
        // Fix the second element  
        for (int j = i + 1; j < n; ++j)  
        {  
          
            while (k < n && arr[i] + arr[j] > arr[k])  
            ++k;  
  
            if(k > j)  
            count += k - j - 1;  
        }  
    }  
  
    return count;  
}  

int main()  
{  
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    cout<<findNumberOfTriangles( a, n );  
  
    return 0;  
}  

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

int main(){
  int n; int x=0; scanf("%d",&n);
  REP(i,n){
    int y; scanf("%d",&y); x+=y%2;
  }
  if(x%2) printf("NO\n"); else printf("YES\n");
  return 0;
}

Measured memory_bytes: 764
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    ll n,tot=0, ans=1LL<<60;
    cin>>n;
    ll s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
        tot+=s[i];
    }
    for(int i=0;i<n-1;i++){
        tot-=2*s[i];
        ans=min(ans,abs(tot));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
import java.util.*;

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

      Scanner sc = new Scanner(System.in);                                            
      
      String S = sc.next();
     
      String target = "";
      for(int i = 0;i < S.length();i++){
          if(S.charAt(i) == 'C'){
              target = S.substring(i+1);
          }
      }
      
      if(target.contains("F")){
          System.out.println("Yes");
      }else{
          System.out.println("No");          
      }
      
      
   }
        
 }

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

using namespace std;

int main() {
  int H, N, A;
  int damage = 0;
  cin >> H >> N;
  for (int i=0; i<N; i++) {
    cin >> A;
    damage += A;
  }
  if (damage >= H) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.math.BigDecimal;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
       BigDecimal k = BigDecimal.valueOf(sc.nextLong());       
      BigDecimal money = BigDecimal.valueOf(100.0);  
       BigDecimal a = BigDecimal.valueOf(1.01);
        int cnt = 0;
        while(money.compareTo(k) == -1){
        	cnt+=1;
        	money=money.multiply(a);
            BigDecimal bd1 = money.setScale(0, BigDecimal.ROUND_DOWN);
          money = bd1;
        }
   	System.out.println(cnt);            

	}
}

Measured memory_bytes: 36664
n = int(input())

C = [[0 for j in range(10)] for i in range(10)]

for k in range(1, n + 1):
    sk = str(k)
    C[int(sk[0])][int(sk[-1])] += 1

ans = 0
for i in range(1, 10):
    for j in range(i, 10):
        ans += ((i != j) + 1) * C[i][j] * C[j][i]
print(ans)


Measured memory_bytes: 3060
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
    long double a,b;
	cin>>a>>b;
	long double ans = a*b;
    ll x = floor(ans);
    cout<<x;
	return 0;
}


Measured memory_bytes: 3748
import sys
sp=input()
t=input()

m=len(sp)
n=len(t)
for i in range(m-n,-1,-1):
  cand=sp[:i].replace('?','a')+t+sp[i+n:].replace('?','a')
  for j,w in enumerate(t):
    if sp[j+i]!=w and sp[j+i]!='?':
      break
  else:
    print(cand)
    sys.exit()
print('UNRESTORABLE')

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

int N, P;
int A[100];

void solve(bool odd){
	long long res;
	if(!odd){
		if(P == 0) res = pow(2, N);
		else res = 0;
	}
	else{
		res = pow(2, N-1);
	}
	cout << res << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> P;
    bool odd = false;
    for(int i = 0; i < N; i++){
    	cin >> A[i];
    	if(A[i]%2 == 1) odd = true;
    }
    solve(odd);
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    s = input().split()
    N, M = int(s[0]), int(s[1])

    t = 0
    if N == 1 and M == 1:
        t = 1
    elif N == 1:
        t = M - 2
    elif M == 1:
        t = N - 2
    else:
        t = (N - 2) * (M - 2)

    print(t)


if __name__ == '__main__':
    main()



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

int main() {
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    bool ans = true;
    for(int i = 0; i < a; ++i) if(!('0' <= s[i] && s[i] <= '9')) ans = false;
    if(s[a] != '-') ans = false;
    for(int i = a + 1; i < a + b + 1; ++i) if(!('0' <= s[i] && s[i] <= '9')) ans = false;
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MN 100000
#define ll long long
#define mp(x,y) make_pair(x,y)
using namespace std;
inline ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,ansnum,g[MN+5];ll f[MN+5];
pair<int,int> ans[MN+5];
set<pair<ll,pair<int,int> >,greater<pair<ll,pair<int,int> > > >st;
set<pair<ll,pair<int,int> > >::iterator it;
int main()
{
    n=read();
    for(int i=1;i<=n;++i) st.insert(mp(read(),mp(i,g[i]=1)));
    while(st.size()>1)
    {
        pair<ll,pair<int,int> >a=*st.begin(),b;
        st.erase(st.begin());
        ll nx=a.first+a.second.second-(n-a.second.second);
        it=st.lower_bound(mp(nx,mp(1e9,1e9)));
        if(it==st.end()||(*it).first!=nx) return 0*puts("-1");
        b=*it;st.erase(it);
        ans[++ansnum]=mp(a.second.first,b.second.first);
        b.second.second+=a.second.second;
        st.insert(b);
    }
    for(int i=1;i<n;++i) f[ans[i].second]+=f[ans[i].first]+g[ans[i].first],g[ans[i].second]+=g[ans[i].first];
    if(f[st.begin()->second.first]!=st.begin()->first) return 0*puts("-1");
    for(int i=1;i<n;++i) printf("%d %d\n",ans[i].first,ans[i].second);
    return 0;
}


Measured memory_bytes: 9728
#include<bits/stdc++.h> 
using namespace std;
int main(){
  long long n, i, j;  
  cin>>n; 
  long long arr[n]; 
  for(i=0;i<=n;i++){
    cin>>arr[i]; 
    }
  for(i=0;i<=n;i++){ 
    if(arr[i]==0){ cout<<0; return 0;}
    }
  long long ans=1; 
  for(j=0;j<n;j++){
    if(arr[j]>1000000000000000000/ans){
      cout<<-1;
      return 0;
      }
    else{ ans*=arr[j];    }
    }
  cout<<ans;
  
  
  }


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

int main(){
  long long int L,R;
  cin >> L >> R;
  if(L/2019!=R/2019){
    cout << 0 << endl;
  }else{
    int min=2019;
    for(long long int i=L;i<R;i++){
      for(long long int j=i+1;j<R+1;j++){
        if((i*j)%2019<min){
          min=(i*j)%2019;
        }
      }
    }
    cout << min << endl;
  }
  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

      String[] lns = in.readLine().split(" ");
      int n = Integer.parseInt(lns[0]);
      int m = Integer.parseInt(lns[1]);
      City[] city = new City[m];
      City[] city2 = new City[m];
      int[] p = new int[n+1];

      int x,y;
      for(int i=0; i<m; i++) {
        lns = in.readLine().split(" ");
        x = Integer.parseInt(lns[0]);
        y = Integer.parseInt(lns[1]);
        city[i] = new City(i, x, y);
        city2[i] = city[i];
      }

      Arrays.parallelSort(city2, new Comparator<City>() {
        public int compare(City a, City b) {
          if(a.y == b.y) return 0;
          return a.y > b.y ? 1 : -1;
        }
      });

      for(int i=0; i<m; i++) {
        city2[i].no = ++p[city2[i].p];
      }

      String no;
      for(int i=0; i<m; i++) {
        no = String.format("%06d%06d", city[i].p,city[i].no);
        out.println(no);
      }
      out.flush();
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
  class City {
    int s;
    int p;
    int y;
    int no;

    public City(int s, int p, int y) {
      this.s = s;
      this.p = p;
      this.y = y;
    }
  }
}

Measured memory_bytes: 109908
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;

#ifdef DEBUG
int __cnt = 0;
#define msg(x) cout << ++__cnt << '\t' << __FUNCTION__ << "(" << __LINE__ << "): " << x << endl
#else
#define msg(x)
#endif

typedef long long ll;
typedef unsigned long long ull;

template<typename T>
T _scan() {
  T ch; bool seg = false;
  while (!isdigit(ch = getchar())) {
    seg |= (ch == '-');
  }
  T x = ch - '0';
  while (isdigit(ch = getchar())) {
    x = x * 10 + ch - '0';
  }
  if (seg) {
    x = -x;
  }

  return x;
}

auto const scan = &_scan<int>;
auto const scan_ll = &_scan<ll>;

template<typename T>
T maximize(T& a, const T b) {
  if (b > a) {
    a = b;
  }
  return a;
}

template<typename T>
T minimize(T& a, const T b) {
  if (b < a) {
    a = b;
  }
  return a;
}



int main() {
  int n = scan(), a = scan(), b = scan();
  while (n--) {
    int ch = getchar();
    switch (ch) {
      case 'c':
        puts("No");
        break;
      case 'a':
        if (a) {
          --a; puts("Yes"); break;
        }
      case 'b':
        if (b) {
          --b; puts("Yes"); break;
        }
        puts("No");
        break;
    }
  }
}



Measured memory_bytes: 1144