akhauriyash/Code-Regression huggingface dataset:
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

#define in std::cin
#define out std::cout

int32_t N;
std::vector<int32_t> graph[100000];//木
int32_t need[100000] = {};
bool ans = true;
//@return 頂点iから上に流す量
int32_t dfs(int i, int p)
{
	if (graph[i].size() == 1) {
		return need[i];
	}

	int32_t child_total = 0;
	for (auto& c : graph[i]) {
		if (c != p) {
			auto add = dfs(c, i);
			if (add > need[i]) {
				ans = false;
				return 0;
			}
			child_total += add;
		}
	}

	int32_t up = need[i]*2 - child_total;
	if (up < 0 || need[i] < up) {
		ans = false;
		return 0;
	}
	return up;
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N;
	for (int32_t i = 0; i < N; ++i)
	{
		in >> need[i];
	}
	for (int32_t i = 0; i < N-1; ++i)
	{
		int a, b;
		in >> a >> b; --a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	if (N == 2) {
		ans = (need[0] == need[1]);
	}
	else {
		for (int32_t i = 0; i < N; ++i)
		{
			if (graph[i].size() != 1) {
				if (dfs(i, i) != 0) {
					ans = false;
				}
				break;
			}
		}
	}
	out << ((ans) ? ("YES") : ("NO")) << endl;
	return 0;
}
#endif


Measured memory_bytes: 10112
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int> v;
int gcd(int a,int b)
{
    if(a<b)return gcd(b, a);
    int r;
    while((r=a%b)) { a = b;b = r;}
    return b;
}

int comm(int a,int b)
{
    int n=gcd(a,b);
    int result=0,flag=1,cnt=0;
    if(n%2==0){cnt++;while(n%2==0)n=n/2;}
    for(int i=3;i<=sqrt(n);i=i+2)
    {
        if(n%i==0){cnt++;while(n%i==0)n=n/i;}
    }
    if(n>2)cnt++;
    return cnt;

}
main()
{
	int a,b;
	vector<int> v;
	cin>>a>>b;
	cout<<comm(a,b)+1;
}


Measured memory_bytes: 256
S = input()
N = len(S)
L = list(S)
left_idx = 0
right_idx = N - 1
ret = 0
while left_idx < right_idx:
    l = S[left_idx]
    r = S[right_idx]
    if l == r:
        left_idx += 1
        right_idx -= 1
    elif l == "x":
        ret += 1
        left_idx += 1
    elif r == "x":
        ret += 1
        right_idx -= 1
    else:
        ret = -1
        break

print(ret)


Measured memory_bytes: 4084
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	auto V=vecin(3);
	sort(ALL(V));
	out(V[0],V[1],V[2]);
	
	return 0;
}



Measured memory_bytes: 3196
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  vector<ll> v;
  ll total = 0;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
    total += a;
  }
  vector<ll> v1;
  rep(i,0,n){
    v1.pb(v[i]);
  } 
  rep(i,0,n){
    v1.pb(v[i]);
  }
  if(total%(n*(n+1)/2)!=0){
    cout << "NO" << endl;
    return 0;
  }
  ll b = total/(n*(n+1)/2);
  ll d[100010];
  rep(i,0,n){
    d[i] = v1[i+1]-v1[i]-b;
  }
  rep(i,0,n){
    if(d[i]>0||(-d[i])%n!=0){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
 

Measured memory_bytes: 3440
#include<stdio.h>
int main(){
  int n,a[100],i;
  scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d",&a[n-i-1]);
    }
    printf("%d",a[0]);
    for(i=1;i<n;i++){
      printf(" %d",a[i]);
    }
    printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include "stdio.h"

int main(void)
{
	int i,j,n;
	int sum;
	char num[1000];

	while(1)
	{
		sum = 0;
		for(i = 0; ; i++)
		{
			scanf("%c", &num[i]);
			if (num[i] == '\n')
			{
				n = i;
				break;
			}
		}
		if (num[0] == '0')
		{
			break;
		}
		for(j = 0; j < i; j++)
		{
			sum += num[j] - '0';
		}
		printf("%d\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ld long double
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]

typedef vector< int > vi;
typedef vector<long long> lvi;
typedef vector< vector<int> > vvi;
typedef vector< vector<long long> > lvvi;
typedef pair< int,int > ii;
typedef pair< long long,long long > lii;
typedef vector<pair<int,int>> vii;
typedef vector<pair<long long,long long>> lvii;
typedef vector<vector<pair<int,int>>> vvii;
typedef vector<vector<pair<long long,long long>>> lvvii;
typedef vector<bool> vb;

// #ifdef ONLINE_JUDGE 
// #define endl '\n'
// #endif
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " is " << a << endl;
	err(++it, args...);
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
const long long mod = 1e9 + 7;
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

long long mos() { return 0LL; }
template<typename T, typename... Args>
T mos(T a, Args... args) { return ((a + mos(args...))%mod + mod)%mod; }

long long mop() { return 1LL; }
template<typename T, typename... Args>
T mop(T a, Args... args) { return (a*mop(args...))%mod; }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------



signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	ll h,w,m;
	cin>>h>>w>>m;
	map<ii,int> mp;
	map<int,int> X,Y;
	lvii ys;
	for (int i = 0; i < m; ++i)
	{
		ll x,y;
		cin>>x>>y;
		mp[{x,y}]=1;
		X[x]++;
		Y[y]++;
	}	
	for(auto [key,val]:Y)
	{
		ys.pb({val,key});
	}
	sort(all(ys),greater<lii>());
	ll ans=0;
	for(auto [x,nx]:X)
	{
		for(auto [ny,y]:ys)
		{
			if(mp[{x,y}]==0)
			{
				ans = max(ans,nx+ny);
				break;
			}
			else
			{
				ans = max(ans,nx+ny-1);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}	


// WA
// 1. overflow
// 2. re-initialize global variables for every test case.
// 3. edge cases like n=1

// Run time error
// 1. division by zero.
// 2. array bounds.

// TLE
// 1. uncomment that #define endl '\n' line

Measured memory_bytes: 73456
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int d = sc.nextInt();
		
		boolean[][] space = new boolean[n][m];
		for(int i = 0; i < n; i++) {
			String scan = sc.next();
			for(int j = 0; j < m; j++) {
				if(scan.charAt(j) =='.') {
					space[i][j] = true;
				}else {
					space[i][j] = false;
				}
			}
		}
		
		int ans = 0;
		
		for(int i = 0; i < n; i++) {
			for(int j =0; j <= m - d; j++) {
				boolean flag = true;
				for(int l = j; l < j + d; l++) {
					if(!space[i][l]) {
						flag = false;
						break;
					}
				}
				
				if(flag) {
					ans++;
				}
			}
		}
		
		for(int j = 0; j < m; j++) {
			for(int i =0; i <= n - d; i++) {
				boolean flag = true;
				for(int k = i; k < i + d; k++) {
					if(!space[k][j]) {
						flag = false;
						break;
					}
				}
				
				if(flag) {
					ans++;
				}
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 28280
#include<iostream>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>

using namespace std;

struct P{int c,r;};
struct State{
  int t,pos, remain;
  bool operator < (const State& st) const {
    if(t != st.t) return t > st.t;
    return pos > st.pos;
  }
};

const int MAX = 5001;
const int INF = (1<<25);
int T[MAX][MAX];
vector<int> Edge[MAX];
P price[MAX];
int N,K;

void input(){
  scanf("%d %d",&N,&K);
  for(int i = 0; i < N; i++) scanf("%d %d",&price[i].c, &price[i].r);
  for(int i = 0; i < K; i++){
    int a,b;
    scanf("%d %d",&a, &b);
    a--;b--;
    Edge[a].push_back(b);
    Edge[b].push_back(a);
  }
}

int solve(){
  memset(T, -1, sizeof(T));
  T[0][0] = 0;
  priority_queue<State> Q;
  Q.push((State){0,0,0});
  while(!Q.empty()){
    const State now = Q.top();
    Q.pop();
    
    if(now.t > T[now.pos][now.remain]) continue;
    
    if(now.pos == N-1) return now.t;
    if(now.remain > 0){
      for(int i = 0; i < (int)Edge[now.pos].size(); i++){
	State nex = now;
	nex.pos = Edge[now.pos][i];
	nex.remain--;
	
	if(T[nex.pos][nex.remain] == -1 || T[nex.pos][nex.remain] > nex.t){
	  T[nex.pos][nex.remain] = nex.t;
	  Q.push(nex);
	}
      }
    }
    
    if(T[now.pos][price[now.pos].r] == -1 || T[now.pos][price[now.pos].r] > now.t+price[now.pos].c){
      T[now.pos][price[now.pos].r] = now.t+price[now.pos].c;
      Q.push((State){now.t+price[now.pos].c, now.pos, price[now.pos].r});
    }
  }
  return INF;
}

int main(){
  
  input();
  printf("%d\n",solve());
  return 0;
}

Measured memory_bytes: 99388
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,k;
	int s1[100000+5],s2[100000+5];
	cin>>n>>m>>k;
	int min2=0x3f3f3f3f;
	for(int i=0;i<n;i++){
		
		cin>>s1[i];	
		if(s1[i]<min2) min2=s1[i];
	}
	int min3=0x3f3f3f3f;
	for(int i=0;i<m;i++){
		cin>>s2[i];
		if(s2[i]<min3) min3=s2[i];
	}
	int min1=min2+min3;
	for(int i=0;i<k;i++){
		int a,b,c;
		cin>>a>>b>>c;
		if(min1>s1[a-1]+s2[b-1]-c)min1=s1[a-1]+s2[b-1]-c;
	}
	
	
	cout<<min1;
	return 0;
} 

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (scanner.nextInt() >= k) {
                count++;
            }
        }
        System.out.println(count);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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


Measured memory_bytes: 29712
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
  int data1, data2;
  int num, sq;
  int i;
  scanf("%d %d", &data1, &data2);

  if( data2 < 10) num = data1*10+data2;
  else if( data2 < 100) num=data1*100+data2;
  else num=data1*1000+data2;

  sq = sqrt(num);

  if( num == (sq*sq) ) printf("Yes\n");
  else printf("No\n");
 
  return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int>v;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        v.push_back(t);
    }
    sort(v.begin(),v.end());
    double ans=((double)v[0]+(double)v[1])/2.0;
    for(int i=2;i<n;i++){
        ans=(ans+(double)v[i])/2.0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>

using namespace std;

int rot[6][4] = {{2, 4, 3, 1}, {2, 0, 3, 5}, {5, 4, 0, 1}, {0, 4, 5, 1}, {2, 5, 3, 0}, {3, 4, 2, 1}};

string board[30][6];

bool same(int a, int b)
{
	for (int i = 0; i < 6; i++){
		for (int j = 0; j < 6; j++){
			if (board[a][i] != board[b][j]) continue;
			for (int dx = 0; dx < 4; dx++){
				bool same = true;
				for (int k = 0; k < 4; k++){
					if (board[a][rot[i][(k + dx) % 4]] != board[b][rot[j][k]])
						same = false;
				}
				if (same) return (true);
			}
		}
	}
	return (false);
}

int main()
{
	int n;
	while (scanf("%d", &n) && n){
		int ct = 0;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < 6; j++){
				char tmp[64];
				scanf("%s", tmp);
				board[i][j] = tmp;
			}
			bool ok = true;
			for (int j = 0; j < i; j++) if (same(i, j)) ok = false;
			ct += ok;
		}
		
		printf("%d\n", n - ct);
	}	
}

Measured memory_bytes: 1080
#include <iostream>

using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	bool f;
	if (A == B && B == 5) {
		if (C == 7)
			f = true;
	}
	else if (B == C && C == 5) {
		if (A == 7)
			f = true;
	}
	else if (A == C && C == 5) {
		if (B == 7)
			f = true;
	}
	else f = false;


	if (f)
		cout << "YES\n";
	else
		cout << "NO\n";
		

	return 0;
}

Measured memory_bytes: 256
import math

"???????????° n"
"s1 s2 ... sn"

while True:
    num_students = int(input().rstrip())
    if num_students == 0:
        break
    
    score = list(map(int,input().split(" ")))
    
    #average
    score_total = 0
    score_average = 0
    for tmp_score in score:
        score_total = score_total + tmp_score
    
    score_average = score_total / len(score)

    #standard deviation
    tmp_dev = 0
    sta_dev = 0
    for tmp_score in score:
        tmp_dev = tmp_dev + (tmp_score - score_average) ** 2
    
    sta_dev = math.sqrt(tmp_dev/num_students)

    print("{:.5f}".format(sta_dev))

Measured memory_bytes: 7752
N,M = map(int,input().split())
AC = {} # 1:AC済のみ
WA = {}
acNum = 0

for i in range(M):
    p,S = input().split()
    p = int(p)
    if S == 'AC':
        if p in AC:
            pass
        else:
            AC[p] = 1
            acNum += 1
    else:
        # S == 'WA'
        if not p in AC:
            if not p in WA:
                WA[p] = 0
            WA[p]+=1


peNum = 0
for k,v in WA.items():
    if k in AC:
        peNum += v

print(acNum,peNum)

Measured memory_bytes: 15072
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vi a(n); cin >> a;
	map<int, int> od, ev;
	REP(i, n)
	{
		if (i % 2 == 0) ev[a[i]]++;
		else od[a[i]]++;
	}
	sort(ALL(a));
	int cnt = 0;
	REP(i, n)
	{
		if (i % 2 == 0)
		{
			if (ev[a[i]] > 0) ev[a[i]]--;
			else cnt++;
		}
		else
		{
			if (od[a[i]] > 0) od[a[i]]--;
			else cnt++;
		}
	}
	cout << cnt / 2 << endl;
	return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define MOD 1000000007;

using namespace std;
using namespace __gnu_pbds;
//typedef tree<TYPE, null_type, less<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//typedef tree<TYPE, null_type, less_equal<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

string str;

int main(){
	//IO("input.txt", "output.txt");
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> str;
	int sum = 0;
	for(int i = 0; i < (int)str.length() / 2; i++)
		if(str[i] != str[(int)str.length() - 1 - i]) sum++;
	cout << sum << "\n";
	return 0;
}

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


void solve(long long N, std::vector<long long> A){
    for(auto a : A){
        if(a == 0){
            cout << 0 << endl;
            return;
        }
    }
    long long ans = 1;
    for (int i = 0; i < N; i++)
    {
        if(A[i] <= 1000000000000000000/ans) ans *= A[i];
        else{
            cout << -1 << endl;
            return;
        }
    }
    cout << ans << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4024
import java.util.Scanner;

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

        final int[] a = new int[n];
        final int[] b = new int[n];
        final int[] c = new int[n - 1];

        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt() - 1;
        }

        for (int i = 0; i < n; i++) {
            b[a[i]] = scanner.nextInt();
        }

        for (int i = 0; i < n - 1; i++) {
            c[i] = scanner.nextInt();
        }

        int answer = 0;
        int previous = -2;
        for (int i = 0; i < n; i++) {
            final int index = a[i];
            if (index == previous + 1) {
                answer += c[index - 1];
            }

            previous = index;
            answer += b[index];
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <math.h>
using namespace std;

int main(){
      double N,ans;

      cin >> N;
      
      ans = ceil((N/1.08));

      int ans2 = ans * 1.08;

      if(ans2 != N){
            cout << ":(" << endl;
      }else{
            cout << ans << endl;
      }
      
}



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

int main() {
    ll a;
    double b;
    cin >> a >> b;
    int c = round(b*100);
    ll ans = a * c;
    ans /= 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;

    int n = s.size();

    int p[2] = {};
    for (int i = 0; i < n; i++) {
        p[s[i] - '0']++;
    }

    cout << min(p[0], p[1]) * 2 << endl;

    return 0;
}

Measured memory_bytes: 512
x, n = gets.split.map &:to_i
if n == 0
  puts x
  exit
end
p = gets.split.map &:to_i
q = (-1..101).to_a - p
r = q.map{|i| [i, (i-x).abs]}
min = r.min{|a,b| a[1] <=> b[1]}[1]
p r.find{|i| i[1] == min}[0]

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

int main(){
    int K, X;
    int A, B;

    cin >> K >> X;
    A = X-K+1;
    B = X+K-1;

    for(int i=A; i<=B; i++){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int mod = 998244353;
int f[301][301 * 301], g[301][301 * 301];
int n, m;
int a[301];
int calc(long long x, long long y)
{
    long long z = 1;
    while (y)
    {
        if (y & 1) (z *= x) %= mod;
        (x *= x) %= mod, y /= 2;
    }
    return z;
}
int main()
{
    f[0][0] = 3;
    g[0][0] = 1;
    scanf("%d", &n);
    for (int i = 1; i <= n ; i ++)
        scanf("%d", &a[i]);
    for (int i = 0; i < n ; i ++) {
        for (int j = 0; j <= m; j++)
            if (f[i][j]) {
                f[i + 1][j] += (f[i][j] * 2) % mod;
                g[i + 1][j] += g[i][j];
                if (f[i + 1][j] >= mod) f[i + 1][j] -= mod;
                if (g[i + 1][j] >= mod) g[i + 1][j] -= mod;
                f[i + 1][j + a[i + 1]] += f[i][j];
                g[i + 1][j + a[i + 1]] += g[i][j];
                if (f[i + 1][j + a[i + 1]] >= mod) f[i + 1][j + a[i + 1]] -= mod;
                if (g[i + 1][j + a[i + 1]] >= mod) g[i + 1][j + a[i + 1]] -= mod;
            }
        m += a[i + 1];
    }
    int ans = calc(3, n);
    for (int i = (m + 1) / 2; i <= m ; i ++)
    {
        if (i + i == m)
        {
            ans += ((long long)g[n][i] * 3 % mod);
            if (ans >= mod) ans -= mod;
        }
        ans -= f[n][i];
        if (ans < 0) ans += mod;
    }

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

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

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

  vector<int64_t> l;
  l.push_back(2LL);
  l.push_back(1LL);

  int sum = 0;
  for (int i = 2; i <= n; i++) {
    l.push_back(l.at(i-1) + l.at(i-2));
  }

  cout << l.at(n) << endl;
  
  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 all(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<ll, ll> P;

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    int n; cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    sort(a,a+n);
    reverse(a,a+n);
    ll ans = 0;
    ans += a[0];
    int cnt = 1;
    for(int i = 1; i < n-1; i++){
        ans += a[cnt];
        if(i%2==0) cnt++;
    }
    cout << ans << endl;
}

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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int sum = A+B+C;
  int M = max({A, B, C});
  for(int i=0; i<K; i++){
    M = M*2;
  }
  sum=sum+M-max({A, B, C});
  cout << sum << endl;
}

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

int paper[10][10] = {0};

void size_s(int x, int y);
void size_m(int x, int y);
void size_l(int x, int y);
void disp();

int main(){
	int inpx, inpy, size;
	while(scanf("%d,%d,%d", &inpx, &inpy, &size) != EOF){
		if(size == 1) size_s(inpx, inpy);
		if(size == 2) size_m(inpx, inpy);
		if(size == 3) size_l(inpx, inpy);
	}
	disp();
	return 0;
}

void size_s(int x, int y){
	int sousax[4] = {0, 1, 0, -1};
	int sousay[4] = {-1, 0, 1, 0};
	paper[y][x]++;
	for(int i = 0; i < 4; i++){
		int pointx = x + sousax[i], pointy = y + sousay[i];
		if(pointx < 0 || pointx > 9 || pointy < 0 || pointy > 9) continue;
		else paper[pointy][pointx]++;
	}
}

void size_m(int x, int y){
	int sousax[8] = {0, 1, 1, 1, 0, -1, -1, -1};
	int sousay[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
	paper[y][x]++;
	for(int i = 0; i < 8; i++){
		int pointx = x + sousax[i], pointy = y + sousay[i];
		if(pointx < 0 || pointx > 9 || pointy < 0 || pointy > 9) continue;
		else paper[pointy][pointx]++;
	}
}

void size_l(int x, int y){
	int sousax[12] = {0, 2, 0, -2, 0, 1, 1, 1, 0, -1, -1, -1};
	int sousay[12] = {-2, 0, 2, 0, -1, -1, 0, 1, 1, 1, 0, -1};
	paper[y][x]++;
	for(int i = 0; i < 12; i++){
		int pointx = x + sousax[i], pointy = y + sousay[i];
		if(pointx < 0 || pointx > 9 || pointy < 0 || pointy > 9) continue;
		else paper[pointy][pointx]++;
	}
}

void disp(){
	int white = 0, deep = -1;
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			if(paper[i][j] > deep) deep = paper[i][j];
			if(paper[i][j] == 0) white++;
		}
	}
	cout <<white <<endl <<deep <<endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e14;
using Graph = vector<vector<int>>;

vector<int> Zalgo( const string& S ){
  int c = 0;
  int n = (int)S.size();

  vector<int> lcp(n, 0);
  for( int i = 1; i < n; i++ ){
    int l = i-c;
    if( i+lcp[l] < c+lcp[c] ) lcp[i] = lcp[l];
    else{
      int j = max(0LL, c+lcp[c]-i);
      while( i+j < n && S[j] == S[i+j] ) j++;
      lcp[i] = j;
      c = i;
    }
  }
  lcp[0] = n;
  return lcp;
}

signed main(){
  int N;
  cin >> N;
  string S;
  cin >> S;

  int ans = 0;
  for( int i = 0; i < N; i++ ){
    string T = S.substr(i);
    vector<int> now = Zalgo(T);
    for( int j = 0; j < T.size(); j++ ){
      if( now[j] <= j ) ans = max(ans, now[j]);
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 3656
#include<iostream>
#define PI 3.141592653589
using namespace std;

int main() {
	while (1) {
		int x, y;
		char c;
		cin >> x >> c >> y;

		if (c == '?')break;
		int z;
		switch (c) {
		case '+':
			z = x + y;
			break;
		case '-':
			z = x - y;
			break;
		case '*':
			z = x*y;
			break;
		case '/':
			z = x / y;
			break;
		case '%':
			z = x%y;
			break;
		}
		printf("%d\n", z);
	}

	return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define ld long double
constexpr int MAXN = 3000;

int N;
ll a[MAXN+5], DP[2][MAXN+5][MAXN+5];

ll f(int p, int l, int r){
    if(l > r) return 0;
    if(DP[p][l][r] != LLONG_MAX)
        return DP[p][l][r];
    if(p){
        return DP[p][l][r] = max(f(0, l+1, r) + a[l], f(0, l, r-1) + a[r]);
    } else{
        return DP[p][l][r] = min(f(1, l+1, r) - a[l], f(1, l, r-1) - a[r]);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i < N; i++){
        for(int j = i; j < N; j++)
            DP[0][i][j] = DP[1][i][j] = LLONG_MAX;
    }
    cout << f(1, 0, N-1);
}

Measured memory_bytes: 96176
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main(){
    map<string,bool> mp;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string command,key;
        cin>>command;
        if(command=="insert"){
            cin>>key;
            mp[key]=true;
        }
        else if(command=="find"){
            cin>>key;
            if (mp[key]==true){
                cout<<"yes"<<endl;
            }
            else {
                cout<<"no"<<endl;
            }
        }
    }
    return 0;
}


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

int main(){
  int r, D;
  int x[11];

  cin >>r >>D >>x[0];

  for(int i=1;i<=10;i++){
    x[i]=r*x[i-1]-D;
    cout << x[i] << endl;
  }
}


Measured memory_bytes: 256
import sys

S = list(input())

sum = 0
for i in range(2**(len(S)-1)):

    op_list = ['+']*(len(S)-1)

    for j in range(len(S)-1):
        if (i>>j) & 1:
            op_list[j] = ''


    s = ""
    for st_index in range(len(op_list)):
        s = s + S[st_index] + op_list[st_index]
    s = s + S[len(S)-1]
    result = eval(s)
    
    sum = sum + result

print(sum)

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

int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	int n=s.size(),ans[n+5];
	if (n==1)
	{
		cout<<"1\n";
		return 0;
	}
	ans[0]=0;
	ans[1]=1;
	ans[2]=2;
	if (s.at(0)==s.at(1))
	{
		ans[2]=1;
	}
	for (int i = 2; i < n; ++i)
	{
		if (s.at(i-1)==s.at(i))
		{
			ans[i+1]=ans[i-2]+2;
		}
		else
		{
			ans[i+1]=ans[i]+1;
		}
	}
	cout<<ans[n]<<endl;
	return 0;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;


int main(){
	int a,b,c,x,y;
	int ans=0;
	cin>>a>>b>>c>>x>>y;
	if (2*c>=a+b){
		ans=a*x+b*y;
		cout<<ans;
		return 0;
	}
	if (x<y){
		ans+=x*c*2;
	//	cout<<ans<<endl;
		y-=x;
		ans+=min(b,2*c)*y;
	//	cout<<ans<<endl;
	}
	else if (x>=y){
		ans+=y*c*2;
		x-=y;
		ans+=min(a,2*c)*x;
	}
	cout<<ans;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main() {
  int n,k;
  string s;
  cin >> n >> k >> s;
  auto it = next(s.begin(), k-1);
  transform(it ,it+1 ,it, ::tolower);
  cout << s;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<int> d(N);
    for (auto &&i : d) {
        cin >> i;
    }

    SORT(d);
    int abc = d[N / 2 - 1];
    int arc = d[N / 2];
    int ans = arc - abc;
    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef list<ll> listl;
typedef string str;

#define min(A, B) min(static_cast<ll>(A), static_cast<ll>(B))
#define max(A, B) max(static_cast<ll>(A), static_cast<ll>(B))

void in(ll& I)
{
	cin >> I;
}

void in(vl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(listl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(str& s)
{
	cin >> s;
}

void out(ll O)
{
	cout << O;
}

void out(vl& O)
{
	for (auto& o : O)
	{
		cout << o;
	}
}

int main()
{
	ll N;
	ll M;

	in(N);
	in(M);

	vl K(M);

	vector<vl> S(M);

	for (int i = 0; i < M; i++)
	{
		in(K[i]);
		S[i].resize(K[i]);
		in(S[i]);
	}

	vl P(M);

	in(P);

	vector<bool> B(N);

	ll NA = 1;

	for (int i = 0; i < N; i++)
	{
		NA *= 2;
	}

	ll Max = 0;

	for(int n=0;n<NA;n++)
	{
		for (int j = 0; j < N; j++)
		{
			B[j] = n & (0x1 << j);
		}

		bool ac = true;

		for (int i = 0; i < M; i++)
		{
			ll mod = 0;
			for (int j = 0; j < K[i]; j++)
			{
				mod = B[S[i][j] - 1] ? (mod + 1) % 2 : mod;
			}

			if (mod != P[i])
			{
				ac = false;
				break;
			}
		}
		if (ac)Max++;
	}


	out(Max);

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,c,x[11],i,j;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<10;i++) x[i]=0;
		for(i=0;i<n;i++){
			scanf("%d",&c);
			x[c]++;
		}
		for(i=0;i<10;i++){
			if(x[i]==0) printf("-\n");
			else{
				for(j=0;j<x[i];j++) printf("*");
				printf("\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2488
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <algorithm>
#include <iostream>
using namespace std;

#include <vector>
#include <numeric>
#include <math.h>
#define ld long double
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using p = pair<int, int>;//<key,value>


	int main()
	{ 
		int a, b;
		cin >> a >> b;
		cout << a * b << endl;

	
		
		



		
		return 0;
	}


// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント:
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
int main(){
    double n, d;
    int cont=0;
    scanf("%lf %lf", &n, &d);
    for (int i=0; i<n; ++i){
        double x,y;
        scanf("%lf %lf", &x, &y);
        double op=((x*x)+(y*y));
        op=sqrt(op);
        if (op<=d){
            cont+=1;
        }
    }
    printf("%d\n", cont);
    return 0;
}


Measured memory_bytes: 2204
#include <iostream> 
#include <cmath>
#include<iomanip>
using namespace std;
double min(double x,  double y)
{
	return (x < y) ? x : y;

}

 double calcAngle( double h, double m)
{		
	if (h == 12) h = 0;
	if (m == 60) m = 0;	
	double hour_angle = 0.5 * (h * 60 + m);
	double minute_angle = 6 * m;	 
	double angle = abs(hour_angle - minute_angle);
	angle = min(360 - angle, angle);
 return angle;
}
int main()
{
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double C = calcAngle(h, m);
	C = min(C, 360 - C);
	//const long double PI = 0.01745329251994329576;
	double PI = 3.14159265358979323846 / 180;
	C = PI * C;
	double cosval = cos(C);	
	 double c = (a * a) + (b * b) - (2 * a * b * cosval);	
	c = sqrt(c);
	cout << setprecision(21) << c << endl;

	return 0;
}


Measured memory_bytes: 3656
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),k=sc.nextInt();
        if(n%k == 0){
            System.out.println(0);
        }else{
            System.out.println(1);
        }
    }
}

Measured memory_bytes: 21844
//minamoto
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#define fu(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,k,ans=0;
int read(){
    int x=0,f=1;
    char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
    return x*f;
}
int main(){
	n=read();
	fu(i,1,n){
		k=read();
		if(k&1) ans^=1;
	}
	if(ans) printf("NO\n");
	else printf("YES\n");
	return 0;
}

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

int main()
{
    long long t,n;
    cin>>n>>t;
    vector<int>v(t);
    long long cnt=0;
    for(int i=0;i<t;i++)
    {
        cin>>v[i];
        cnt+=v[i];
    }
    if(cnt>=n)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <stdlib.h>
#include <vector>
using namespace std;

typedef struct node* treepointer;
struct node{
	int data;
	treepointer leftchild,rightchild,parent;
};
void inorder(treepointer ptr){
	if(ptr){
		inorder(ptr->leftchild);
		cout<<" "<<ptr->data;
		inorder(ptr->rightchild);
	}
}
void preorder(treepointer ptr){
	if(ptr){
		cout << " " << ptr->data;
		preorder(ptr->leftchild);
		preorder(ptr->rightchild);
	}
}
void lastorder(treepointer ptr){
	if(ptr){
		lastorder(ptr->leftchild);
		lastorder(ptr->rightchild);
		cout << " " << ptr->data;
		
	}
}
int main(){
	int n;
	cin >> n;
	vector<node> tree(n);
	int x, y, z,root;
	for (int i = 0; i < n; i++) {
		cin >> z>> x>> y;
		tree[z].data = z;
		if (x == -1)
			tree[z].leftchild = NULL;
		else {
			tree[x].parent = &tree[z];
			tree[z].leftchild = &tree[x];
		}
		if (y == -1)
			tree[z].rightchild = NULL;
		else {
			tree[z].rightchild = &tree[y];
			tree[y].parent = &tree[z];
		}
	}
	cout << "Preorder" << endl;
	treepointer m = &tree[0];
	while (m->parent) m = m->parent;
	preorder(m);
	cout << endl << "Inorder" << endl;
	inorder(m);
	cout << endl << "Postorder" << endl;
	lastorder(m);
	cout << endl;
	return 0;
}

Measured memory_bytes: 3088
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main()
{
  cin.tie(0);
  int r, d, x;
  cin >> r >> d >> x;
  for (int i = 0; i < 10; i++) {
    int tmp = r * x - d ;
    cout << tmp << endl;
    x = tmp;
  }
}

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

using namespace std;

const int INF = 1 << 29;

struct Bipartite_Matching
{
  vector< vector< int > > graph;
  vector< int > dist, match;
  vector< bool > used, vv;

  Bipartite_Matching(int n, int m)
  {
    graph.resize(n);
    match.assign(m, -1);
    used.assign(n, false);
  }

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

  void bfs()
  {
    dist.assign(graph.size(), -1);
    queue< int > que;
    for(int i = 0; i < graph.size(); i++) {
      if(!used[i]) {
        que.emplace(i);
        dist[i] = 0;
      }
    }

    while(!que.empty()) {
      int a = que.front();
      que.pop();
      for(auto &b : graph[a]) {
        int c = match[b];
        if(c >= 0 && dist[c] == -1) {
          dist[c] = dist[a] + 1;
          que.emplace(c);
        }
      }
    }
  }

  bool dfs(int a)
  {
    vv[a] = true;
    for(auto &b : graph[a]) {
      int c = match[b];
      if(c < 0 || (!vv[c] && dist[c] == dist[a] + 1 && dfs(c))) {
        match[b] = a;
        used[a] = true;
        return (true);
      }
    }
    return (false);
  }

  int bipartite_matching()
  {
    int ret = 0;
    while(true) {
      bfs();
      vv.assign(graph.size(), false);
      int flow = 0;
      for(int i = 0; i < graph.size(); i++) {
        if(!used[i] && dfs(i)) ++flow;
      }
      if(flow == 0) return (ret);
      ret += flow;
    }
  }
};

int main()
{
  int N, M, L;
  int cost[100][100];
  int p[1000], t[1000];

  while(scanf("%d %d %d", &N, &M, &L), L) {
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) cost[i][j] = INF;
      cost[i][i] = 0;
    }

    for(int i = 0; i < M; i++) {
      int u, v, d;
      scanf("%d %d %d", &u, &v, &d);
      cost[u][v] = cost[v][u] = d;
    }
    for(int i = 0; i < L; i++) {
      scanf("%d %d", &p[i], &t[i]);
    }

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

    Bipartite_Matching flow(L, L);
    for(int i = 0; i < L; i++) {
      for(int j = 0; j < L; j++) {
        if(i == j) continue;
        if(t[j] - t[i] >= cost[p[i]][p[j]]) {
          flow.add_edge(i, j);
        }
      }
    }
    printf("%d\n", L - flow.bipartite_matching());
  }
}

Measured memory_bytes: 5640
<?php

fscanf(STDIN, "%d%d", $n,$k);
$a = trim(fgets(STDIN));
$a_array = explode(' ', $a);

$unique_array = array_unique($a_array);

$cnt = count($unique_array)-$k;

//echo '$cnt='.$cnt."\n";

$value_count_array = array_count_values($a_array);

asort($value_count_array);

$ans = 0;
//var_dump($value_count_array);
foreach ($value_count_array as $value) {
    if($cnt<=0){
        echo $ans;
        return;
    }
    $ans+=$value;
    $cnt--;
}

Measured memory_bytes: 37864
#define NAME "a"

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cctype>
#include <cassert>
#include <memory>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <iterator>

#define pb push_back
#define mp make_pair
#define frs first
#define snd second

using namespace std;

#ifdef WIN32
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 7;
const ll INFLONG = (ll) 1e18 + 7;
const double EPS = 1e-9;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<string> vs;

typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;

template <typename T>
T sqr(T a) {
    return a * a;
}

void solve() {
    int n;
    scanf("%d", &n);
    vi a(n);
    vi cnt((int) (1e5 + 10), 0);
    ll sum = 0LL;

    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        cnt[a[i]]++;
        sum += (ll) (a[i]);
    }

    int q;
    scanf("%d", &q);

    for (int i = 0; i < q; i++) {
        int b, c;
        scanf("%d %d", &b, &c);
        int cnt1 = cnt[b];
        cnt[b] = 0;
        cnt[c] += cnt1;
        ll diff = (ll) (c - b);
        diff *= (ll) (cnt1);
        sum += diff;
        printf(lld"\n", sum);
    }
}

int main() {
    srand(time(0));

//    freopen(NAME".in", "r", stdin);
  //  freopen(NAME".out", "w", stdout);

    int T = 1;

    while (T--) {
        solve();
    }

//    printf("%.3lf\n", (double) clock() / CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 4040
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int A,B;
  cin>>A>>B;
  string S,ans="Yes";
  cin>>S;
  rep(i,0,A){
    if(S[i]=='-'){
      ans="No";
      break;
      }
    }
  if(S[A]!='-')
    ans="No";
  REP(i,A+1,A+B){
    if(S[i]=='-'){
      ans="No";
      break;
      }
    }
  cout<<ans;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,w;
    cin>>n>>w;
    long long int wt[n];
    long long int val[n];
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    long long int dp[n+1][w+1];
    for(int i=0;i<n+1;i++)
    {
        for(int j=0;j<w+1;j++)
        {
            if(i ==0 || j==0)
                dp[i][j] = 0;
            else if(wt[i-1]>j)
                dp[i][j] = dp[i-1][j];
            else
            {
                dp[i][j] = max(dp[i-1][j], val[i-1] + dp[i-1][j-wt[i-1]]);
            }
        }
    }
    cout<<dp[n][w];
}

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

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int N, M;
    cin >> N >> M;
    VVI connection(M);
    VI P(M);
    REP(i, M) {
        int temp_k;
        cin >> temp_k;
        REP(j, temp_k) {
            int temp_s;
            cin >> temp_s;
            connection[i].emplace_back(temp_s - 1);
        }
    }
    REP(i, M) {
        cin >> P[i];
    }
    // オン・オフ全ての組み合わせにつてい判定
    int ans = 0;
    REP(i, pow(2, N)) {
        // if (i == 9) cerr << "i:" << bitset<8>(i) << ln;

        bool flag = true;
        REP(j, M) {
            // cerr << "m:" << j << ln;
            int num_s = 0;
            for (auto c : connection[j]) {
                if (i & (1 << c)) num_s++;
            }
            // cerr << num_s << ln;
            if (num_s % 2 != P[j]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            // cerr << "i:" << bitset<8>(i) << ln;
            ans++;
        }
    }
    cout << ans << ln;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
using namespace std;
//#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int H,W,D;
	cin>>H>>W>>D;
	pint alpha[SIZE];
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			int a;
			cin>>a;
			alpha[a]=mp(i,j);
		}
	}
	ll DP[SIZE]={};
	for(int i=D+1;i<=H*W;i++){
		DP[i]=DP[i-D]+(abs(alpha[i].first-alpha[i-D].first)+abs(alpha[i].second-alpha[i-D].second));
	}
	int Q;
	cin>>Q;
	for(int i=0;i<Q;i++){
		int L,R;
		cin>>L>>R;
		cout<<DP[R]-DP[L]<<endl;
	}
	return 0;
}

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

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(10)<<fixed;
	
	int h,n;
	cin>>h>>n;
	int t;
	int c=0;
	for(int i=0;i<n;i++)
	{
		cin>>t;
		c+=t;
	}
	if(c>=h)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 256
package main

import (
        "fmt"
)

func main() {
        var str string
        fmt.Scanf("%s", &str)
        
        ret := 0
        for i := 0; i < len(str); i++ {
                if str[i] == '1' {
                        ret += 1
                }
        }

        fmt.Println(ret)
}


Measured memory_bytes: 512