akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

// Description: 素集合を管理するデータ構造
// TimeComplexity: 初期化$\mathcal{O}(n)$ 更新$\mathcal{O}(\log n)$
// Verifyed: AOJ DSL_1_A

struct Union_find {
	Union_find(int n) {par.resize(n), iota(_all(par), 0);}
	int find(int x) {return (par[x] == x) ? x : par[x] = find(par[x]);}
	void unite(int a, int b) {a = find(a), b = find(b); par[a] = b;}
	bool same(int a, int b) {return find(a) == find(b);}
	vector<int> par;
};

using edge = struct {int to; ll cost;};
using G = vector<vector<edge>>;
G graph;

const int limit = 4010;
ll dist[limit][limit];

void dfs(int v, int p, int s, ll c) {
	chmax(dist[s][v], c);
	for (auto &e : graph[v]) {
		if (e.to == p) continue;
		dfs(e.to, v, s, max(c, e.cost));
	}
}

int main(void) {
	int n, m;
	cin >> n >> m;

	using edge = tuple < ll, ll, ll>;
	vector<edge> edges;

	rep(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		edges.push_back(edge(c, a, b));
	}

	sort(begin(edges), end(edges));
	Union_find uf(n);

	ll res = 0LL;
	graph = G(n);

	for (auto &e : edges) {
		ll c, a, b;
		tie(c, a, b) = e;
		if (uf.same(a, b)) continue;
		uf.unite(a, b);
		res += c;
		graph[a].push_back({b, c});
		graph[b].push_back({a, c});
	}

	rep(v, n) dfs(v, -1, v, 0LL);

	int q;
	cin >> q;
	rep(loop, q) {
		int s, t;
		cin >> s >> t;
		s--, t--;
		cout << res - dist[s][t] << endl;
	}
	return 0;
}

Measured memory_bytes: 138216
n = int(input())
arr = list(map(int, input().split()))
d = dict()
for a in arr:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

count = 0
for k, v in d.items():
    if k != v:
        if k < v:
            count += v-k
        else:
            count += v
print(count)


Measured memory_bytes: 17780
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fast ios::sync_with_stdio(0); cin.tie(0)
 
const int sz = 1e6+1;
int SPF[sz] , mp[sz];
 
void spf(){
  for(int i=2;i*i<=sz;i++){
    for(int j=i;j<sz;j+=i) if(SPF[j]==0) SPF[j] = i;
  }
  for(int i=1;i<sz;i++) if(SPF[i]==0) SPF[i] = i;   
}
 
vector<pair<int,int>> primeFactorization(int n){
  vector<pair<int,int>> v;
  while(n!=1){
  int smallest_prime = SPF[n];
  int c = 0;
  while(n%smallest_prime==0){
    c++;
    n/=smallest_prime;
  }
  v.pb({smallest_prime,c});
  }
 
  return v;
}
 
void generateDivisor(vector<pair<int,int>>& pf,int pos,int current_divisor,vector<int>& divisor){
  if(pos==pf.size()){
    divisor.pb(current_divisor);
  }else{
    for(int i=0;i<=pf[pos].second;i++){
      generateDivisor(pf,pos+1,current_divisor,divisor);
      current_divisor*=pf[pos].first;
    }
  }
}

int32_t main(){
    
  fast;
  spf();
  int n; cin >> n;
  int ar[n] = {0};

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

  // unordered_map<int,int> mp;
  int mp[sz] = {0};

  for(int i=0;i<n;i++){
    int num = ar[i];
    vector<pair<int,int>> pf = primeFactorization(num);
    vector<int> divisor;
    generateDivisor(pf,0,1,divisor);
    for(int k : divisor) mp[k]++;
  }

  bool flag = true;
  // for(auto p  : mp){
  //   if(p.first>1&&p.second>1){
  //     flag = false;
  //     break;
  //   }
  // }

  for(int i=1;i<sz;i++){
    if(i>1&&mp[i]>1){
      flag = false;
      break;
    }
  }

  if(flag){
    cout << "pairwise coprime\n";
  }else{
    int g = __gcd(ar[0],ar[1]);
    for(int i=2;i<n;i++) g = __gcd(g,ar[i]);
    if(g==1){
      cout << "setwise coprime\n";
    }else{
      cout << "not coprime\n";
    }
  }

  return 0;
}

Measured memory_bytes: 15276
s = input()
 
def dp(sb, c_1):
  ret = ''
  for i,c in enumerate(sb):
    ret += c
    if c_1 != ret:
      return sb[i+1:], ret
  return False, False
    
sb = s
c_1 = ''
cnt = 0
while True:
  sb, c_1 = dp(sb, c_1)
  #print(c_1)
  if sb == False: 
    break
  cnt += 1
  if len(sb) == 0:
    break
print(cnt)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

// can be applied to string type
#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T>
void Debug(const T &val) { cerr << val << End; }
template<typename T, typename... Args>
void Debug(const T &val, Args... args) {
    cerr << val << ' ';
	Debug(std::forward<Args>(args)...);
}

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

// can be applied to string type
#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
// array sorters
#define Sart(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])));
#define SartR(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])), std::greater<__typeof(a[0])>())

#define pb push_back
#define mp make_pair
#define a first
#define b second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

template <typename T>
T nCr(T n, T r) {
	T table[r + 1];

	memset(table, 0, sizeof(table));

	table[0] = 1;

	T i, j;

	for (i = 1; i <= n; i++) for (j = min(i, r); 0 < j; j--) table[j] = table[j] + table[j - 1];

	return table[r];
}

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    long n;

    cin >> n;

	ll a;
	ll c = 0;
	map<ll, ll> table;
	ll ans = 0;

	table[c] = 1;

	long i;

	rep(i, n) {
		cin >> a;

	    c += a;
		table[c]++;
	}

    repit(table) ans += nCr(it->b, 2LL);

	Out(ans);
	
	return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  vector<int> ans;
  int i = 0;
  while (i < n) {
    for (int j = min(m, n-i); j > 0; --j) {
      if (s[i+j] == '0') {
        i += j;
        ans.push_back(j);
        break;
      }
      if (j == 1) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  reverse(ans.begin(), ans.end());
  rep(i, ans.size()) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3856
#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; 
typedef long long ll;
typedef unsigned long long int ull;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>  
#define ff first
#define ss second
#define pb push_back
#define Inf  1e18
#define inf -1e18
#define mod 1000000007
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll,ll>;
using umll = unordered_map<ll,ll>;
using sll = set<ll>;
using msll = multiset<ll>;
 
 
ll MUL(ll A,ll B){
  return (A%mod*B%mod)%mod;
}
 
ll ADD(ll A,ll B){
  return (A%mod+B%mod)%mod;
}
 
ull power(ll A,ll B) { 
    ull RES = 1;      
    while (B > 0) 
    { 
        if (B & 1) 
            RES = RES*A;  
        B = B>>1;  
        A = A*A;  
    } 
  return RES; 
}

 
void testcases(int cases){
  
  ll N;
  cin >> N;
  ll arr[N+2];
  for(int i = 1 ;i <= N ; i ++){
    cin >> arr[i];
  }
  ll XOR = 0;
  for(int i = 1 ;i <= N ; i ++){
    XOR^=arr[i];
  }
  for(int i = 1 ;i <= N ; i ++){
    ll TMP = XOR^arr[i];
    cout << TMP << " ";
  }
  cout << "\n";
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
    ll t;
    t = 1;
   // cin >> t;
    ll Case =1 ;
    while(t--)
    {
      testcases(Case++);
    }
}

Measured memory_bytes: 5204
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>
#include<string>
#include<math.h>
using namespace std;

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

	}
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		int j = a[i];
		int h = -1;
		for (int k = i; k < n; k++)
		{
			if (j>a[k])
			{
				j = a[k];
				h = k;
			}
		}
		if (h != -1)
		{
			ans++;
			a[h] = a[i];
			a[i] = j;
		}
	}
	for (int i = 0; i < n; i++)
	{
		cout << a[i];
		if (i != n - 1)cout << " ";
	}
	cout << endl << ans << endl;



}

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

int h[4];

int main() {
    int a, b; cin >> a >> b;
    h[a] = 1;
    h[b] = 1;
    for (int i = 1; i < 4; ++i) {
        if (!h[i]) return !printf("%d", i);
    }
    return 0;
}

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


typedef pair<int, int> pi;
typedef long long ll;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define sq(i) (a)*(a)

int ac = 0;
int wa = 0;
int tle = 0;
int re = 0;

int main()
{

	ios_base::sync_with_stdio(0);	
	cin.tie(0);			
	cout.tie(0);	
	
	int n; cin >> n;
	rep(i, 0, n){
		
		string now;
		cin >> now;
		if(now == "AC")
		{
			ac += 1;
			
			}
		else if (now == "WA")
		{
			wa += 1;
			
			
			}
		else if (now == "TLE")
		{
			tle += 1;
			
			
			}
		else if (now == "RE")
		{
			re += 1;
			
			
			}					
		}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;

	
}

//upsolve here
//N = int(input())
//2 s = [input() for i in range(N)]
//3 for v in ['AC', 'WA', 'TLE', 'RE']:
//4 print('{0} x {1}'.format(v, s.count(v)))


//how the fuck is it so short?????


Measured memory_bytes: 3608
N = int(input())
A = list(map(int,input().split()))
count = 0

for i in range(N):
  if A[i] < 0:
    A[i] *= -1
    count += 1

if count%2 == 0 or A.count(0) > 0:
  print(sum(A))
else:
  print(sum(A)-2*min(A))

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

using namespace std;
using ll = long long;

struct node {
  ll cnt = 0;
  vector<int> nexts;
};

void hoge(vector<node> &nodes, int parent = 0, int pos = 1, int xsum = 0) {
  nodes[pos].cnt += xsum;
  for (int next : nodes[pos].nexts)
    if (parent != next)
      hoge(nodes, pos, next, nodes[pos].cnt);
}

int main() {
  ll n, q;
  cin >> n >> q;
  vector<node> nodes(n + 1);
  for (ll i = 1; i < n; ++i) {
    ll a, b;
    cin >> a >> b;
    nodes[a].nexts.push_back(b);
    nodes[b].nexts.push_back(a);
  }

  for (ll i = 0; i < q; ++i) {
    ll p, x;
    cin >> p >> x;
    nodes[p].cnt += x;
  }

  hoge(nodes);

  cout << nodes[1].cnt;
  for (ll i = 2; i <= n; ++i)
    cout << " " << nodes[i].cnt;
  cout << endl;
}

Measured memory_bytes: 28180
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <cstdio>
#define ll long long
#define abs(a) ((a)>0?(a):(-a))
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
ll n,a[210000],tot,ans=922372036854775805;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}
int main()
{
	n=read();
	for(register ll i=1; i<=n; ++i) a[i]=read(),tot+=a[i];	 
	for(register ll i=1; i<=n-1; ++i)
		tot-=2*a[i],ans=min(ans,(ll)abs(tot));
	printf("%lld\n",ans);	
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
int main(){
  int n,m[32],l;
  scanf("%d",&l);
  for(n=0;n<32;n++){
    if(n==31){
      m[n]=51;
    }else if(n==23){
      m[n]=15;
    }else if(n==15){
      m[n]=14;
    }else if(n==27 || n==29){
      m[n]=4;
    }else if(n==7 || n==11 || n==17 || n==19 ||n==26){
      m[n]=5;
    }else if(n==3 || n==5 || n==8 || n==9 ||n==13 ||n==20|| n==21 ||n==24 ||n==25){
      m[n]=2;
    }else{
      m[n]=1;
    }
    
  }
  printf("%d",m[l-1]);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep_rev(i, n) for (int i = n-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}

template<class... T>
void debug_print(T... args){
    vector<lint> tmp = initializer_list<lint>{args...};
    print_vec(all(tmp));
}
template<class T>
void print(T a){ cout << a << endl;}

vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

int ord(char x){ return (int)(x - 'a');}
char chr(lint x){ return (char)(x + (lint)('a'));}
lint mod = 1e9+7;
// lint mod = 

lint sum(vlint a){lint ret = 0; for(auto&& v:a) ret += v; return ret;}
lint vmini(vlint a, lint &index){
    lint ret = LLONG_MAX;
    rep(i, Size(a)){ if (chmin(ret, a[i])) index = i;}
    return ret;
}
lint vmaxi(vlint a, lint &index){
    lint ret = -LLONG_MAX;
    rep(i, Size(a)){ if (chmax(ret, a[i])) index = i;}
    return ret;
}

lint vmin(vlint a){
    lint ret = LLONG_MAX; for (auto && v : a) chmin(ret, v); return ret;
}
lint vmax(vlint a){
    lint ret = -LLONG_MAX; for (auto && v : a) chmax(ret, v); return ret;
}


vlint base_3(int k){
    vlint ret;
    while (k > 0){
        ret.pb(k % 3);
        k /= 3;
    }
    reverse(all(ret));
    return ret;
}

lint dist(lint x, lint y){
    return x*x + y*y;
};
int main(){
    LINT(n);
    STR(c);
    lint cnt = 0;
    rep(i, n){
        if(c[i] == 'R') cnt++;
    }

    lint ans = 0;
    rep(i, cnt){
        if (c[i] == 'W'){
            ans++;
        }
    }
    print(ans);
}


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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
//#define int long long
#define INF 1e18

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

// modint: mod 計算を int を扱うように扱える構造体
template <int MOD>
struct Fp
{
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD)
    {
        if (val < 0)
            val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept
    {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp &operator+=(const Fp &r) noexcept
    {
        val += r.val;
        if (val >= MOD)
            val -= MOD;
        return *this;
    }
    constexpr Fp &operator-=(const Fp &r) noexcept
    {
        val -= r.val;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr Fp &operator*=(const Fp &r) noexcept
    {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp &operator/=(const Fp &r) noexcept
    {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b)
        {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr bool operator==(const Fp &r) const noexcept
    {
        return this->val == r.val;
    }
    constexpr bool operator!=(const Fp &r) const noexcept
    {
        return this->val != r.val;
    }
    friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept
    {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept
    {
        if (n == 0)
            return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1)
            t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;
int n;
signed main()
{
    
    cin >> n;
    vector<int> c(n);
    REP(i, n) cin >> c[i];
    sort(c.rbegin(), c.rend());
   /* if(n==1){
        cout << mint(c[0] * 2) << endl;
        return 0;
    }*/
    mint ans = 0;
    mint n1 = modpow(mint(2), n - 2);
    mint n2 = modpow(mint(2), n - 1);
    for (int i = 0; i < n; i++)
    {
        mint fac = n1 * i + n2;
        ans += fac*c[i];
    }
    cout << ans * modpow(mint(2), n) << endl;
    

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;

struct UnionFind{
    vector<int> d;
    UnionFind(int n=0):d(n,-1){}
    int find(int x){
        if(d[x]<0) return x;
        return d[x]=find(d[x]);
    }
    bool unite (int x, int y){
        x=find(x); y=find(y);    
        if(x==y) return false;
        if(d[x]>d[y]) swap(x,y);
        d[x]+=d[y];
        d[y]=x;
        return true;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return -d[find(x)];
    }
};
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    UnionFind uf(n);
    vector<int> deg(100005);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        uf.unite(a,b);
        deg[a]++;
        deg[b]++;
    }
    vector<vector<int>> block(n);
    for(int i=0;i<k;i++){
        int c,d;
        cin>>c>>d;
        c--;d--;
        block[d].push_back(c);
        block[c].push_back(d);
    }
    for(int i=0;i<n;i++){
        int ans=uf.size(i)-deg[i]-1;
        for(int j=0;j<block[i].size();j++){
            if(uf.same(i,block[i][j])) ans--;
        }
        cout<<ans<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 6784
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int h, n;
	int *a;
	scanf("%d", &h);
	scanf("%d", &n);
	a = (int *)malloc(sizeof(int) * n);
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	for(int j=0; j<n; j++){
		h -= a[j];
	}
	if(h<=0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 512
//85DTG
//07082020
#include<bits/stdc++.h>
using namespace std;
#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define vi vector <int>
typedef long long ll;
typedef long double ld;
const ld pi=3.1415926535897932384626433;
const ll mod = 998244353;
const ll inf = 1e18;
int main ()
{
   bolt;
   ll n;
   cin>>n;
   string s;
   cin>>s;
   ll r=0,w=0;
   for (ll i=0;i<n;i++)
   {
      if (s[i]=='R')
         r++;
      else
         w++;
   }
   ll ans=0;
   for (ll i=0;i<r;i++)
   {
      if (s[i]=='W')
         ans++;
   }
   cout<<ans;
}


Measured memory_bytes: 3732
#include <stdio.h>

int main(int argc, char *argv[])
{
    struct _data_st {int min, max;} datasets[3000];
    int count = 0;
    for (int x, y; scanf("%d %d", &x, &y) == 2 && (x || y);)
    {
        struct _data_st *const elm = &datasets[count++];
        elm->min = (x < y) ? x : y;
        elm->max = (x > y) ? x : y;
    }
    for (struct _data_st *elm = datasets, *const end = elm + count; elm != end; ++elm)
    {
        printf("%d %d\n", elm->min, elm->max);
    }
    return 0;
}



Measured memory_bytes: 2072
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n;
	string s;
	cin>>n>>s;
	if(n<3200)cout<<"red";
	else cout<<s;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int i,n,old,list[7],a[10];

void check(int old){
	if(old<10)list[0]++;
	else if(old<20)list[1]++;
	else if(old<30)list[2]++;
	else if(old<40)list[3]++;
	else if(old<50)list[4]++;
	else if(old<60)list[5]++;
	else list[6]++;
}

int main(){
	while(scanf("%d",&n)*n){
		for(;n>9;n-=10){
			scanf("%d %d %d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);
			for(i=0;i<10;i++)check(a[i]);
		}
		for(;n>0;n--){
			scanf("%d",&old);
			check(old);
		}
		for(n=0;n<7;n++){
			printf("%d\n",list[n]);
			list[n]=0;
		}
	}
	return 0;
}

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

int main()
{
   int h,a;
   int i=0;
   scanf("%d %d",&h,&a);

   while(h>0)
   {
       h=h-a;
       i=i+1;
   }
   printf("%d",i);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

string str; char dmy[32];
int n,m;
int c[300],v[300],d[300],l[300];
int V[301],D[301],L[301];

int main()
{
	while(~scanf("%d%d",&n,&m))
	{
		rep(i,n)
		{
			fgets(dmy,31,stdin);fgets(dmy,31,stdin);
			scanf("%d%d%d%d",c+i,v+i,d+i,l+i);
		}
		rep(i,m+1)V[i]=D[i]=L[i]=0;
		rep(i,n)for(int j=c[i];j<=m;j++)
		{
			V[j]=max(V[j],V[j-c[i]]+v[i]);
			D[j]=max(D[j],D[j-c[i]]+d[i]);
			L[j]=max(L[j],L[j-c[i]]+l[i]);
		}
		printf("%d\n",max(V[m],max(D[m],L[m])));
	}
	
	return 0;
}

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

#define int long long
#define ALL(x) x.begin(),x.end()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define eb emplace_back
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 1000000007
#define F(i, a, n) for(i=a;i<n;i++)
#define B(i, a, n) for(i=n-1;i>=0;i--)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<"\n"
#define DO(x, y) cout<<x<<" "<<y<<"\n"
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<< "\n"
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

inline bool inBounds(int a, int b)
{
    if(a < 0 || b < 0)
        return false;
    return true;
}

inline int add(int a, int b)
{
    return ((a%MOD) + (b%MOD)) % MOD;
}

int32_t main(void)
{
    FASTER;
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int i, j;
    int h, w;
    DI(h, w);
    int dp[h][w];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    char grid[h][w];
    F(i, 0, h)
        F(j, 0, w)
            SI(grid[i][j]);
    F(i, 0, h)
    {
        F(j, 0, w)
        {
            if(grid[i][j] == '#')
                continue;
            if(inBounds(i - 1, j))
                dp[i][j] = add(dp[i][j], dp[i - 1][j]);
            if(inBounds(i, j - 1))
                dp[i][j] = add(dp[i][j], dp[i][j - 1]);
        }
    }
    SO(dp[h - 1][w - 1]);
    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
int a[22];
int q;
set<int> t;

int main(){
  cin >> n;
  rep(i,0,n){
    cin >> a[i];
  }

  for(int S=0;S<1<<n;S++){
    int k=0;
    rep(i,0,n){
      if(S>>i & 1) k += a[i];
    }
    t.insert(k);
  }
  cin >> q;
  rep(i,0,q){
    int m;
    cin >> m;
    if(t.find(m) != t.end()){
      cout << "yes" << endl;
    }else{
      cout << "no" << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
typedef long long ll;
using namespace std;
 
 
int main(){
    
    double d, t, s;
    
    cin >> d >> t >> s;
    
    string ans = (d/s)<=t? "Yes" : "No";
    
    cout << ans << endl;
    
    
}

Measured memory_bytes: 3732
import heapq
n=int(input())
p=[-1 for i in range(n)]
inf=100000000
d=[inf for i in range(n)]
M=[[] for i in range(n)]
color=["white" for i in range(n)]
Q=[]
heapq.heapify(Q)

for i in range(n):
    tmp=list(map(int,input().split()))
    root=tmp[0]
    k=tmp[1]
    for j in range(k):
        M[root].append((tmp[2*(j+1)+1],tmp[2*(j+1)]))

def dijkstra(s):
    d[s]=0
    heapq.heappush(Q,(d[s],s))
    color[s]="gray"
    while Q:
        f=heapq.heappop(Q)

        u=f[1]
        color[u]="Black"
        if f[0]>d[u]:
            continue
        for i in range(len(M[u])):
            if color[M[u][i][1]]!="Black":
                v=M[u][i][1]
                if d[v]>d[u]+M[u][i][0]:
                    d[v]=d[u]+M[u][i][0]
                    color[M[u][i][1]]="gray"
                    heapq.heappush(Q,(d[M[u][i][1]],M[u][i][1]))
                    
dijkstra(0)

for i in range(n):
    print(i,d[i])



Measured memory_bytes: 68920
#include <iostream>
using namespace std;
int main()
{
    while(1)
    {
        int w;
        cin>>w;if(w==-1)return 0;
        int res=1150;
        for(;w>30;--w){
            res+=160;
        }
        for(;w>20;--w){
            res+=140;
        }
        for(;w>10;--w){
            res+=125;
        }
        cout<<4280-res<<endl;
    }
}

Measured memory_bytes: 1160
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val w = readLine()!!.split(" ").map{it.toInt()}
    var ans = 100000
    for(i in 0 until n - 1){
        var sum1 = 0
        var sum2 = 0
        for(j in 0 .. i) sum1 += w[j]
        for(j in i + 1 until n) sum2 += w[j]
        ans = Math.min(ans, Math.abs(sum1 - sum2))
    }
    println(ans)
}


Measured memory_bytes: 37876
#include <bits/stdc++.h>
#define pb push_back
#define ff first;
#define ss second;
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define lli long long int
#define INF 1000000000
#define endl '\n'
const double pi = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
	
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b;
	cin >> a >> b; 
	int sum = a*500;
	if(sum>=b){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3600
n,m,k=map(int,input().split())
w=[i for i in range(n+1)]
s=[1]*(n+1)
g=[list(map(int,input().split()))for i in range(m)]
def root(x):
    if w[x]==x:
        return x
    x=w[x]
    return root(w[x])
def unite(x,y):
    x=root(x)
    y=root(y)
    if x!=y:
        if s[x]<s[y]:
            w[x]=y
            s[y]+=s[x]
        else:
            w[y]=x
            s[x]+=s[y]
for i in range(m):
    a,b=g[i][0],g[i][1]
    unite(a,b)
for i in range(1,n+1):
    w[i]=root(i)
    s[i]=s[w[i]]
for i in range(m):
    s[g[i][0]]-=1
    s[g[i][1]]-=1
for i in range(k):
    a,b=map(int,input().split())
    if w[a]==w[b]:
        s[a]-=1
        s[b]-=1
for i in range(1,n+1):s[i]-=1
print(*s[1:])


Measured memory_bytes: 91936
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    vector<string> ans(n);
    ll bi = 1;
    ll cnt = 0;

    rep(i, n) {
        if(s.at(i) == 'a' && cnt < a + b) {
            ans.at(i) = "Yes";
            cnt++;
        } else if(s.at(i) == 'b' && cnt < a + b && bi <= b) {
            bi++;
            ans.at(i) = "Yes";
            cnt++;
        } else {
            ans.at(i) = "No";
        }
    }
    rep(i, n) cout << ans.at(i) << endl;
}


Measured memory_bytes: 6144
/**
*    author:  souzai32
*    created: 02.08.2020 19:29:14
**/

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;


int main() {

    long long int n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;

    long long int time=0;
    long long int t=min(a,min(b,min(c,min(d,e))));
    if(n%t) time++;
    time+=n/t+4;

    cout << time << endl;

    return 0;
}

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

int main() {
  int N,K; cin >> N >> K;
  int x[101];
  for ( int i = 0; i < N; i++ ) cin >> x[i];
  int sum = 0;

  for ( int i = 0; i < N; i++ ) {
  sum += min(2*x[i],abs(K-x[i])+abs(K-x[i]));
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':

	n = int(input())
	S = set()

	for _ in range(n):
		x,y = map(int,input().split())
		if x == 0:
			S.add(y)
			print(len(S))
		else:
			if y in S:
				print("1")
			else:
				print("0")



Measured memory_bytes: 23360
using System;
using System.Linq;

namespace ABC145
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            if (S.Length % 2 != 0) { Console.WriteLine("No"); return; }

            string s1 = S.Substring(0, S.Length / 2);
            string s2 = S.Substring(S.Length / 2, S.Length / 2);

            //Console.WriteLine(s1);
            //Console.WriteLine(s2);

            if (s1 == s2) { Console.WriteLine("Yes"); }
            else { Console.WriteLine("No"); }

        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main()
{
	int i,a,w1=0,w2=0,w3=0,k1=0,k2=0,k3=0;
	for(i=0;i<10;i++){
		scanf("%d",&a);
		if(w3<a){
			w3=a;
			if(w2<a){
				w3=w2;
				w2=a;
				if(w1<a){
					w2=w1;
					w1=a;
				}
			}
		}
	}
	for(i=0;i<10;i++){
		scanf("%d",&a);
		if(k3<a){
			k3=a;
			if(k2<a){
				k3=k2;
				k2=a;
				if(k1<a){
					k2=k1;
					k1=a;
				}
			}
		}
	}
	printf("%d %d\n",w1+w2+w3,k1+k2+k3);
	return 0;
}

Measured memory_bytes: 2744
from sys import stdin
import numpy as np
def main():
    #入力
    readline=stdin.readline
    n,m,q=map(int,readline().split())
    table=np.array([[0]*n for _ in range(n)],dtype="int64")
    for i in range(m):
        l,r=map(lambda x:int(x)-1,readline().split())
        table[l][r]+=1

    #累積和
    for i in range(n):
        table[i]=table[i].cumsum()

    ans=[0]*q
    for i in range(q):
        l,r=map(lambda x:int(x)-1,readline().split())
        ans[i]=table[l:r+1,r].sum()

    for i in range(q):
        print(ans[i])

if __name__=="__main__":
    main()

Measured memory_bytes: 20868
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

void solve(long long N, std::vector<long long> &D) {
	bool f = false;
	sort(D.begin(), D.end());
	int used[24] = { 1 };
	int ans = 24;
	for (int t : D) {
		f = !f;
		int i = f ? t : ((24 - t) % 24);
		if (++used[i] >= 2) {
			ans = 0;
		}
	}
	for (int i = 0; i < 24; ++i) {
		for (int j = i + 1; j < 24; ++j) {
			if (used[i] && used[j]) {
				ans = min(ans, j - i);
			}
		}
	}
	cout << ans << endl;
}

int main() {
    long long N;
	std::cin >> N;
	std::vector<long long> D(N);
	for (int i = 0; i < N; i++) {
		std::cin >> D[i];
	}
	solve(N, D);
	return 0;
}


Measured memory_bytes: 3576
n,W=map(int,input().split())
mv=1
s=[None]*n
for i in range(n):
  s[i]=list(map(int,input().split()))
  mv+=s[i][1]
  
INF=10**9+5
dp=[INF]*mv
dp[0]=0
for i in range(len(s)):
  w=s[i][0]
  v=s[i][1]
  for j in range(len(dp)-v-1,-1,-1):
    if dp[j]+w<dp[j+v]:
      dp[j+v]=dp[j]+w
      
ans=0
for i in range(len(dp)):
  if dp[i]<=W:
    ans=i
    
print(ans)

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

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

static const int MMAX = 20;
static const int NMAX = 50000;
static const int INFTY = (1 << 29);

int main()
{
    int n, m;
    int C[MMAX + 1];
    int T[NMAX + 1];
    cin >> n >> m;

    for (int i = 1; i <= m; i++) {
        cin >> C[i];
    }

    for (int i = 0; i <= NMAX; i++)T[i] = INFTY;
    T[0] = 0;
    for (int i = 1; i <= m; i++) {
        for (int j = 0; j + C[i] <= n; j++) {
            T[j + C[i]] = min(T[j + C[i]], T[j] + 1);
        }
    }

    cout << T[n] << endl;
    return 0;
}

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

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



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

int main(){
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> A(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());
    vector<vector<int>> B(h, vector<int>(w));

    int cur = 0, cnt = 0;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (cnt >= A[cur]){
                cnt = 0;
                cur++;
            }
            B[i][j] = cur + 1;
            cnt++;
        }
    }

    for (int i = 1; i < h; i += 2){
        reverse(B[i].begin(), B[i].end());
    }

    for (auto &b: B){
        copy(b.begin(), b.end(), ostream_iterator<int>(cout, " "));
        cout << endl;    
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m, sum = 0;
	cin >> n >> m;
	vector<int> a(n);
	for(int i = 0; i < n; ++ i) cin >> a[i], sum += a[i];
	int cnt = 0;
	for(int i = 0; i < n; ++ i) {
		if(a[i] * 4 * m >= sum) cnt ++;
	}
	cout << (cnt >= m ? "Yes\n" : "No\n");
	
}


Measured memory_bytes: 256
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::max;
fn main() {
    input! { n, cap, wv: [(usize, usize); n] };
    let mut dp = vec![0; cap + 2];
    for &(w, v) in &wv {
        for c in (0..(cap + 1)).rev() {
            if c + w <= cap {
                dp[c + w] = max(dp[c + w], dp[c] + v);
            }
        }
    }
    println!("{}", dp.iter().max().unwrap());
}


Measured memory_bytes: 4352
import java.util.Scanner;

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

		//a??????
		int intA = sc.nextInt();
		//b??????
		int intB = sc.nextInt();

		//a?????????
		//????????????
		double dbF; //?????°?????£?¨?
		//f???????????????????????°???????????§???????¨????
		dbF = (double) intA /  (double) intB;
		 //?¨??????????db????????°??????string???????????????
		 String f2 = String.format("%.5f", dbF);
		//?¨??????????????????????a/b = d
		System.out.println(intA / intB + " " + intA % intB + " " + f2);
	}
}

Measured memory_bytes: 26224
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

int n, a[100005];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n, greater<int>());
	for (int i = 1; i <= n; i++)
		if (a[i] <= i) {
			int k = 0;
			while (a[i + k] == i)
				k++;
			return !printf(k & 1 || a[i - 1] - i & 1? "First": "Second");
		}
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

#define MAX_N 50

int N,M;
vector<int> city[MAX_N];

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N >> M;
	int a,b;
	FOR(m,M) {
		cin >> a >> b;
		city[a-1].push_back(b-1);
		city[b-1].push_back(a-1);
	}

	FOR(n,N) {
		cout << city[n].size() << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF long long int(1e18+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;


int main() 
{
	int n;
	cin >> n;
	vector<long long int>a(n);
	rep(i, 0, n)cin >> a[i];
	sort(a.begin(), a.end());
	rep(i, 1, n) {
		if (a[i] == a[i - 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}



Measured memory_bytes: 4712
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

int K, Q;
vector<long long> d;
long long N, x, m;

long long solve() {
    long long q = (N-1) / K;
    long long r = (N-1) % K;
    long long e_num = 0, r_num = 0;
    long long e_sum = 0, r_sum = 0;
    for (int i = 0; i < K; ++i) {
        if (d[i] % m == 0) {
            ++e_num;
            if (i < r) ++r_num;
        }
        e_sum += d[i] % m;
        if (i < r) r_sum += d[i] % m;
    }

    // equal
    long long equal = q * e_num + r_num;

    // zouka
    long long syoko = x;
    long long last = x + q * e_sum + r_sum;
    long long zouka = last/m - syoko/m;

    return N-1 - equal - zouka;
}

int main() {
    cin >> K >> Q;
    d.resize(K);
    for (int i = 0; i < K; ++i) cin >> d[i];
    while (Q--) {
        cin >> N >> x >> m;
        cout << solve() << endl;
    }
}


Measured memory_bytes: 384
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
# define int ll
using namespace std;
 
int n,q,a,b,c,k,d[1 << 17],x,y;
vector<pair<int,int>>vec[1 << 17];

void dfs(int nod,int par,int val)
{
	d[nod] = val;
	for(auto it : vec[nod])
	{
		if(it.first != par) dfs(it.first,nod,val + it.second);
	}
}

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n;
	for(int i = 1;i < n;i++)
	{
		cin >> a >> b >> c;
		vec[a].pb(mp(b,c));
		vec[b].pb(mp(a,c));
	}		
	cin >> q >> k;
	dfs(k,0,0);
	while(q--)
	{
		cin >> x >> y;
		cout << d[x] + d[y] << '\n';
	}
}

Measured memory_bytes: 14080
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	s := getString()

	ans := true

	if len(s)%2 == 1 {
		out("No")
		return
	}

	for i := 0; i < len(s); i += 2 {
		if s[i] != 'h' || s[i+1] != 'i' {
			ans = false
			break
		}
	}
	if ans {
		out("Yes")
	} else {
		out("No")
	}

}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  for(int a=1;a<=9;a++)
  for(int b=1;b<=9;b++)
  {
    if(a*b==n)
    {
    puts("Yes");
    return 0;
    }
  }
  puts("No");
}


Measured memory_bytes: 128