akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int H, W;

void solve(string a[]) {
  bool ans[H][W];
  fill(ans[0], ans[H], false);
  REP(i, H) {
    bool check = false;
    REP(k, W) {
      if (a[i][k] == '#') {
        check = true;
        break;
      }
    }
    if (check) {
      REP(k, W) {
        ans[i][k] = true;
      }
    }
  }
  REP(i, W) {
    bool check = false;
    REP(k, H) {
      if (a[k][i] == '#') {
        check = true;
        break;
      }
    }
    if (!check) {
      REP(k, H) {
        if (a[k][i] == '.')
          ans[k][i] = false;
      }
    }
  }
  REP(i, H) {
    bool check = false;
    REP(k, W) {
      if (ans[i][k]) {
        cout << a[i][k];
        check = true;
      }
    }
    if (check)
      cout << endl;
  }
}

int main() {
  cin >> H >> W;
  string a[H];
  REP(i, H) {
    cin >> a[i];
  }
  solve(a);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const ll INF = 1e+15;

ll dist1[305][305];
ll dist2[305][305];

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

    int n, m, l;
    cin >> n >> m >> l;
    fill((ll*)dist1, (ll*)(dist1 + n), INF);
    fill((ll*)dist2, (ll*)(dist2 + n), INF);
    for(int i = 0; i < n; ++i){
        dist1[i][i] = dist2[i][i] = 0;
    }
    for(int i = 0; i < m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        dist1[a][b] = c;
        dist1[b][a] = c;
    }

    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                dist1[i][j] = min(dist1[i][j], dist1[i][k] + dist1[k][j]);
            }
        }
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            if(dist1[i][j] != INF && dist1[i][j] <= l){
                dist2[i][j] = 1;
                dist2[j][i] = 1;
            }
        }
    }
    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);
            }
        }
    }

    int q;
    cin >> q;
    for(int i = 0; i < q; ++i){
        int s, t;
        cin >> s >> t;
        --s, --t;
        if(dist2[s][t] == INF)  dist2[s][t] = 0;
        cout << --dist2[s][t] << "\n";
    }
}

Measured memory_bytes: 2048
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n;
  scanf("%d", &n);
  vector<int64> pos, neg;
  for (int i = 0; i < n; ++i) {
    int64 x;
    scanf("%lld", &x);
    if (x >= 0) {
      pos.push_back(x);
    } else {
      neg.push_back(x);
    }
  }
  sort(pos.begin(), pos.end(), greater<int64>());
  sort(neg.begin(), neg.end());
  if (pos.empty()) {
    pos.push_back(neg.back());
    neg.pop_back();
  }
  if (neg.empty()) {
    neg.push_back(pos.back());
    pos.pop_back();
  }
  int64 ret = 0;
  for (auto& it : pos) ret += it;
  for (auto& it : neg) ret -= it;
  printf("%lld\n", ret);
  if (pos.size() <= neg.size()) {
    printf("%lld %lld\n", pos[0], neg[0]);
    int64 last = pos[0] - neg[0];
    for (int i = 1; i < pos.size(); ++i) {
      printf("%lld %lld\n", neg[i], last);
      last = neg[i] - last;
      printf("%lld %lld\n", pos[i], last);
      last = pos[i] - last;
    }
    for (int i = pos.size(); i < neg.size(); ++i) {
      printf("%lld %lld\n", last, neg[i]);
      last = last - neg[i];
    }
  } else {
    printf("%lld %lld\n", neg[0], pos[0]);
    int64 last = neg[0] - pos[0];
    for (int i = 1; i < neg.size(); ++i) {
      printf("%lld %lld\n", pos[i], last);
      last = pos[i] - last;
      printf("%lld %lld\n", neg[i], last);
      last = neg[i] - last;
    }
    for (int i = neg.size(); i < pos.size() - 1; ++i) {
      printf("%lld %lld\n", last, pos[i]);
      last = last - pos[i];
    }
    printf("%lld %lld\n", pos.back(), last);
  }
  return 0;
}


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

int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  vector<ll> cnts;
  ll cur = 1;
  for (int i = 1; i < n; ++i) {
    if (s[i] != s[i - 1]) {
      cnts.push_back(cur);
      cur = 1;
    } else {
      cur++;
    }
  }
  cnts.push_back(cur);

  if (cnts.size() == 1) {
    ll ans = (ll)n * k / 2;
    cout << ans << '\n';
    return 0;
  }

  ll ans = 0;
  for (int i = 0; i < cnts.size(); ++i) {
    ans += (cnts[i] / 2 * k);
  }
  

  if (s[0] == s.back()) {
    ll sub = (cnts[0] / 2) + (cnts.back() / 2) - ((cnts[0] + cnts.back()) / 2);
    ans -= (sub * (k - 1));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{

  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  while (1)
  {
    C -= B;
    if (C <= 0)
    {
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
    if (A <= 0)
    {
      cout << "No" << endl;
      return 0;
    }
  }

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int ssx = sx - sx;
  int ssy = sy - sy;
  int ttx = tx - sx;
  int tty = ty - sy;

  vector<pair<char, int>> v(1);
  v.emplace_back(make_pair('U', tty));
  v.emplace_back(make_pair('R', ttx));
  v.emplace_back(make_pair('D', tty));
  v.emplace_back(make_pair('L', ttx));
  v.emplace_back(make_pair('L', 1));
  v.emplace_back(make_pair('U', tty + 1));
  v.emplace_back(make_pair('R', ttx + 1));
  v.emplace_back(make_pair('D', 1));
  v.emplace_back(make_pair('R', 1));
  v.emplace_back(make_pair('D', tty + 1));
  v.emplace_back(make_pair('L', ttx + 1));
  v.emplace_back(make_pair('U', 1));

  for (int i = 1; i < v.size(); ++i) {
    for (int j = 0; j < v[i].second; ++j) {
      cout << v[i].first;
    }
  }
  return 0;
}


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

int main(){
  string s;
  cin>> s;
  bool c1= false, c2= false, c3 = false;
  string sdash =s;
  reverse(s.begin(), s.end());
  if(s.compare(sdash)==0)
    c1 = true;
  string s1 = s.substr(0, (s.size()-1)/2);
  string s2 = s.substr((s.size()+3)/2 -1, s.size()-1);
  string s1dash = s1;
  string s2dash = s2;
  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());
  if(s1 == s1dash)
    c2 = true;
  if(s2  == s2dash)
    c3 = true;
  // cout<<s<<" "<<s1<< " "<< s2<<endl;
  // cout<<sdash<<" "<<s1dash<< " "<< s2dash<<endl;
  if(c1&& c2&& c3)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


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

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}

signed main()
{
	int a=read(),b=read(),c=read(),n=read(),ans=0;
	for (int i=0;i*a<=n;i++)
	for (int j=0;i*a+j*b<=n;j++)
	{
		int m=n-i*a-j*b;
		ans+=m%c==0;
	}
	print(ans);

	return 0;
}

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

int main(){
    int n,ans=-10000;
    cin>>n;
    int dp[102][102]={0};
    for(int i=0;i<n;i++){
        int sum[105]={0};
        for(int j=1;j<=n;j++){
            cin>>sum[j];
            sum[j]+=sum[j-1];
        }
        for(int j=1;j<=n;j++){
            for(int k=j;k<=n;k++){
                dp[j][k]=max(sum[k]-sum[j-1],dp[j][k]+sum[k]-sum[j-1]);
                ans=max(ans,dp[j][k]);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1208
#include <stdio.h>

int main(void) {
	int count;
	int point[200][2/*x,y*/];

	int n,d;

	while(1) {
		scanf( "%d", &count );
		if ( count == 0 ) { break; }
		
		int xmin,xmax,ymin,ymax;
		xmin=0, xmax=0, ymin=0, ymax=0;
		
		point[0][0]=0;
		point[0][1]=0;
		for ( int i=1; i<count; i++ ) {
			scanf("%d %d", &n, &d);

			switch ( d ) {
			case 0: //left
				point[i][0] = point[n][0]-1;
				point[i][1] = point[n][1];
				break;
			case 1: //down
				point[i][0] = point[n][0];
				point[i][1] = point[n][1]-1;
				break;
			case 2: //right
				point[i][0] = point[n][0]+1;
				point[i][1] = point[n][1];
				break;
			case 3: //up
				point[i][0] = point[n][0];
				point[i][1] = point[n][1]+1;
				break;
			}
			
			if ( xmax < point[i][0] ) { xmax = point[i][0]; }
			if ( xmin > point[i][0] ) { xmin = point[i][0]; }
			if ( ymax < point[i][1] ) { ymax = point[i][1]; }
			if ( ymin > point[i][1] ) { ymin = point[i][1]; }
		}
		
		printf("%d %d\n", xmax-xmin+1, ymax-ymin+1);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
  ll t;
  while(b) {
    t = a % b, a = b, b = t;
  }
  return a;
}

int main(void) {
  ll i, j, k, n, a, b, c, l, m;
  scanf("%lld%lld", &n, &m);
  char s[n + 10], t[m + 10];
  scanf("%s%s", s, t);
  ll g = gcd(n, m), lc = n * m / g;
  for(i = 0; i < g; ++i) {
    if(s[lc / m * i] != t[lc / n * i]) {
      printf("-1");
      return 0;
    }
  }
  printf("%lld", lc);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   string s,t;
   cin>>s>>t;
   cout<<t<<s<<"\n";
   
   return 0;        
}  
   

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

int main()
{
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            if (0 <= s-i-j and s-i-j <= k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll x,y,a,b,c,n;

void solve(){
    cin >> x >> y >> a >> b >> c;
    priority_queue<ll, vector<ll>> pq;
    ll A[a], B[b], C[c];
    for(auto &i : A) cin >> i;
    for(auto &i : B) cin >> i;
    for(auto &i : C) cin >> i;
    sort(A, A + a, greater<ll> ());
    sort(B, B + b, greater<ll> ());
    for(int i = 0; i < x; i++)
        pq.push(A[i]);
    for(int i = 0; i < y; i++)
        pq.push(B[i]);
    for(auto i : C) pq.push(i);
    ll ans = 0, cnt = 0;
    while(cnt < x + y){
        ans += pq.top();
        pq.pop();
        cnt++;
    }
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 8816
#include <iostream>
#include <cmath>
#include <algorithm>
#include <deque>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
// #define mp make_pair
// #define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define show(x) cout << #x << " = " << x << endl;





int main(){

  int q;
  cin >> q;
  int l[q],r[q];
  REP(i,q){
    cin >> l[i] >> r[i];
  }
  bool memo[200001];
  bool memo2[100000];
  int memo3[100000];
  REP(i,200001){
    memo[i] = false;
  }
  REP(i,100000){
    memo2[i] = false;
    memo3[i] = 0;
  }

  bool flag;
  for(int i = 2; i <= 100000; i++){
    flag = true;
    for(int j = 2; j*j <= i; j++){
      if(i % j == 0)flag = false;
    }
    if(flag){
      memo[i] = true;
      memo[i*2] = true;
    }
  }

  for(int i = 3; i < 100000; i+=2){
    if(memo[i] && memo[i+1]){
      memo2[i] = true;
    }
  }
  memo3[1] = 0;
  for(int i = 3; i < 100000; i+=2){
    if(memo2[i]){
      memo3[i] = memo3[i-2] + 1;
    }else{
      memo3[i] = memo3[i-2];
    }
  }

  REP(i,q){
    if(l[i] == 1){
      cout << memo3[r[i]] << endl;
    }else{
      cout << memo3[r[i]] - memo3[l[i]-2] << endl;
    }
  }



  return 0;
}


Measured memory_bytes: 2048
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define repr(i,a,b) for (int i = a; i > b; --i)
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)

#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define _ <<" "<<

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <iterator>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <limits.h>
#include <iomanip>
#include <cctype>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;

int diff[100100];

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	int data[n];
	data[0] = 0;
	rep(i, 0, n) cin>>data[i+1];
	data[n+1] = 0;
	int sum = 0;
	rep(i, 1, n+1)
	{
		sum += abs(data[i] - data[i-1]);
			diff[i] = abs(data[i+1] - data[i]) + abs(data[i] - data[i-1]) - abs(data[i+1] - data[i-1]);
	}
	sum += abs(0 - data[n]);
	rep(i, 1, n+1)
	{
		cout<<sum - diff[i]<<"\n";
	}
	return 0;
}


Measured memory_bytes: 2048
//IOI 2021
//labriz kon code ra, ham paye ie AC manam, AC age yari kone ta sob man code miznm :)
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 100 * 1000 + 17;

ll n, a[MAXN], sumALL;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i], sumALL += a[i];
	sort(a + 1, a + n + 1);
	int l = 0, r = n;
	while (l + 1 < r) {
		int mid = (l + r) / 2;
		ll sum = a[mid];
		for (int i = 1; i < mid; i++)
			sum += a[i];
		for (int i = mid + 1; i <= n; i++)
			if (a[i] <= 2 * sum)
				sum += a[i];
		if (sum == sumALL)
			r = mid;
		else
			l = mid;
	}
	cout << n - r + 1 << endl;
	return 0;
}


Measured memory_bytes: 1024
import sys
a, b, c = map(int, input().split())
if a == b and b == c and a % 2 == 0:
    print(-1)
    sys.exit(0)
count = 0
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    a, b, c = b // 2 + c // 2, a // 2 + c // 2, a // 2 + b // 2
    count += 1
print(count)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int pre = 0;
    int max = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      int h = sc.nextInt();
      if (pre >= h) {
        cnt++;
      } else {
        cnt = 0;
      }
      max = Math.max(max, cnt);
      pre = h;
    }

    System.out.println(max);

  }
}

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

using namespace std;

#define ll long long

//#define TEST

signed main() {
	int n, m;
	cin >> n >> m;
	vector<vector<ll>> job(m + 1);
	// job[i] : i日後に報酬がもらえる仕事の報酬
	for (int i = 0; i < n; ++i) {
		int a;
		ll b;
		cin >> a >> b;
		if (a > m) continue; // できない仕事
		job[a].push_back(b);
	}

	/* job[i]をそれぞれ降順にソート */
	for (int i = 0; i <= m; ++i) {
		sort(
			job[i].begin(),
			job[i].end(),
			[](ll a, ll b) {
				return b < a;
			}
		);
	}

#ifdef TEST // jobの確認
	for (int i = 1; i <= m; ++i) {
		cout << "----------job[" << i << "]----------" << endl;
		for (auto ji : job[i])
			cout << ji << " ";
		cout << endl;
	}
#endif

	/* i=m,m-1,...,0日目にできる仕事のなかで高額報酬なものを行う. */
	priority_queue<ll> q; // 可能な仕事の報酬を降順に持つ
	ll ans = 0;
	for (int i = m; i >= 0; --i) {
		// m-i日後に報酬がもらえる仕事をqに追加
		for (auto bi : job[m - i])
			q.push(bi);
		if (q.size() > 0) {
			ans += q.top();
			q.pop();
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int t = sc.nextInt();
		int d = 0;
		for (int i = 0; i < t; i++) {
			int a = sc.nextInt();
			if (a > (k + 1) / 2) {
				d += (a - (k + 1) / 2) * 2 - 1;
			}
		}
		System.out.println(d);
	}
}


Measured memory_bytes: 9804
h, w, n = map(int,input().split())
sr, sc = map(int,input().split())
s = input()
t = input()


def b():
    M = [[h-sr,h-1], [sr-1,h-1], [w-sc,w-1], [sc-1,w-1]]
    D = [["U","D"], ["D","U"], ["L","R"], ["R","L"]]

    for i in range(4):
        # print(M[i])
        j = 0
        while j < n and M[i][0] >= 0:
            if s[j] == D[i][1]:
                M[i][0] -= 1
                if M[i][0] < 0:
                    return "NO"
            if t[j] == D[i][0]:
                M[i][0] = min(M[i][0]+1, M[i][1])                
            # print(i, M[i][0])
            j += 1
    return "YES"

print(b())

Measured memory_bytes: 41840
package main

import "fmt"

var anss = [...]string{"AC", "WA", "TLE", "RE"}

func main() {
	n := 0
	r := make(map[string]int)
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		r[s]++
	}

	for _, ans := range anss {
		fmt.Println(ans, "x", r[ans])
	}
}


Measured memory_bytes: 6332
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main () {
  int N;
  cin >> N;
  int v[N], c[N];
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> c[i];
  }

  int ans = 0;  
  for (int i = 0; i < N; i++) {
    if (v[i] - c[i] > 0) ans+=v[i]-c[i];  
  }
  
  cout << ans;
}


Measured memory_bytes: 256
#include<stdio.h>
void swap(int *x, int *y) {
	int temp = *x;
	*x = *y;
	*y = temp;
}

void bubble_sort(int a[]) {
	int i;
	int j;
	for (j = 0; j < 5; j++) {
		for (i = 5 - 1; i > 0; i--) {

			if (((a[i - 1]-1)%10 > (a[i]-1)%10)) {
				swap(&a[i], &a[i - 1]);
			}

		}
	}

}
int main(void) {
	int t = 0;
	int i;
	int a[5];
	for (i = 0; i < 5; i++) {
		scanf("%d",&a[i]);
	}

	bubble_sort(a);

	

	for (i = 4; i > 0; i--) {
		//cout << a[i]<<"\n";
		if (a[i] % 10 > 0)
			t += a[i] + (10 - a[i] % 10);
		else
			t += a[i];
	}
	t += a[0];
	
printf("%d",t);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define maxn 200010
#define count _count

vector <int> adj[maxn], cd[maxn], st[maxn];
int totcnt[maxn], totcnt2[maxn], pv[maxn];
int par[maxn], mx[maxn];
map <int, int> cnt[maxn], cnt2[maxn];
int ans[maxn];

void dfs (int v, int p){
	par[v]= p;
	mx[v]= max(v, mx[p]);
	st[mx[v]].push_back(v);
	for (int i=0; i<adj[v].size(); i++){
		int nt= adj[v][i];
		if (nt==p) continue;
		dfs(nt, v);
	}
}

void count (int m, int c, int v){
	if (v>m) return;
	totcnt[m]++;
	cnt[m][c]++;
	pv[v]=c;
	for (int i=0; i<adj[v].size(); i++){
		int nt= adj[v][i];
		if (nt==par[v]) continue;
		if (mx[nt]!=m) continue;
		count(m, c, nt);
 	}
}

void count2 (int m, int c, int v){
	if (v>mx[par[m]]) return;
	totcnt2[m]++;
	cnt2[m][c]++;
	for (int i=0; i<adj[v].size(); i++){
		int nt= adj[v][i];
		if (nt==par[v]) continue;
		count2(m, c, nt);
	}
}

void find (int v, int p){
	if (v==1){
		ans[v]=0;
	}
	else if (par[v]==1){
		ans[v]=2;
	}
	else{
		if (v==mx[v]){
			int up= mx[par[v]];
			if (mx[par[v]]!=par[v]) ans[v]= totcnt2[v]+ans[up]+cnt[up][pv[par[v]]]+1-cnt2[up][pv[par[v]]];
			else ans[v]= totcnt2[v]+ans[up]+1;
		}
		else{
			int up= mx[v];
			ans[v]=cnt[up][pv[v]]-cnt2[up][pv[v]]+ans[up];
		}
	}
	for (int i=0; i<adj[v].size(); i++){
		int nt= adj[v][i];
		if (nt==par[v]) continue;
		find(nt, v);
	}		
}



int main(){
	int n, u, v;
	cin>>n;
	for (int i=1; i<=n; i++) totcnt[i]=1;
	for (int i=1; i<n; i++){
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(1, 0);
	for (int i=2; i<=n; i++){
		if (mx[i]==i) {
			for (int j=0; j<adj[i].size(); j++){
				if (adj[i][j]==par[i]) continue;
				count(i, adj[i][j], adj[i][j]);
				count2(i, adj[i][j], adj[i][j]);
			}
		}
	}
	find(1, 0);
	for (int i=2; i<=n; i++) cout<<ans[i]-1<<" ";
	cout<<endl;	

}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

int main(void){

	int N; cin >> N;
	vector<int> A(N);

	map<int, int> mp;
	REP(i,N-1){
		int A; cin >> A;
		mp[A-1]++;
	}

	REP(i,N){
		cout << mp[i] << endl;
	}

	return 0;

}


Measured memory_bytes: 13468
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 

const long long INF = (long long) 1e11+1;
const long long mod = (long long) 100000000 ;
const long long hell = (long long) 1000000007;


ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x*res);
    x=(x*x);    
    y=y/2;
  }
  return res;
}

ll modinv(ll x,ll m){
  return power(x,m-2);
}

void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


void solve(){
    double r;
    cin>>r;
    double c=2*M_PI*r;
    cout<<fixed<<setprecision(12)<<c;
}


int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;
  
   while(test--)
   solve();
}

///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

// gcd of strings
/*
string getgcd(string s1,string s2){
    
    while(true){
        if(s1.length()<s2.length()){
            swap(s1,s2);
            continue;
        }
        if(s2.empty())
        return s1;
        
        if(s1.substr(0,s2.length())!=s2)
        return "";
        
        s1=s1.substr(s2.length());
    }
}
*/
/*
// for user defined DS hashmap and set
 
struct hash_pair{
      size_t operator()(const pair<int,pair<int,int>>& p) const{
          auto hash1=hash<int>()(p.F) ;
          auto hash2=hash<int>()(p.S.F) ;
          auto hash3=hash<int>()(p.S.S) ;
          return (hash1^hash2)^hash3;
      }  
};
struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
*/



Measured memory_bytes: 3800
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >> a;
  while(1){
    b = sqrt(a);
    if(ceil(b)!=floor(b));
    else{
      cout << b*b << endl;
      break;
    }
    a--;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<ll>A(n);
    for(int i=0; i<n; i++) {cin >> A[i]; A[i]-=i+1;}
    ll sum1= 0;
    ll sum2= 0;
    
    sort(A.begin(), A.end());
    for(int i=0; i<n; i++){
        sum1+= abs(A[i]-A[n/2]);
        sum2+= abs(A[i]-A[(n-1)/2]);
    }
    cout << min(sum1, sum2) << endl;
    return 0;
}

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


int main() {
    int r, D, x;
    cin >> r >> D >> x;
    int X[11];
    X[0] = x;
    for ( int i = 1; i < 11; i++ ) {
        X[i] = r*X[i-1] - D;
    }
    for ( int i = 1; i < 11; i++ ) {
        cout << X[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<list>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<set>
using namespace std;
bool a[2 * 123456 + 1];
int main() {
	fill(a, a + 2 * 123456 + 1, true);
	a[0] = false;
	a[1] = false;
	for (int i = 2; i <= 2 * 123456; i++) {
		if (a[i]) {
			int j = 2;
			while (i*j <= 2 * 123456) {
				a[i*j] = false;
				j++;
			}
		}
	}
	int n;
	while (cin >> n&&n != 0) {
		int sum = 0;
		for (int i = n + 1; i <= n * 2; i++) {
			if (a[i]) sum++;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3228
#include<stdio.h>

int main(void)
{
	int i;
	int j;
	
	for(i = 1;i <= 9;i++){
		for(j = 1;j <= 9;j++){
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	
	return (0);
}

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

const int N = 1e5 + 5;
int p[N];
vector< int> conn[N];
int link[N], size[N];

int find(int x) {
    return x == link[x] ? x : link[x] = find(link[x]);
}

void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b) return;
    if (size[a] < size[b]) swap(a, b);
    size[a] += size[b];
    link[b] = a;
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i) scanf("%d", p + i);
    for (int i = 1; i <= n; ++i) link[i] = i, size[i] = 1;

    while (m--) {
        int x, y;
        scanf("%d %d", &x, &y);
        unite(p[x], p[y]);
    }

    int res = 0;
    for (int i = 1; i <= n; ++i) {
        if (find(i) == find(p[i])) res++;
    }
    printf("%d\n", res);
}

Measured memory_bytes: 3712
#include <stdio.h>

int main(void){
	int much, many, how, bg[1000], ans, i, j, tmp;
	while(scanf("%d %d", &many, &how) != 0){
		if(many == 0 && how == 0) break;
		for(i = 0; i < many; i++) scanf("%d", &bg[i]);
		for(i = 0; i < many - 1; i++){
			for(j = i + 1; j < many; j++){
				if(bg[i] < bg[j]){
					tmp = bg[i];
					bg[i] = bg[j];
					bg[j] = tmp;
				}
			}
		}
		ans = 0;
		for(i = 0; i < many; i++){
			if(i % how == how - 1) continue;
			ans += bg[i];
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main() {
  int n;
  string s,t;
  cin>>n>>s>>t;
  int c=0;
  bool flag=false;
  for(int i=0;i<s.size();i++){
    if(s[i]==t[0]){
      int cnt=1;
      if(i==s.size()-1) {c=1;break;}
      for(int j=1;j<t.size();j++){
        if(s[i+j]==t[j]) cnt++;
        else break;
        if(i+j==s.size()-1) {c=cnt;flag=true;break;}
      }
      if(flag) break;
    }
  }
  cout<<s.size()+t.size()-c<<endl;
}
        
    
      
    

Measured memory_bytes: 256
n = int(input())
score = list(map(int, input().split()))
target = list(map(int, input().split()))

sub = [score[i] - target[i] for i in range(n)]
ans = 0

if sum(score) < sum(target): ans = -1
else:
    minus = []
    plus = []
    for i in range(n):
        if(sub[i] < 0): minus.append(-sub[i])
        elif(sub[i] > 0): plus.append(sub[i])
    plus = sorted(plus, reverse = True)
    sum_minus = sum(minus)

    ans += len(minus)
    while sum_minus > 0:
        if sum_minus <= plus[0]:
            plus[0] = 0
            sum_minus = 0
        else:
            sum_minus -= plus.pop(0)
        ans += 1

print(ans)

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

using namespace std;

int main(){
  int n, m; cin >> n >> m;
  vector<int> num(n);
  for(int i=0;i<m;i++){
    int a, b; cin >> a >> b;
    num[a-1]++;
    num[b-1]++;
  }
  for(int i=0;i<num.size();i++){
    cout << num[i] << endl;
  }
}

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

int main(){
    int K;
    string S;
    cin >> K >> S;
    if(S.size() <= K){
        cout << S << endl;
    }else{
        rep(i,K) cout << S.at(i);
        cout << "..." << endl;
    }
}

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

bool judge(int N){
	for(int i=2;i*i<=N;i++){
		if(N%i==0) return false;
	}
	return true;
}

int main(){
	int X;
	cin >> X;
	while(1){
		if(judge(X)){
			cout << X << endl;
			return 0;
		}
		X++;
	}
	return 0;
}

Measured memory_bytes: 3636
N = int(input())
S = input()

S = list(S)

for i in range(len(S)):
    S[i] = ord(S[i])
    if S[i] + N >= 91:
        S[i] += N - 26
    else:
        S[i] += N
    S[i] = chr(S[i])

print("".join(S))


Measured memory_bytes: 3060
from bisect import *
from collections import defaultdict
import sys
input = sys.stdin.readline

S = input().rstrip()
T = input().rstrip()
L = len(S)

dic = defaultdict(list)
for i, s in enumerate(S):
    dic[s].append(i)


s0 = -1
cnt = 0
for t in T:
    if not dic[t]:
        print(-1)
        exit()
    p = bisect_right(dic[t],s0)
    if p >= len(dic[t]):
        cnt += 1
        s0 = min(dic[t])
    else:
        s0 = dic[t][p]

print(L*cnt+s0 +1)

Measured memory_bytes: 80108
import collections
N = int(input())
a = list(map(int,input().split()))
ans = sum(a)
cnt = collections.Counter(a)
for i in range(int(input())):
  b,c = map(int,input().split())
  ans += (c-b)*cnt[b]
  cnt[c] += cnt[b]
  cnt[b] = 0
  print(ans)

Measured memory_bytes: 24000
n = int(input())
s = [input() for _ in range(n)] # 見た目がスッキリするリスト内包表記で入力を受け取っています。forループを使っても同じです。

ss = set(s) # sのset型を作ります。これは悪い変数名ですが、短いコードなので適当でいいと思います。
ans = len(ss) # これで種類数がわかります。
print(ans)

Measured memory_bytes: 35728
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

const ll N_MAX = 300;
vector<vector<ll>> A(N_MAX,vector<ll>(N_MAX));
ll N;

int main() {
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++) {
            cin >> A[i][j];
        }
    }
    vector<Pll> Ps;
    vector<vector<ll>> B(N,vector<ll>(N,INF));
    for(int i=0;i<N;i++) B[i][i]=0;
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(i==k || j==k) continue;
                B[i][j] = min(B[i][j],A[i][k]+A[k][j]);
            }
        }
    }

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(B[i][j]<A[i][j]){
                cout << -1 << endl;
                return 0;
            }
            else if(B[i][j]>A[i][j]) Ps.push_back(Pll(i,j));
        }
    }

    ll ans = 0;
    for(auto e : Ps){
        ans += A[e.first][e.second];
    }
    cout << ans/2 << endl;


    return 0;
}

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

int main(void){
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    
    int cnt = 0;
    while(A >= B){
        B *= 2;
        cnt++;
    }
    while(B >= C){
        C *= 2;
        cnt++;
    }
    
    if(cnt <= K){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3640
# coding: utf-8
# Here your code !

cards = {
        'S': [0] * 13,
        'H': [0] * 13,
        'C': [0] * 13,
        'D': [0] * 13
}

n = int(input())

for i in range(n):
    s,num = input().split()
    num = int(num)
    cards[s][num - 1] = 1

for c in ["S","H","C","D"]:
    for i in range(13):
        if cards[c][i] == 0:
            print(c, str(i + 1))

Measured memory_bytes: 7660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <cmath>
using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// 0 <= unsigned int <= 4.2e9

int main()
{
    vector<int> v{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    uint k; cin >> k;
    cout << v[k-1] << endl;
}


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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int n, a;
	ll ans = 0;
	cin >> n;
	rep(i, n){
		cin >> a;
		while(a % 2 == 0){
			ans++;
			a /= 2;
		}
	}
	cout << ans << endl;
	return 0;
}

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

const int NOTV = 0;
const int VIST = 1;
const int NMAX = 10000;
//const int VMAX = 2000;
const int NILL = -1;
const int INF = 1 << 21;
//int a[NMAX][NMAX];  //??£??\??????
int n;
vector<pair<int, int> > adj[NMAX];

void dijkstra() {
	int d[NMAX];
	int vst[NMAX];
	priority_queue<pair<int, int> > pq;
	for (int i = 0; i < n; i++) {
		vst[i] = NOTV;
		d[i] = INF;
	}
	d[0] = 0;
	pq.push(make_pair(d[0], 0));
	while (not pq.empty()) {
		pair<int, int> f = pq.top(); pq.pop();
		int u = f.second;
		vst[u] = VIST;
		if (d[u] < f.first*(-1)) continue;
		for (int i = 0; i < adj[u].size(); i++) {
			int v = adj[u][i].first;
			if (vst[v] == NOTV) {
				if (d[u] + adj[u][i].second < d[v]) {
					d[v] = d[u] + adj[u][i].second;
					pq.push(make_pair(d[v] * (-1), v));
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i << ' ' << d[i] << endl;
	}
}

int main() {
	cin >> n;
	int k, u, v, c;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> c;
			adj[u].push_back(make_pair(v, c));
		}
	}
	dijkstra();
	return 0;
}

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

int main() {
	string s;
  	cin>>s;
  
  char he=s[6];
  	
  
 if(s[5]=='1'){
	cout<<"TBD"<<endl;
 }
 else{ 
  switch(he){
    case '1':
      cout<<"Heisei"<<endl;
      break;
    case '2':
    cout<<"Heisei"<<endl;
      break;
    case '3':
    cout<<"Heisei"<<endl;
      break;
    case '4':
    cout<<"Heisei"<<endl;
      break;
    case '5':
    cout<<"TBD"<<endl;   
      break;
 	case '6':
 	cout<<"TBD"<<endl; 
      break;
 	case '7':
 	cout<<"TBD"<<endl; 
		break;
 	 case '8':
	 cout<<"TBD"<<endl; 
	break;
	 case '9':
	 cout<<"TBD"<<endl; 
      break;
      
  }
 
}
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    char a, b;
    cin >> a >> b;
    if(a == 'H'){
        if(b == 'H'){
            cout << 'H' << endl;
        } else {
            cout << 'D' << endl;
        }
    } else {
        if(b == 'H'){
            cout << 'D' << endl;
        } else {
            cout << 'H' << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;

const int INF = 100000000;



int GCD(int a, int b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    return GCD(b, a%b);
}

ll a[100010];

bool cmp(const pair<int, int> &a, const pair<int, int> &b){
    if(a.first == b.first) return a.second == b.second;
    return a.first < b.first;
}
vector<pair<int, int>> vp;
int arr[210];
int main() {
    //cout << fixed << setprecision(15);

    int N, L; cin >> N >> L;

    for(int i=1; i<=N; ++i){
        arr[i] = L+i-1;
    }

    int sum=0;

    for(int i=1; i<=N; ++i){
        sum += arr[i];
    }

    int minV = 100000;
    int ans=0;
    for(int i=1; i<=N; ++i){
        int a = sum - arr[i];

        if(minV > abs(a - sum)){
            minV = abs(a-sum);
            ans = a;
        }
    }
    cout << ans << endl;





    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL)x=x->right;
  return x;
}

Node treeSearch(Node u, int k){
  if (u == NIL || k == u->key)return u;
  if (k < u->key)return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)return treeMinimum(x->right); // case 1
  y = x->parent;
  while(y != NIL && x == y->right){
    x=y;
    y = y->parent;
  }
  return y; // case 2
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL)y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL)x=y->left;
  else x=y->right;

  if(x!=NIL)x->parent=y->parent;

  if(y->parent==NIL)root=x;
  else if(y==y->parent->left)y->parent->left=x;
  else y->parent->right=x;

  if(y != z)z->key=y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else if(z->key < y->key)y->left=z;
  else y->right = z;
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

using namespace std;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  string res = "NO";
  for (int i = 1; i <= B; ++i) {
    if ((A * i) % B == C) res = "YES";
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

typedef long long LL;

const int maxm=1e5+5;
const LL mo=1e9+7;

struct ARR{
	LL n[3][3];
};
ARR re;
ARR operator * (const ARR &a,const ARR &b)
{
	fo(i,0,2)
		fo(j,0,2)
		{
			re.n[i][j]=0;
			fo(k,0,2) (re.n[i][j]+=a.n[i][k]*b.n[k][j])%=mo;
		}
	return re;
}

int m;
LL n,x[maxm];

ARR C,ans;
void mi(LL y)
{
	for(; y; y>>=1, C=C*C) if (y&1) ans=ans*C;
}

int main()
{
	scanf("%lld %d",&n,&m);
	fo(i,1,m) scanf("%d",&x[i]);
	x[++m]=n;
	sort(x+1,x+1+m);
	
	ans=(ARR){{{1,0,0},{0,0,0},{0,0,0}}};
	x[0]=-1;
	fo(i,1,m)
	{
		LL len=x[i]-(x[i-1]+1);
		C=(ARR){{{1,2,1},{0,1,1},{1,2,2}}};
		mi(len);
		if (i==m) break;
		C=(ARR){{{1,2,1},{0,1,1},{0,0,1}}};
		ans=ans*C;
	}
	
	printf("%lld\n",ans.n[0][2]);
}

Measured memory_bytes: 1024