akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

class Edge {
  public:
    int from;
    int to;
    int cost;
    Edge() {
    }
    Edge(int _from, int _to, int _cost) {
      from = _from;
      to = _to;
      cost = _cost;
    }
};

int main()
{
  int nnode, nedge;
  cin >> nnode >> nedge;
  vector<Edge> edge(nedge);
  for (int i = 0; i < nedge; i++) {
    cin >> edge.at(i).from >> edge.at(i).to >> edge.at(i).cost;
  }
  vector<vector<long long>> cost(nnode, vector<long long>(nnode, 1e18));
  for (int i = 0; i < nnode; i++) {
    cost.at(i).at(i) = 0;
  }
  for (const auto& e : edge) {
    cost.at(e.from).at(e.to) = e.cost;
  }

  // Floyd-Warshall
  for (int k = 0; k < nnode; k++) {
    for (int i = 0; i < nnode; i++) {
      for (int j = 0; j < nnode; j++) {
        if (cost.at(i).at(k) + cost.at(k).at(j) < cost.at(i).at(j)) {
          cost.at(i).at(j) = cost.at(i).at(k) + cost.at(k).at(j);
        }
      }
    }
  }

  // negative cycle detection
  // If distance of any vertex from itself becomes negative,
  // there is a negative weight cycle.
  for (int i = 0; i < nnode; i++) {
    if (cost.at(i).at(i) < 0) {
      cout << "NEGATIVE CYCLE\n";
      return 0;
    }
  }

  for (int x = 0; x < nnode; x++) {
    if (1e10 < cost.at(x).at(0)) {
      cout << "INF";
    } else {
      cout << cost.at(x).at(0);
    }
    for (int y = 1; y < nnode; y++) {
      cout << ' ';
      if (1e10 < cost.at(x).at(y)) {
        cout << "INF";
      } else {
        cout << cost.at(x).at(y);
      }
    }
    cout << '\n';
  }

  return 0;
}



Measured memory_bytes: 3264
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int a, b, c, x, y; readV(a, b, c, x, y);

  auto ans = 10^^9;
  foreach (nc; 0..2*max(x,y)+1) {
    auto na = max(0, x-nc/2), nb = max(0, y-nc/2);
    ans = min(ans, na*a+nb*b+nc*c);
  }
  writeln(ans);
}


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

int main() {
  string s;
  cin >> s;
  cout << s.find_last_of("Z") - s.find_first_of("A") + 1 << endl;
  return 0;
}

Measured memory_bytes: 640
def bubble_sort(A):
    count = 0
    flag = True
    while flag:
        flag = False
        for j in reversed(range(1, len(A))):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                flag = True
                count += 1
    return A, count

if __name__ == '__main__':
    n = int(input())
    array, count = bubble_sort(list(map(int, input().split())))
    print(' '.join(map(str, array)))
    print(count)

Measured memory_bytes: 6724
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 17;
char dn[dm], * di = dn;

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


	int N = getint(), K = getint(), Q = getint();

	int P[100001];
	rep1(i, N) {
		P[i] = K - Q;
	}
	rep(i, Q) {
		P[getint()]++;
	}
	rep1(i, N) {
		if (P[i] > 0) {
			*di++ = 'Y';
			*di++ = 'e';
			*di++ = 's';
			*di++ = '\n';
		}
		else {
			*di++ = 'N';
			*di++ = 'o';
			*di++ = '\n';
		}
		if (i % 25000 == 0) {
			fwrite(dn, 1, di - dn, stdout);
			di = dn;
		}
	}
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 1152
#include<iostream>
using namespace std;
#include<iomanip>
#include<cmath>

#define MAX 5000

void show(double* x, double* y, int size)
{
    int i;
    cout << fixed << setprecision(10);
    for(i = 0; i < size; i++){
        cout << x[i] << " " << y[i] << endl;
    }
}

void Kochcurve(double* x, double* y, int left, int right)
{
    int d = (right - left) / 4;
    if(d < 1) return;

    int m;
    double x1, x2, y1, y2;

    m = (left + right) / 2;
    x1 = x[left]; x2 = x[right];
    y1 = y[left]; y2 = y[right];

    x[left + d] = (2 * x1 + x2) / 3;
    y[left + d] = (2 * y1 + y2) / 3;

    x[m] = (x1 + x2) / 2 - (y2 - y1) * sqrt(3 * 1.0) / 6;
    y[m] = (y1 + y2) / 2 + (x2 - x1) * sqrt(3 * 1.0) / 6;
 
    x[right - d] = (x1 + 2 * x2) / 3;
    y[right - d] = (y1 + 2 * y2) / 3;

    Kochcurve(x, y, left, left + d);
    Kochcurve(x, y, left + d, m);
    Kochcurve(x, y, m, right - d);
    Kochcurve(x, y, right - d, right);

    return;
}

int main()
{
    double x[MAX], y[MAX];
    int i, n, R;
    cin >> n;
    R = 1;
    for(i = 0; i < n; i++) R = R * 4;

    x[0] = 0;
    y[0] = 0;
    x[R] = 100 * 1.0;
    y[R] = 0;

    Kochcurve(x, y, 0, R);

    show(x, y, R + 1);

    return 0;
}

Measured memory_bytes: 1316
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = iss()
    print(sum(S[n:n+3] == 'ABC' for n in range(N-2)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 100005;

int n, a[MAXN], b[MAXN], c[MAXN];
ll ans, cnt[MAXN];

inline void read( int &x ){
	char ch;
	while( ch = (char)getchar(), ( ch < '0' || ch > '9' ) );
	x = ch - '0';
	while( ch = (char)getchar(), ( ch >= '0' && ch <= '9' ) ) x = x * 10 + ch - '0';
}

int main(){
	read(n);
	for( int i = 1; i <= n; ++i ) read(a[i]);
	sort( a + 1, a + n + 1 );
	for( int i = 1; i <= n; ++i ) read(b[i]);
	sort( b + 1, b + n + 1 );
	for( int i = 1; i <= n; ++i ) read(c[i]);
	sort( c + 1, c + n + 1) ;
	for( int i = n; i >= 1; --i){
		cnt[i] = c + n + 1 - upper_bound( c + 1, c + n + 1, b[i] );
		cnt[i] += cnt[i+1];
		// printf( "%lld\n", cnt[i]);
	}
	for( int i = 1; i <= n; ++i ){
		int j = (int)( upper_bound( b + 1, b + n + 1, a[i] ) - b );
		// printf( "J : %d\n", j);
		ans += cnt[j];
	}
	printf( "%lld\n", ans );
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a; i ++)
int main(void){
  int sum = 0;
  rep(i,5){
    int in;
    cin>>in;
    if(in<=40)sum += 40;
    else sum += in;
  }
  cout<<sum / 5 << endl;
  return 0;
}

Measured memory_bytes: 1160
// Problem : I - Coins
// Contest : Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_i
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

import java.io.*;
import java.util.*;

public class Main{
	
	public static void main(String[] args) throws Exception {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		//PrintWriter out = new PrintWriter("file.out");
		Task solver = new Task();
		//int t = scan.nextInt();
		int t = 1;
		for(int i = 1; i <= t; i++) solver.solve(i, scan, out);
		out.close();
	}

	static class Task {
		static final int inf = Integer.MAX_VALUE;
		public void solve(int testNumber, FastReader sc, PrintWriter pw) {
			double[][] dp = new double[3002][3002];
			int n = sc.nextInt();
			double[] arr= new double[n];
			for(int i=0;i<n;i++){
				arr[i]=sc.nextDouble();
			}
			dp[1][0]=1-arr[0];
			dp[1][1]=arr[0];
			for(int i = 2;i <= n;i++){
				for(int j = 0;j <= i;j++){
					if(j == 0){
						dp[i][j] = dp[i-1][j] * (1-arr[i-1]);
					}
					else{
						dp[i][j] = dp[i-1][j] * (1-arr[i-1]) + dp[i-1][j-1] * arr[i-1];
					}
				}
			}
			double ans = 0;
			for(int i=n/2+1;i<=n;i++){
				ans+=dp[n][i];
			}
			pw.println(ans);
		}
	}
	long binpow(long a, long b, long m) {
		a %= m;
		long res = 1;
		while (b > 0) {
			if ((b & 1) == 1)
				res = res * a % m;
			a = a * a % m;
			b >>= 1;
		}
		return res;
	}
	static class tup implements Comparable<tup>{
		int a, b;
		tup(int a,int b){
			this.a=a;
			this.b=b;
		}
		@Override
		public int compareTo(tup o){
			return Integer.compare(o.b,b);
		}
	}
	static void shuffle(int[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}

	static void shuffle(long[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}

Measured memory_bytes: 129216
#include<bits/stdc++.h>
#include<algorithm>
#define M 10000000007
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define L long long
#define endl '\n'
using namespace std;

int main(){
    int d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#!/usr/bin/env python3
import sys
from collections import Counter


def solve(S: str):
    tmp = []
    i = 0
    while i < len(S):
        j = i+1
        if S[i: i+3] == 'ABC':
            j = i
            while True:
                if S[j:j+3] == 'ABC':
                    j += 3
                elif S[j:j+2] == 'BC':
                    j += 2
                else:
                    break
            jl = i
            while jl >= 0:
                if S[jl] != 'A':
                    break
                jl -= 1
            jl += 1


            if len(tmp)>0 and tmp[-1][1] == jl:
                tmp[-1][0] += S[jl: j]
                tmp[-1][1] = j
            else:
                tmp.append([S[jl: j], j])

        i = j
    ans = 0
    for elem, _ in tmp:
        cnt_a = Counter(elem)['A']
        for i in range(len(elem)):
            if elem[i] == 'A':
                cnt_a -= 1
                ans += (len(elem)-1-i-cnt_a)//2
                assert (len(elem)-1-i-cnt_a)%2==0

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)

if __name__ == '__main__':
    main()


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

int main(void){
    long long l, r;
    cin >> l >> r;

    int mod_min = 2018;

    r = min(r, l + 2019);

    for(long long i = l; i < r; i++){
        for(long long j = i + 1; j <= r; j++){
            int mod = (i * j) % 2019;

            mod_min = min(mod_min, mod);
        }
    }

    printf("%d\n",mod_min);
    return 0;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
//TOP BOTTOM 

public class Main{
	static int[] v, w;
	static int n, s; // Length el elements w hgm l shanta ele m3ak
	static long dp[][];

	public static long dp(int idx, int rem) {
		if (rem < 0) {
			return -(int) 1e9; // infinty value
		}
		if (idx == n) {
			return 0;
		}
		if (dp[idx][rem] != -1) {
			return dp[idx][rem];
		}

		long take = v[idx] + dp(idx + 1, rem - w[idx]);
		long leave = dp(idx + 1, rem);
		return dp[idx][rem] = Math.max(take, leave); // Da keda mn gher dp da tkrar tbe3e gddn !

	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		n = sc.nextInt();
		s = sc.nextInt();

		w = new int[n];
		v = new int[n];

		for (int i = 0; i < w.length; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();

		}

		dp = new long[n][s + 1]; // tagnab l outof range
		for (long[] x : dp) {
			Arrays.fill(x, -1);
		}
		pw.println(dp(0, s));
		pw.close();

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}


Measured memory_bytes: 131176
def dfs(c,lst):
 n=len(lst)
 ans=[0]*n
 stack = [c-1]
 check = [0]*n #チェック済みリスト
 while stack != [] :
  d=stack.pop()
  if check[d]==0:
   check[d]=1
   for i in lst[d]:
    if check[i]==0:
     stack.append(i)
     ans[i]=ans[d]+1
 return(ans)
import sys
input = sys.stdin.readline
N,u,v=map(int,input().split())
ki=[[] for f in range(N)]
for i in range(N-1):
 a,b = map(int,input().split())
 ki[a-1].append(b-1)
 ki[b-1].append(a-1)
U=dfs(u,ki)
V=dfs(v,ki)
ans=0
for i in range(N):
 if V[i]>U[i]:
  ans=max(ans,V[i]-1)
print(ans)


Measured memory_bytes: 29856
# include <bits/stdc++.h>
# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define in freopen("input.txt", "r", stdin)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
  
using namespace std;
  
const ll INF = 1e18;
const int mod = 1e9 + 7;
const ll N = 1e5 + 7;

ll n, W, v[N], w[N], dp[200][N];
   
int main()
{   
    cin >> n >> W;
    fore( i, 1, n + 1 ) {
        cin >> w[i] >> v[i];
    }
    fore( i, 1, n + 1 ) {
        forn( j, W + 1 ) {
            dp[i][j] = dp[i - 1][j];
            if ( j >= w[i] ){
                dp[i][j] = max( dp[i][j], dp[i - 1][ j -  w[i] ] + v[i] );
            }
        }
    }
    cout << dp[n][W];
    time;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
   int counter = 0;
  for (;A < B + 1; A++) {
    int s1 = A % 10;
    int s2 = A % 100 / 10;
    int s3 = A % 1000 / 100;
    int s4 = A % 10000 / 1000;
    int s5 = A / 10000;
    
    if (s1 == s5 && s2 == s4) 
      counter++;
    else if (s5 == 0 && s1 == s4 && s2 == s3)
      counter++;
    else if (s5 == 0 && s4 == 0 && s1 == s3)
      counter++;
  }
  
  cout << counter << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll func(ll a,ll b,ll& ans_x,ll& ans_y){
    if(b == 0){
        ans_x = 1;
        ans_y = 0;
        return a;
    }else{
        ll ret = func(b,(a%b),ans_y,ans_x);
        ans_y -= (a/b)*ans_x;
        return ret;
    }
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

ll dp[50010];

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

    ll n,ans=0,t=-INF;
    cin>>n;
    pair<ll,ll> itv[n];
    rep(i,n){
        ll x,l;
        cin>>x>>l;
        itv[i].first=x+l;
        itv[i].second=x-l;
    }
    sort(itv,itv+n);
    
    rep(i,n){
        if(t<=itv[i].second){
            ans++;
            t=itv[i].first;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int ans;
int arr[3]={3,5,7};

bool func(int data){
	string s;
	while(data){
		s=s+(char)(data%10+'0');
		data/=10;
	}
	if(s.find('3')!=string::npos&&s.find('5')!=string::npos&&s.find('7')!=string::npos){
		return true;
	}
	return false;
}

void BFS(int t){
	if(t<357){
		ans=0;
		return;
	}
	queue<int> myque;
	myque.push(0);
	while(!myque.empty()){
		int acc=myque.front();
		if(acc>t||acc>77777777){
			return;
		}
		myque.pop();
		for(int i=0;i<3;i++){
			int temp=acc*10+arr[i];
			if(temp>t){
				break;
			}
			if(func(temp)){
				ans++;
			}
			myque.push(temp);
		}
	}
}

int main(){
	int t;
	cin>>t;
	ans=0;
	BFS(t);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		// 計算
		int result = 0;
		HashSet<Integer> hs = new HashSet<Integer>();
		hs.add(a);
		hs.add(b);
		hs.add(c);
		result = hs.size();
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {

	int N, X;
	cin >> N >> X;

	int all = 0;
	int v;
	vector<int> vec;
	for (int i = 0; i < N; i++) {
		cin >> v;
		vec.push_back(v);
		all += v;
	}

	int rest = X - all;

	decltype(vec)::iterator it = min_element(vec.begin(), vec.end());
	int min_item = *it;

	int num = N + rest / min_item;

	cout << num << endl;

	return 0;
}



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


int main(){
    int n; cin >> n;
    int free=0;
    set<string> colors;
    for (int i=0; i<n; i++){
        int rate; cin >> rate;
        if(rate<400) colors.insert("grey");
        else if(rate<800) colors.insert("brown");
        else if(rate<1200) colors.insert("green");
        else if(rate<1600) colors.insert("sky");
        else if(rate<2000) colors.insert("blue");
        else if(rate<2400) colors.insert("yellow");
        else if(rate<2800) colors.insert("orange");
        else if(rate<3200) colors.insert("red");
        else{
            free += 1;
        }
    }
    int g = colors.size();
    int minimum, maximum;
    if(g==0){
        minimum = 1;
        maximum = free;
    }
    else{
        minimum = g;
        maximum = g+free;
    }
    cout << minimum << ' ' << maximum << endl;
}

Measured memory_bytes: 3580
# C = -10
# C = -4

# B = [1, 2, 3]
# B = [-2, 5]

# A = [[3, 2, 1], [1, 2, 2]]
# A = [[100, 41], [100, 40], [-3, 0], [-6, -2], [18, -13]]

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [[int(i) for i in input().split()] for i in range(N)]

cnt = 0
for aa in A:
    sum = 0
    for i, a in enumerate(aa):
        sum += B[i] * a

    # print(sum, sum + C)

    if sum + C > 0:
        cnt += 1

print(cnt)


Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
mt = [0] * N
t = 0
for i, a in enumerate(A):
    if i % 2 == 0:
        t += a
    else:
        t -= a
mt[0] = t
for i in range(1, N):
    mt[i] = 2 * A[i - 1] - mt[i - 1]
print(*mt)

Measured memory_bytes: 14092
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
#define YMAX 250001
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int H,W;
	char a[101][101];
	int count[26]={0};
	int countmod[4]={0};
	scan(H);scan(W);
	rep(i,H){
		scan(a[i]);
		rep(j,W){
			count[a[i][j]-'a']++;
		}
	}
	int flag=1;
	rep(i,26){
		countmod[count[i]%4]++;
	}
	if(H%2==0&&W%2==0){
		if(countmod[0]==26) flag=1;
		else flag=0;
	}
	else if(H%2==0){
		if(countmod[1]+countmod[3]>0) flag=0;
		else if(countmod[2]<=H/2) flag=1;
		else flag=0;
	}
	else if(W%2==0){
		if(countmod[1]+countmod[3]>0) flag=0;
		else if(countmod[2]<=W/2) flag=1;
		else flag=0;
	}
	else{
		if(countmod[1]+countmod[3]==1){
			if(countmod[1]==1) countmod[0]++;
			else countmod[2]++;
			if((H-1)/2+(W-1)/2>=countmod[2]) flag=1;
			else flag=0;
		}
		else{
			flag=0;
		}
	}
	if(flag) prin("Yes");
	else prin("No");
	return 0;
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;
map<ll, ll> mp;

int main(){
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 != m2) {
        cout << "1" << endl;
    } else {
        cout << "0" << endl;
    }



    return 0;
}


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

void myprint(vector<int> &a) {
  for (auto it = a.begin(); it != a.end(); ++it) {
    if (it != a.begin()) {
      cout << " ";
    }
    cout << *it;
  }
  cout << endl;
}

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

  vector<int> a;
  for (int i = 0; i < N; ++i) {
    int t;
    cin >> t;
    a.push_back(t);
  }

  int counter = 0;
  for (int i = 0; i < N; ++i) {
    int m = i;
    for (int j = i; j < N; ++j) {
      if (a[j] < a[m]) {
        m = j;
      }
    }
    if (i != m) {
      int t = a[i];
      a[i] = a[m];
      a[m] = t;
      ++counter;
    }
  }

  myprint(a);
  cout << counter << endl;

  return 0;
}

Measured memory_bytes: 3144
N = int(input())
l = [list(map(int,input().split())) for _ in [0]*N]

dp_a = [0]*N
dp_b = [0]*N
dp_c = [0]*N
dp_a[0] = l[0][0]
dp_b[0] = l[0][1]
dp_c[0] = l[0][2]

for i in range(1,N):
    dp_a[i] = max(dp_b[i-1],dp_c[i-1])+l[i][0]
    dp_b[i] = max(dp_a[i-1],dp_c[i-1])+l[i][1]
    dp_c[i] = max(dp_b[i-1],dp_a[i-1])+l[i][2]

print(max(dp_a[-1],dp_b[-1],dp_c[-1]))

Measured memory_bytes: 42468
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
  int N,K;
  vector<int> vec(51);
  cin >> N >> K;
  for(int i = 0;i < N;i++) cin >> vec[i];
  sort(vec.rbegin(),vec.rend());
  int length=0;
  for(int i = 0;i < K;i++){
    length += vec[i];
  }
  cout << length << endl;
}


Measured memory_bytes: 256
S=raw_input()
N=len(S)
mod=10**9+7

num=[ [ 0 for i in range(4) ] for j in range(N) ]		# i=0 A, i=1 B, i=2 C, i=3 ?

for i in range(N):
	if i==0:
		if S[i]=="A":  num[i][0]=1
		elif S[i]=="B":  num[i][1]=1		
		elif S[i]=="C":  num[i][2]=1
		elif S[i]=="?":  num[i][3]=1
	else:
		for j in range(4):
			num[i][j]=num[i-1][j]
			
		if S[i]=="A":  num[i][0]+=1
		elif S[i]=="B":  num[i][1]+=1		
		elif S[i]=="C":  num[i][2]+=1
		elif S[i]=="?":  num[i][3]+=1		

ans=0

for i in range(1,N):
	if S[i]=="B" or S[i]=="?":
		a=num[i-1][0]
		c=num[N-1][2]-num[i][2]
		ql=num[i-1][3]
		qr=num[N-1][3]-num[i][3]

		#ABC
		ans+=a*pow(3,ql,mod)*c*pow(3,qr,mod)

		#AB?
		if qr>0:
			ans+=a*pow(3,ql,mod)*pow(3,(qr-1),mod )*qr

		#?BC
		if ql>0:
			ans+=pow(3,(ql-1),mod )*ql*c*pow(3,qr,mod)

		#?B?
		if ql>0 and qr>0:
			ans+=pow(3,(ql-1),mod )*ql*pow(3,(qr-1),mod )*qr

print ans%mod



Measured memory_bytes: 49948
#include<stdio.h>
#include<stdlib.h>

int count = 0;

int countt(int num);

int main() {
        int N;
        int max = 0, num = 1, i;

        scanf("%d", &N);

        for(i = 0; i <= N; i++) {
                count = 0;
                countt(i);
                if(max < count) {
                        max = count;
                        num = i;
                }
        }

        printf("%d", num);

        return 0;

}

int countt(int num) {
        if((num % 2 == 0) && (num != 0)) {
                count++;
                countt(num / 2);
                return 0;
        }
        else
                return -1;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll X;
  cin >> X;
  cout << 10-X/200 << endl;
  
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) begin(n),end(n)

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

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int x, y;
	cin >> x >> y;
	const int tbl[] = {0,1,2,1,3,1,3,1,1,3,1,3,1};
	cout << (tbl[x] == tbl[y] ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
#define erase(s) s.erase(s.end()-1) //文字列sの末尾削除
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
string RLE(string s){
  ll n=s.size();
  char now='.';
  ll count=1;
  string press;
  loop(i,n){
    if(s[i]!=now){
      if(i){
        press+=now;
        press+=to_string(count);
      }
      now=s[i];
      count=1;
      continue;
    }
    else count++;
  }
  press+=now;
  press+=to_string(count);
  return press;
}
int main() {
  cout << fixed << setprecision(30);
  string s;
  cin>>s;
  ll q;
  cin>>q;
  string cf="",ce="";
  ll revcount=0;
  loop(i,q){
    ll a;
    cin>>a;
    if(a==1)revcount++;
    else{
      ll b;
      cin>>b;
      string w;
      cin>>w;
      if((revcount+b)%2==0){
        ce+=w;
      }
      else{
        cf+=w;
      }
    }
  }
  reverse(all(cf));
  s=cf+s+ce;
  if(revcount%2==1){
    reverse(all(s));
  }
  putout(s);
}


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

typedef long long ll;
const int MAX_N = 100030;    // Change as necessary

int A[20][MAX_N];
int x[MAX_N];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n;
  for(int i=0;i<n;i++)
    cin >> x[i];
  int L,Q; cin >> L >> Q;
  
  x[n] = x[n-1]+1;
  n++;
  
  for(int i=0;i<n;i++)
    A[0][i] = upper_bound(x,x+n,x[i]+L)-x-1;
  
  for(int j=1;j<20;j++)
    for(int i=0;i<n;i++)
      A[j][i] = A[j-1][A[j-1][i]];

  while(Q--){
    int a,b; cin >> a >> b; a--; b--;
    if(a > b) swap(a,b);
    
    int ans = 0;
    for(int i=19;i>=0 && a < b;i--)
      if(A[i][a] <= b){
        a = A[i][a];
        ans += (1 << i);
      }
    if(a < b)
      ans++;
    cout << ans << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 9088
#include <iostream>

using namespace std;

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

  // cout << "行数: " << n << endl;

  int r;
  int minv;
  int maxv;
  
  cin >> minv;
  cin >> r;
  maxv = r - minv;
  
  if(r < minv) {
    minv = r;
  }
  
  for(int i = 0; i < n-2; i++){
    cin >> r;
    // cout << r << endl;

    if(maxv < r - minv) {
      maxv = r - minv;
    }

    if(r < minv) {
      minv = r;
    }
  }

  // cout << "minv: " << minv << endl;
  // cout << "maxv: " << maxv << endl;
  cout << maxv << endl;
  
  return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    if(a%2 == b%2) {
        out((b-a)/2);
    }
    else {
        if(a-1 <= n-b) {
            out(a + (b-a-1)/2);
        }
        else {
            ll x = n-b+1;
            out(x + (n - (a+x))/2);
        }
    }
    
    re0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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 dy[4] = {-1, 0, 1, 0},dx[4] = {0, 1, 0, -1};

int h,w;
string G[21];

int bfs(int s,int t){
  int rec = -12345;
	vector<vector<int>> dist(h,vector<int>(w,-1));
  queue<pii> q;
  q.push({s,t});
  dist[s][t] = 0;
  while (!q.empty()) {
    pii now = q.front();
    q.pop();
    int nowx = now.fi, nowy = now.se;
		rep(i,4){
			int nx=nowx+dx[i],ny=nowy+dy[i];
			if(nx<0 || nx>=h || ny<0 || ny>=w) continue;
			if(dist[nx][ny]!=-1 || G[nx][ny]=='#')continue;
			dist[nx][ny]=dist[nowx][nowy]+1;
			q.push({nx,ny});
		}
  }
  rep(i, h) rep(j, w) chmax(rec, dist[i][j]);
  return rec;
}

int main(int argc, char const *argv[]) {
	cin >> h >> w;
	rep(i,h) cin >> G[i];
	int ans = -1234;
	rep(i,h)rep(j,w){
    if (G[i][j] == '#') continue;
    chmax(ans, bfs(i, j));
  }
	cout << ans << endl;
  return 0;
}

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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353
const int INF = 1 << 28;



int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;
    int num = 0;
    rep(i, N - 1) {
        if (S[i] != S[i + 1]) num++;
    }
    cout << min(N - 1, N - 1 - num + 2 * K) << endl;

}


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

int main()
{
  int N;
  cin >> N;
  vector<pair<int,int>> students(N);
  for(int i=0; i<N; i++){
    int Ai;
    cin >> Ai;
    students[i] = {i+1,Ai};
  }
  sort(students.begin(), students.end(), [](auto const& left, auto const& right){
    return left.second < right.second;
  });
  for(auto& p: students) cout << p.first << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 1536
fun main() {
    var s = readString()

    println(s.replace("?", "D"))
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

Measured memory_bytes: 58836
#include<stdio.h>

int main()
{
	long long A,B,K;
    while(scanf("%lld%lld%lld",&A,&B,&K)!=EOF)
	{
		if(A>=K)
        printf("%lld %lld\n",A-K,B);
		else
		{
		    if(B>=(K-A))
			printf("%lld %lld\n",0,B-K+A);
			else
		    printf("0 0\n");
			
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    vector<int> C(N);
    long long total = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
        C[i] = A[i] - B[i];
        if (A[i] < B[i]) {
            total += B[i] - A[i];
            ans++;
        }
    }
    sort(C.rbegin(), C.rend());
    for (int i = 0; i < N; ++i) {
        if (total <= 0) {
            break;
        }
        if (C[i] <= 0) {
            cout << -1 << endl;
            return 0;
        }
        total-=C[i];
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P	  = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	int n;
	cin >> n;
	vector<ll> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			sum += d[i] * d[j];
		}
	}
	dump(sum);
	return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)

ls_S = list(S)
rv_S = ls_S.copy()
rv_S.reverse()
# print(ls_S, rv_S)
comment = False

if ls_S == rv_S:
    Sf = ls_S[0:int((N-1)/2)]
    Sf_rv = Sf.copy()
    Sf_rv.reverse()
    if Sf_rv == Sf:
        Sb = ls_S[int((N+3)/2 - 1):]
        Sb_rv = Sf.copy()
        Sb_rv.reverse()
        if Sb_rv == Sb:
            comment = True

if comment:
    print('Yes')
else:
    print('No')


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

using namespace std;

const int Nmax = 1e5 + 5;
int i, dp[1<<15], j, x, y, z, n, m, xr, val[Nmax], cnt[20], ans;
vector<int> v;

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n;
    for(i=1; i<n; ++i)
    {
        cin >> x >> y >> z;
        val[x] ^= z; val[y] ^= z;
    }

    for(i=0; i<n; ++i) cnt[val[i]]++;
    ans = cnt[0];
    for(i=1; i<=15; ++i)
    {
        ans += cnt[i] / 2;
        if(cnt[i] & 1) v.push_back(i);
    }

    m = v.size();
    if(m)
    {
        for(i=0; i<(1<<m); ++i)
        {
            xr = 0;
            for(j=0; j<m; ++j)
                if(i&(1<<j)) xr ^= v[j];

            if(!xr) dp[i] = 1;
                else
                {
                    dp[i] = -1e9;
                    continue;
                }

            for(j=i&(i-1); j; j = i&(j-1))
                dp[i] = max(dp[i], dp[j] + dp[i^j]);
        }
        ans += dp[i-1];
    }

    ans = n - ans;
    cout << ans << '\n';;

    return 0;
}


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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define pb push_back


// string size = str.size()

// stack <int> s; 
// queue <int> gquiz; 
// __gcd(m, n) 

// ll arr[10e5 + 5];
// char arr[10e5 + 5];


bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}


int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string str;
    cin >> str;
    ll flag = 0;
    ll len = str.size();
    for (ll i = 0, j = len-1; i<(len/2); i++,j--)
    {
        if(str[i] != str[j])
        {
            flag = 1;
            break;
        }
    }
    if(flag == 1)
    {
        cout << "No" << endl;
    }
    else
    {
        ll flag1 = 0,flag2 = 0;
        for(ll i = 0,j = (len/2) - 1; i < ((len/2) / 2); i++,j--)
        {
                // cout << i << " " << j << endl;

            if(str[i] != str[j])
            {
                flag1 = 1;
                break;
            }
        }
        if(flag1 == 1)
        {
            cout << "No" << endl;;
        }
        else
        {
            for(ll i = (len/2) + 1, j = len - 1 ; i < ((len/2 + 2) + (len+1))/2 ;i++,j--)   
            {
                // cout << i << " " << j << endl;
                if(str[i] != str[j])
                {
                    flag2 = 1;
                    break;
                }
            }
             if(flag2 == 1)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
        }
       
    }
    return 0;
}   

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

#define roop(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

	ll int N;
	cin >> N;
	ll int A;
	map<long long int,int> m;
	roop(i,N){
	cin >> A;
	if(m[A] == 1){
	cout << "NO";
	return 0;
	}
	else{
		m[A]=1;
	}
	}
	cout << "YES";









	return 0;

}



Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

int gcd(int x, int y) {
    int r;
    if(x < y) swap(x, y);

    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

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

    int a, b;
    int maxi = 0;
    rep(i,n){
        if(i == 0) cin >> a;
        else{
            cin >> b;
            a = gcd(a,b);
        }
        maxi = max(maxi, max(a,b));
    }
    cout << (k % a == 0 && k <= maxi ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 256
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) sort(a.rbegin(),a.rend())
#define Sort(a) sort(a.begin(),a.end())

int main(int argc, const char * argv[]) {

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

	LL N, M;
	LL sum = 0;

	cin >> N >> M;

	vector<LL>X((UI)M);

	for (UI i = 0; i < M; i++) {
		cin >> X.at(i);
	}

	Sort(X);
	vector<LL>Y;

	for (UI i = 0; i + 1 < X.size(); i++){
		Y.push_back(X[i + 1] - X[i]);
	}

	rSort(Y);

	for (UI i = 0; i < N - 1 && i < Y.size(); i++) {
		sum += Y[i];
	}

	cout << X.back() - X.front() - sum << endl;

	return 0;

}

Measured memory_bytes: 2168
main :: IO ()
main = do
  s <- getLine
  putStrLn $ if solve s
             then "Yes"
             else "No"

solve s = s == map f (reverse s)
  where
    f 'b' = 'd'
    f 'd' = 'b'
    f 'p' = 'q'
    f 'q' = 'p'
    f a   = a


Measured memory_bytes: 8572