akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class ACoffee {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            char[] c = s.next().toCharArray();
            w.println(c[2] == c[3] && c[4] == c[5] ? "Yes" : "No");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public String next() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
using namespace std;

struct drink 
{
    long a;
    long b;
};

bool cmp(const drink &value_a, const drink &value_b) {
  return value_a.a < value_b.a;
}

int main(void)
{
    long t,n,m,tmp = 0;
    long total = 0;

    cin >> n >> m;
    struct drink drinks[n];
    for(int i = 0;i < n;i++)
    {
        cin >> drinks[i].a >> drinks[i].b;
    }
    sort(drinks,drinks+n,cmp);      
    for(int i = 0;i < n;i++)
    {
        if(tmp + drinks[i].b > m){total += drinks[i].a * (m - tmp); break;}
        if(tmp < m){total += drinks[i].a * drinks[i].b; tmp += drinks[i].b;}
        else{break;}
    }

    cout << total << endl;
    return 0;
}

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

using namespace std;

int gcd2(int a, int b)
{
	if (b == 0)
		return a;
	
	return gcd2(b, a % b);
}

int gcd3(int a, int b, int c)
{
	return gcd2(gcd2(a, b), c);
}

int main() {
	
	int n, res = 0, i, j, k;
	
	scanf("%d", &n);
	
	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
			for (k = 1; k <= n; k++)
				res += gcd3(i, j, k);
	
	printf("%d", res);	
	
	return 0;
}

Measured memory_bytes: 3816
n=int(input())
cnt=[[0]*10 for i in range(10)]
for i in range(1,n+1):
  cnt[int(str(i)[0])][int(str(i)[-1])]+=1
ans=0
for i in range(1,10):
  for j in range(1,10):
    ans+=cnt[i][j]*cnt[j][i]
print(ans)    


Measured memory_bytes: 67396
///   ***   ---   |||         In the name of ALLAH        |||   ---   ***   ///



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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}




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

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

gp_hash_table<long long, int, custom_hash> cnt;

const int mx = 1e5+123;
int a[mx];

int main()
{
    optimize();

    int n;
    cin >> n;
    for ( int i = 1; i <= n; i++ ) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    int ans = 0;
    for ( int i = 1; i <= n; i++ ) {
        if ( cnt[a[i]] >= a[i] ) ans += ( cnt[a[i]] - a[i] );
        else ans += cnt[a[i]];
        cnt[a[i]] = 0;
    }

    cout << ans << endl;



    return 0;
}


















Measured memory_bytes: 9968
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    const char *YES = "Yes";
    const char *NO = "No";

    const char C = 'C';
    const char F = 'F';

    char S[101];

    if (scanf("%s", S) < 1) return 0;

    bool flg = false;
    for (int i = 0; i < strlen(S); i++)
    {
        if (!flg)
        {
            if (S[i] == C) flg = true;
        }
        else if (S[i] == F)
        {
            printf("%s\n", YES);
            return 0;
        }
    }

    printf("%s\n", NO);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
using namespace std;
int main()
{
	SPEED
	string s, t;
	cin >> s >> t;
	int count = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		if (s[i]!=t[i])
		{
			count++;
		}
	}

	cout << count;
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)

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

typedef long long ll;

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

    int n;
    cin >> n;

    vector<int> buttons(n);
    rep(i, n) cin >> buttons[i];

    int put = 0;
    bool flag = false;
    rep(i, n){
        if(put == 1){
            cout << i << endl;
            flag = true;
            break;
        }

        put = buttons[put] - 1;
    }

    if(!flag) cout << -1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sqr(x) (x)*(x)
typedef long long ll;

int main() {
    string str;
    cin >> str;
    if(str.substr(2,1) == str.substr(3,1) && str.substr(4,1) == str.substr(5,1)) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 256
x, y = map(int, input().split())

if 0 <= x <= y or x <= y <= 0:
    print(y - x)
elif x <= 0 <= y:
    if x == 0 or y == 0:
        print(abs(x + y))
    else:
        print(abs(y + x) + 1)
elif 0 <= y <= x or y <= x <= 0:
    if x == 0 or y == 0:
        print(abs(x - y) + 1)
    else:
        print(abs(x - y) + 2)
else:
    print(abs(x + y) + 1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;

int n,a[N],b[N];
ll ans;
priority_queue<pair<int,int>>q;

int main(){
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	for(int i=1;i<=n;++i)cin>>b[i];
	for(int i=1;i<=n;++i)q.push(make_pair(b[i],i));
	while(!q.empty()){
		int x=q.top().second;q.pop();
		int l=x==1?n:x-1,r=x==n?1:x+1;
		int w=b[x]-a[x];
		if(w==0)continue;
		if(w<(b[l]+b[r])){
			puts("-1");
			return 0;
		}
		b[x]-=w/(b[l]+b[r])*(b[l]+b[r]);
		ans+=w/(b[l]+b[r]);
		q.push(make_pair(b[x],x));
	}
	cout<<ans<<endl;
} 

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

using namespace std;
typedef pair<int, int> pii;
typedef unsigned long long ull;

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

bool between(int a, int b, int c){
	return a <= b && b < c;
}
bool valid_count(ull v){
	const ull m = 0x1111111111111111ull;
	return (v & (v >> 1) & (v >> 2) & (v >> 3) & m) == 0;
}

map< pair<ull, pii>, int > memo;
int recur(
	ull count, int y, int x, const vector< vector<ull> > &dec,
	const vector< vector<ull> > &cutmask)
{
	map< pair<ull, pii>, int >::iterator it =
		memo.find(make_pair(count, pii(y, x)));
	if(it != memo.end()){ return it->second; }
	int h = dec.size(), w = dec[0].size();
	if(y == h){ return count != 0 ? INF : 0; }
	if(count & cutmask[y][x]){ return INF; }
	int ny = (x + 1 == w ? y + 1 : y), nx = (x + 1 == w ? 0 : (x + 1));
	int answer = INF;
	if(dec[y][x] != 0ull){
		ull nc = count - dec[y][x];
		if(valid_count(nc)){
			answer = 1 + recur(nc, ny, nx, dec, cutmask);
		}
	}
	answer = min(answer, recur(count, ny, nx, dec, cutmask));
	memo.insert(make_pair(make_pair(count, pii(y, x)), answer));
	return answer;
}

int main(){
	while(true){
		int h, w;
		cin >> h >> w;
		if(h == 0 && w == 0){ break; }
		vector<string> field(h);
		for(int i = 0; i < h; ++i){ cin >> field[i]; }
		vector< vector<int> > hint(h, vector<int>(w, -1));
		ull init_count = 0;
		for(int i = 0, hi = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				if(isdigit(field[i][j])){
					hint[i][j] = hi;
					init_count |= ((ull)field[i][j] - '0') << hi * 4;
					++hi;
				}
			}
		}
		vector< vector<ull> > dec(h, vector<ull>(w));
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				if(field[i][j] != '.'){
					ull vec = 0;
					for(int k = 0; k < 9; ++k){
						int y = i + dy[k], x = j + dx[k];
						if(!between(0, y, h) || !between(0, x, w)){ continue; }
						if(hint[y][x] < 0){ continue; }
						vec |= (1ull << hint[y][x] * 4);
					}
					dec[i][j] = vec;
				}
			}
		}
		vector< vector<ull> > cutmask(h, vector<ull>(w));
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				if(hint[i][j] < 0){ continue; }
				int x = j + 2, y = i + 1;
				if(x >= w){ x = 0; ++y; }
				if(y < h){ cutmask[y][x] |= 0x0full << (hint[i][j] * 4); }
			}
		}
		memo.clear();
		cout << recur(init_count, 0, 0, dec, cutmask) << endl;
	}
	return 0;
}

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

int main() {

    long long h, w; cin >> h >> w;
    long long hw = h * w;

    if (h == 1 || w == 1) cout << 1 << endl;
    else if (hw % 2 == 0) cout << hw / 2 << endl;
    else cout << hw / 2 + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

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

  int ans = n;
  while (true)
  {
    int tmp = ans;
    bool j = true;
    while (tmp)
    {
      int t = tmp % 10;
      tmp /= 10;
      for (int i = 0; i < k; ++i)
      {
        if (t == d[i])
        {
          ans++;
          j = false;
          break;
        }
      }
      if (!j)
        break;
    }
    if (j)
      break;
  }
  cout << ans << endl;

  return 0;
}


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

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

	string ans = "Zero";
	if( a > 0 ) ans = "Positive";
	else if(  b < 0 ) {
		long long n = a - b + 1;
		if( n % 2 ) ans = "Negative";
		else ans = "Positive";
	}

	cout << ans << endl;
}


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

int main(){
  int N,K;
  cin >> N >> K; //nk=33
  vector<int> P(N) ;
  for(int i =0;i<K;i++){
    int d;
    cin >> d;//1
    vector<int> S(d) ;
    for(int j=0;j<d;j++){
      cin >> S.at(j);//j0
      P.at(S.at(j)-1)++;
    }
  }
  int answer = 0 ;
  for(int l =0;l<N;l++){
    if(P.at(l) == 0){answer++;}
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3628
import math

N,M = map(int,input().split())
n = 1
m = 1
if (abs(N-M) > 1):
  print(0)
else:
  for i in range(1,N+1):
    n = (n*(i%((10**9)+7))%((10**9)+7))
  for j in range(1,M+1):
    m = (m*(j%((10**9)+7))%((10**9)+7))
  if (abs(N-M) == 1):
    print((n*m)%((10**9)+7))
  else:
    print((n*m*2)%((10**9)+7))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{
    // 整数の入力
    int A,B,H,M;
    cin >> A >> B >> H >> M;
    
    int amin = H*60+M;
    double h_th = 2*M_PI/(12*60)*amin;
    double m_th = 2*M_PI/60*M;    
    double ax = A * sin(h_th);
    double ay = A * cos(h_th);

    double bx = B * sin(m_th);
    double by = B * cos(m_th);    
    double len = sqrt((ax - bx)*(ax - bx) + (ay - by)*(ay - by));
    // 出力
    cout << std::fixed << std::setprecision(20) << len << endl;
    return 0;
}


Measured memory_bytes: 4100
indices = Hash.new

readlines.each do |l|
	word, page = l.chomp.split
	if indices.has_key?(word)
		indices[word] << page.to_i
	else
		indices[word] = [page.to_i]
	end
end

indices.sort.each do |word,pages| 
	puts word
	pages.sort.each_with_index {|p,i| print (i==0 ? "#{p}" : " #{p}")}
	puts ""
end

Measured memory_bytes: 6100
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int m = in.nextInt();
        out.println(m>=n?"Yes":"No");
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21076
import java.util.*;

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

        int n = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 1; i < n; i++) {
            map.put(i, 0);
        }

        for (int i = 1; i < n; i++) {
            for (int j = i + 1; j <= n; j++) {
                int length = calcLength(i, j, x, y);
                map.put(length, map.get(length) + 1);
            }
        }

        for (int i = 1; i < n; i++) {
            System.out.println(map.get(i));
        }
    }

    private static int calcLength(int i, int j, int x, int y) {
        int a = j - i;
        int b = Math.abs(x - i) + 1 + Math.abs(j - y);
//        int c = Math.abs(y - i) + 1 + Math.abs(j - x);

//        return Math.min(a, Math.min(b, c));
        return Math.min(a,b );
//        if (i <= x && j >= y) {
//            return ((j - i) - (y - x)) + 1;
//        } else if (i <= x && j < y) {
//            int lengthl = j - i;
//            int lengthr = (y - j) + (x - i) + 1;
//            return Math.min(lengthl, lengthr);
//        } else if (i > x && j >= y) {
//            int lengthl = j - i;
//            int lengthr = (i - x) + (j - y) + 1;
//            return Math.min(lengthl, lengthr);
//        } else {
//            return j - i;
//        }
    }
}


Measured memory_bytes: 61596
#include<stdio.h>
#include<algorithm>

using namespace std;

int N, abc[100001][3];

void input(){
  scanf("%d", &N);
  for(int i=1; i<=N; i++){
    scanf("%d %d %d", &abc[i][0], &abc[i][1], &abc[i][2]);
  }
}

int main(){
  input();
  int DP[100001][3] = {0};
  for(int i=1; i<=N; i++){
    DP[i][0] = max(DP[i-1][1], DP[i-1][2]) + abc[i][0];
    DP[i][1] = max(DP[i-1][0], DP[i-1][2]) + abc[i][1];
    DP[i][2] = max(DP[i-1][0], DP[i-1][1]) + abc[i][2];
  }
  printf("%d", max(DP[N][0], max(DP[N][1], DP[N][2])));
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int ot(int m) {
	return m / 5 + m % 5;
}
int main() {
	int m;
	cin >> m;
	while (m != 0) {
		m = 1000 - m;
		int ans = 0;
		for (int i = 0; i < 4; i++) {
			int l = m % 10;
			ans += ot(l);
			m = m / 10;
		}
		cout << ans << endl;
		cin >> m;
	}
	return 0;
}


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) a.begin(), a.end()
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {	
	int N,D,X;
	int A[101];
	cin >> N >> D >> X;
	for (int i = 1; i <= N; ++i) {
		cin >> A[i];
	}

	int ans = 0;
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j * A[i]+1 <= D; ++j) {
			++ans;
		}
	}

	ans += X;
	cout << ans << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N;

int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    cout<<2*PI*N<<endl;

}    


Measured memory_bytes: 3796
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		String S = sc.next();
		String T = sc.next();
		System.out.println(T+S);
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((a+b)==(c+d)){
        cout << "Balanced" << endl;
    }else if((a+b)>(c+d)){
        cout << "Left" << endl;
    }else{
        cout << "Right" << endl;
    }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll n, ansm, ansk, cnt;
    ll a[85];
    ansm = 1000;

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

    int si = a[0];
    cnt = 0;
    for(int i = 1; i <= n; i++) {
        if(a[i] > a[i - 1]) {
            cnt++;
        } else if(a[i] < a[i - 1]) {
            if(cnt > 0) {
                ansk = ansm / si;
                ansm += ansk * (a[i - 1] - si);
                cnt = 0;
            }
            si = a[i];
        }
    }

    cout << ansm << endl;

    return 0;
}

Measured memory_bytes: 3628
if __name__ == '__main__':
    Q, H, S, D = map(int, input().split())
    N = int(input())
    #各サイズの量
    #amounts = {'Q' : 0.25, 'H' : 0.5, 'D' : 1.0, 'D' : 2.0}
    #1リットルあたりの値段
    sizes = {'Q' : int(Q * 4.0), 'H' : int(H * 2.0), 'S' : S, 'D' : int(D * 0.5)}
    sizes = sorted(sizes.items(), key=lambda x: x[1])
    sum_price = 0
    while N > 0:
        for size in sizes:
            if size[0] != 'D':
                sum_price += size[1] * N
                N = 0
            else:
                num = int(N / 2)
                N -= 2 * num
                sum_price += D * num
    print(sum_price)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
        int n, k; cin >> n >> k;
        vector<int> v;
        for (int x = 0; x < n; ++x){
            int q; cin >> q;
            v.push_back(q);
        }
        sort(v.begin(), v.end());
        int ans = 0;
        for (int x = 0; x < k; ++x){
            ans += v[x];
        }
        cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
N=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
b=[]
if len(a)%2==0:
    for i in range(0,(len(a)//2)):
        b.append(a[2*i]-a[2*i+1])
else:
    for i in range(0,(len(a)//2)):
        b.append(a[2*i]-a[2*i+1])
    b.append(a[len(a)-1])
print(sum(b))

Measured memory_bytes: 61356
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

string s;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> s;
    for(int i=0;i<s.lg-1;i++){
        if(s[i]=='A' && s[i+1]=='C'){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 256
//
// Created by yuu on 2019-04-25.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;


int main(void){

    int A,B;
    cin>>A>>B;
    if(A==1){
        A = 100;
    }
    if(B==1){
        B = 100;
    }

    if(A>B){
        cout<<"Alice"<<endl;
    }else if(B>A){
        cout<<"Bob"<<endl;
    }else{
        cout<<"Draw"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int sum = 0;
	int out = 0;
	string s;
	int r=0;
	int n;
	cin >> n;
	while (n){
		cin >> s;
		if (s == "HIT"){
			if (r + 1 == 4){
				sum++;
			}
			else{
				r++;
			}
		}
		if (s == "HOMERUN"){
			sum += r+1;
			r = 0;
		}
		if (s == "OUT"){
			if (out + 1 == 3){
				n--;
				cout << sum << endl;
				sum = 0;
				r = 0;
				out = 0;
			}
			else{
				out++;
			}
		}
	}
}

Measured memory_bytes: 1212
#include <iostream>
#include<vector>

using namespace std;

int N, A, B;
vector<int> V;

int C[300005];

int main(void) {

	cin >> N >> A >> B;

	if (A + B >= N + 2 || (long long int) A*B < (long long int) N) {
		cout << -1 << endl;
	}
	else {
		int num = N;
		for (int i = 1; i <= A; i++) { C[i] = 1; num--; }
		for (int i = 1; i <= A; i++) {
			for (int j = 2; j <= B; j++) { if (num > 0) { C[i]++; num--; } }
			if (num <= 0) { break; }
		}

		for (int i = 1; i <= A; i++) {
			C[i] += C[i - 1];
		}

		for (int i = 1; i <= A; i++) {
			for (int j = C[i]; j > C[i - 1]; j--) { V.push_back(j); }
		}

		for (int i = 0; i < N; i++) {
			if (i == 0) { cout << V[i]; }
			else { cout << " " << V[i]; }
		}
		cout << endl;
	}



	//system("pause");
	return 0;
}

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

int main()
{
	int i;
	char a[4];
	for( i = 0 ; i < 4 ; i++ )
	{
		scanf("%c",&a[i]);
	}
	if(a[0] == a[1] && a[1] == a[2])
		printf("Yes\n");
	else if( a[1] == a[2] && a[2] == a[3])
		printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
using System;
class Program
{
    static IO io = new IO();

    static void Main(string[] args)
    {
        //入力
        io.Read();
        int N = io.Int();
        io.ReadSplit();
        int[] A = io.Int(N);

        //計算
        int xCount = 1;
        int xDirection = 0;
        for (int i = 1; i < A.Length; ++i)
        {
            int xNewDirection = Direction(A, i);
            if (xDirection == 0)
            {
                if (xNewDirection == 1)
                {
                    xDirection = 1;
                }
                else if (xNewDirection == -1)
                {
                    xDirection = -1;
                }
            }
            else if (xDirection == 1)
            {
                if (xNewDirection == -1)
                {
                    xCount += 1;
                    xDirection = 0;
                }
            }
            else if (xDirection == -1)
            {
                if (xNewDirection == 1)
                {
                    xCount += 1;
                    xDirection = 0;
                }
            }
        }
        
        //出力
        io.Write(xCount.ToString());

    }
    static int Direction(int[] A, int i)
    {
        if (A[i - 1] == A[i])
        {
            return 0;
        }
        else if(A[i - 1] < A[i])
        {
            return 1;
        }
        else if (A[i - 1] > A[i])
        {
            return -1;
        }
        else
        {
            return 999;
        }
    }
}

class IO
{
    private string[] input;
    private int index;
    public void Read()
    {
        input = new string[1];
        input[0] = Console.ReadLine();
        index = -1;
    }
    public void ReadSplit()
    {
        input = Console.ReadLine().Split(' ');
        index = -1;
    }
    public string String()
    {
        index += 1;
        return input[index];
    }
    public string[] String(int count)
    {
        index += 1;
        string[] rv = new string[count];
        Array.Copy(input, index, rv, 0, count);
        return rv;
    }
    public int Int()
    {
        index += 1;
        return int.Parse(input[index]);
    }
    public int[] Int(int count)
    {
        index += 1;
        int[] rv = new int[count];
        for (int i = 0; i < count; ++i)
        {
            rv[i] = int.Parse(input[index + i]);
        }
        return rv;
    }
    public long Long()
    {
        index += 1;
        return long.Parse(input[index]);
    }
    public long[] Long(int count)
    {
        index += 1;
        long[] rv = new long[count];
        for (int i = 0; i < count; ++i)
        {
            rv[i] = long.Parse(input[index + i]);
        }
        return rv;
    }
    public void Write(string str)
    {
        Console.WriteLine(str);
    }
}

Measured memory_bytes: 24416
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var in []string
	scanner := bufio.NewScanner(os.Stdin)
	if scanner.Scan() {
		in = strings.Split(scanner.Text(), " ")
	}

	var n1, n2 int
	stack := []int{}
	for _, s := range in {
		switch s {
		case "+":
			if len(stack) > 1 {
				n1, n2, stack = stack[len(stack)-2], stack[len(stack)-1], stack[:len(stack)-2]
				stack = append(stack, n1+n2)
			}
		case "-":
			if len(stack) > 1 {
				n1, n2, stack = stack[len(stack)-2], stack[len(stack)-1], stack[:len(stack)-2]
				stack = append(stack, n1-n2)
			} else if len(stack) == 0 {
				stack[0] = stack[0] * -1
			}
		case "*":
			n1, n2, stack = stack[len(stack)-2], stack[len(stack)-1], stack[:len(stack)-2]
			stack = append(stack, n1*n2)
		default:
			i, _ := strconv.Atoi(s)
			stack = append(stack, i)
		}
	}
	fmt.Println(stack[0])
}


Measured memory_bytes: 1108
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}


macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"3 7"# => r#"5 6 7 8 9 "#,
r#"4 0"# => r#"-3 -2 -1 0 1 2 3 "#,
r#"1 100"# => r#"100 "#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        k: i64,
        x: i64,
    }

    let mut disp:String = "".to_string();
    for i in x-k+1..x+k {
        if -1000000 <= i && i <= 1000000 {
            disp.push_str(&format!("{} ", i.to_string()));
        }
    }

    disp
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

//まあ大丈夫だと思うが集合の数はsetに各ノードの根を入れてその大きさ見れば良い
//各グループの要素数uf.size[uf.find(1)]みたいな感じでfind経由忘れずに
//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
struct UnionFind{
public:
	vector<int> par;
	vector<int> rank;
	vector<int> s;
	int cnt;
 
	UnionFind(int n){
		rep(i,n){
			par.push_back(i);
			rank.push_back(0);
			s.push_back(1);
		}
		cnt=n;
	}
 
	int find(int x){
		if(par[x]==x) return x;
		else return par[x]=find(par[x]);
	}
 
	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			par[x]=y;
			s[y]+=s[x];
		}else{
			par[y]=x;
			s[x]+=s[y];
			if(rank[x]==rank[y]) rank[x]++;
		}
		cnt--;
	}

	bool same(int x,int y){
		return find(x)==find(y);
	}

	int size(int x){
		return s[find(x)];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,k;
	cin>>n>>m>>k;
	UnionFind uf(n);
	vector<set<int>> g(n);
	rep(i,n) g[i].insert(i);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--,b--;
		g[a].insert(b);
		g[b].insert(a);
		uf.unite(a,b);
	}
	rep(i,k){
		int c,d;
		cin>>c>>d;
		c--,d--;
		if(uf.same(c,d)){
			g[c].insert(d);
			g[d].insert(c);
		}
	}
	rep(i,n){
		cout<<uf.size(i)-g[i].size()<<endl;
	}
}

Measured memory_bytes: 30188
from functools import lru_cache
N = int(input())
A = list(map(int, input().split()))

@lru_cache(maxsize=N)
def f(i):
    if i >= 2:
        return f(i - 2) + 2 * A[i - 1] - 2 * A[i - 2]
    total = 0
    for j in range(N):
        if j % 2 == 0:
            total += A[(i + j) % N]
        else:
            total -= A[(i + j) % N]
    return total

B = (f(i) for i in range(N))

print(*B)

Measured memory_bytes: 108516
#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (llong (Itr) = a; (Itr) < b; (Itr) += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)

#include <iostream>
#include <map>
#include <vector>
using namespace std;
using llong = long long;


int main() {
    int n;
    vector<llong> a;
    cin >> n;
    a.resize(n);
    for (auto &vs:a) cin >> vs;

    map<llong, llong> mp;
    mp[0] = 1;

    llong ans = 0;
    llong s = 0;
    for (auto vs:a) {
        s += vs;
        ans += mp[s];
        mp[s]++;
    }

    cout << ans << endl;

    return 0;
};


Measured memory_bytes: 17252
#include <iostream>
#include <vector>

using namespace std;

/*
再帰関数での全探索
bit全探索(2^n通り)
*/

void many_equals();

void train_ticket();


int main()
{
  //many_equals();
  train_ticket();
}


void many_equals()
{
  string S;
  cin >> S;
  vector<int> a(S.size());

  for (int i = 0; i < S.size(); ++i)
  {
    a[i] = S[i] - '0';
  }

  cout << (1 << (S.size() - 1)) << "\n";;

  long long int n_sum = 0;
  for (int i = 0; i < 1 << (S.size() - 1); ++i)
  {
    //cout << i << "\n";
    long long int tmp = a[0];
    for (int p = 0; p < S.size() - 1; ++p)
    {
      //p left shift先にあれば
      if (i & 1 << p)
      {
        n_sum += tmp;
        tmp = a[p + 1];
      }
      else
      {
        tmp = tmp * 10 + a[p + 1];
      }
    }
    n_sum += tmp;
  }

  cout << n_sum << "\n";
}

void train_ticket()
{
  string abcd;
  cin >> abcd;
  vector<int> a(abcd.size());
  for (int i = 0; i < abcd.size(); ++i)
  {
    a[i] = abcd[i] - '0';
  }

  vector<char> sign(3);

  for (int i = 0; i < 1 << (abcd.size() - 1); ++i)
  {
    int v_sum = a[0];
    for (int j = 0; j < abcd.size() - 1; ++j)
    {
      if (i & 1 << j)
      {
        v_sum += a[j + 1];
        sign[j] = '+';
      }
      else
      {
        v_sum -= a[j + 1];
        sign[j] = '-';
      }
    }
    //iの位置は+,それ以外は-を行う判定
    if (v_sum == 7)
    {
      for (int k = 0; k < 3; ++k)
      {
        cout << abcd[k] << sign[k];
      }
      cout << abcd[3] << "=7\n";

      return;
    }
  }
}

Measured memory_bytes: 3116
#include<math.h>
#include<stdlib.h>

int main(void){
  int S = 4;
  char moji[S];
  int num = 0;
  int i = 0;
  for(i = 0;i < S;i++){
    scanf("%s",&moji[i]);
  }
  for(i = 0 ;i < S ;i++){
  if(moji[i] == '+')
        num++;
      else 
        num--;
  } 
   
  printf("%d",num);
  
  return 0;
  
//	  
  
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
#define PRYES(x) PR((x) ? "Yes" : "No")
const long long INF = numeric_limits<long long>::max();
// SourceTest用出力マクロ
#ifdef SOURCE_TEST
#define SPR(x) PR(x)
#define SPS(x) PS(x)
#else
#define SPR(x) \
    {}
#define SPS(x) \
    {}
#endif
int main() {
    ll N;
    cin >> N;

    ll count = 0;

    for (ll i = 1; i <= N; ++i) {
        for (ll j = 1; j <= N; ++j) {
            ll ab = i * j;
            if (i * j >= N) break;
            count++;
        }
    }

    PR(count);
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> a(m);
    rep(i, m) cin >> a[i];

    ll sum = 0;
    rep(i, m) sum += a[i];
    ll ans = n - sum;
    if (ans >= 0) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 3708
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<functional>

#define LLI long long int

using namespace std;

int N;
vector<pair<int,int> >BA;
int main(){
	cin>>N;
	for(int i=0;i<N;i++){
			int a,b;
			cin>>a>>b;
			BA.push_back(pair<int,int>(b,a));
	}
	sort(BA.begin(),BA.end());
	int now=0;
	string ans="Yes";
	for(int i=0;i<N;i++){
		pair<int,int>job=BA[i];
		now+=job.second;
		if(now>job.first){
				ans="No";
				break;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 2420
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9') f|=c=='-',c=getchar();
    while(c>='0'&&c<='9') x=x*10+(c^48),c=getchar();
    return f?-x:x;
}

#define MAXN 2000
#define INF 0x7fffffff
int N;
char str[MAXN+5];
vector<int> G[MAXN+5];
int Size[MAXN+5],Max[MAXN+5],Min[MAXN+5];

int All;
void dfs(int u,int fa){
    Size[u]=Max[u]=Min[u]=0;
    for(int i=0;i<int(G[u].size());i++){
        int v=G[u][i];
        if(v!=fa){
            dfs(v,u);
            Size[u]+=Size[v];
            Max[v]+=Size[v];
            Min[v]+=Size[v];
            if(max(Min[u],Min[v])<=min(Max[u],Max[v])){
                Max[u]+=Max[v];
                Min[u]=(Min[u]%2!=Min[v]%2);
            }
            else{
                Min[u]=max(Min[u],Min[v])-min(Max[u],Max[v]);
                Max[u]+=Max[v];
            }
        }
    }
    if(str[u]=='1')
        Size[u]++;
}

int main(){
    N=read();
    scanf("%s",str+1);
    for(int i=1;i<=N-1;i++){
        int u=read(),v=read();
        G[u].push_back(v),
        G[v].push_back(u);
    }
    int Ans=INF;
    for(int i=1;i<=N;i++){
        All=0;
        dfs(i,-1);
        if(!Min[i])
            Ans=min(Ans,Max[i]/2);
    }
    printf("%d",Ans==INF?-1:Ans);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n, m;
  cin >> n;
  VEC<pair<int, int>> B(n), R(n);
  REP(i, 0, n) { cin >> R[i].first >> R[i].second; }
  REP(i, 0, n) { cin >> B[i].first >> B[i].second; }
  sort(ALL(R));
  sort(ALL(B));
  int cnt = 0;
  //DUMP/g(R);
  //DUMP/g(B);
  REP(i, 0, n) {
    auto p = upper_bound(ALL(R), B[i]);
    int ma = -1;
    auto mi = R.begin();
    auto a = R.begin();
    for (a = R.begin(); a != p; ++a) {
      if (a->second < B[i].second && a->second > ma) {
        ma = a->second;
        mi = a;
      }
    }
    if (ma > -1) {
      ++cnt;
      //DUMP/g(cnt, B[i], *mi);
      //DUMP/g("  ",R);
      mi->second=10000;
    }
  }
  cout << cnt << endl;

  return 0;
}


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

// GCD, LCM
// https://youtu.be/8lm8o8L9Bmw?t=2285
// https://youtu.be/XI8exXVxZ-Q?t=3595
// https://youtu.be/F2p_e6iKxnk?t=843
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { 
    if(a==1 || b==1){
        return max(a,b);
    }
    return a/gcd(a,b)*b;
}

void solve(long long N, long long M, std::vector<long long> a){
    ll num = a[0]/2;
    
    for(int i=0;i<N;i++){
        // cerr <<"i="<<i <<endl;
        ll t = a[i];
        t/=2;
        ll old = num;
        
        num = lcm(num,t);
        
        // cerr <<"num=" << num <<"old="<<old <<"t="<<t<<endl;
        (num/old)%2;
        
        if(num>M){
            cout << 0<<endl;
            return;
        }
        // cerr <<"p" << endl;
        // cerr <<num/t <<endl;
        if((num/t)%2==0|| (num/old) %2 ==0 ){
            cout << 0 <<endl;
            return;
        }

    }
    
    cout <<  1 + (M-num)/(2*num) << endl;

}

// 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 N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, M, std::move(a));
    return 0;
}


Measured memory_bytes: 1024