akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(),x = sc.nextInt(),y = sc.nextInt();
    ArrayList<ArrayList<Integer>> g = new ArrayList<ArrayList<Integer>>();
    int count[]=new int[n];
    for(int i=0;i<n;i++){
      g.add(new ArrayList<Integer>());
      if(i!=0){
        g.get(i).add(i-1);
      }
      if(i!=n-1){
        g.get(i).add(i+1);
      }
    }
    g.get(x-1).add(y-1); g.get(y-1).add(x-1);

    for(int i=0;i<n;i++){
      int di[]=dijk(n,i,g);
      for(int j=i+1;j<n;j++){
        count[di[j]]++;
      }
    }
    for(int i=1;i<n;i++){
      pl(count[i]+"");
    }
  }

  public static int[] dijk(int n,int s,ArrayList<ArrayList<Integer>> g){
    int dist[]=new int[n];
    boolean flg[]=new boolean[n];
    ArrayList<Integer> list = new ArrayList<Integer>();
    list.add(s);
    dist[s]=0;
    flg[s]=true;
    while(list.size()!=0){
      int num = list.get(0);
      list.remove(0);
      for(int i:g.get(num)){
        if(!flg[i]){
          list.add(i);
          flg[i]=true;
          dist[i]=dist[num]+1;
        }
      }
    }
    return dist;
  }

  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
}


Measured memory_bytes: 61804
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int r, g;
  cin >> r >> g;

  // 解答
  cout << r + 2 * (g - r) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int max_length = 10;

int main() {
    ll K;
    cin >> K;

    vector<ll> values;
    vector<vector<ll> > bit_values(max_length, vector<ll>());
    for(ll i=1; i<=9; i++) {
        values.push_back(i);
        bit_values[0].push_back(i);
    }

    for(int bit=1; bit < max_length; bit++) {
        for(ll x: bit_values[bit-1]) {
            for(ll i = 0; i <= 9; i++) {
                if(abs(x%10 - i) <= 1) {
                    bit_values[bit].push_back(x * 10 + i);
                    values.push_back(x * 10 + i);
                }
            }
        }
    }

    sort(ALL(values));
    cout << values[K-1] << endl;

    return 0;
}

Measured memory_bytes: 4464
import java.io.*;

class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str[] = br.readLine().split(" ",0);
    int n[] = new int[str.length];
    int count = 0;

    for(int i = 0; i < str.length; i++) n[i] = Integer.parseInt(str[i]);

    for(int x = n[0]; x <= n[1]; x++){
      if(n[2] % x == 0) count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 24452
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int N=1e5+11,INF=~0u>>2;
char s[N];
int k;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int main(){
//	freopen("ex.in","r",stdin);
	scanf("%s",s);k=read();
	for(int i=0;s[i];++i){
		if(s[i]=='a') continue;
		int t='z'+1-s[i];
		if(k>=t){
			k-=t;
			s[i]='a';
		}
	}
	int len=strlen(s);
	s[len-1]+=k%26;
	if(s[len-1]>'z') s[len-1]='a'+s[len-1]-'z'-1;
//	while(k--){
//		s[len-1]++;
//		if(s[len-1]>'z') s[len-1]='a';
//	}
	printf("%s",s);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vvll edges(n, vll(n, 0));
  REP(i, n) {
    ll u, K; cin >> u >> K;
    REP(k, K) {
      ll to; cin >> to;
      edges.at(u-1).at(to-1) = 1;
    }
  }
  REP(i, n){
    REP(j, n) {
      cout << edges.at(i).at(j);
      if (j != n-1) cout << ' ';
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    ll a, b, c, k;
    cin>>a>>b>>c>>k;
    if(k%2)cout<<b-a<<"\n";
    else cout<<a-b<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


void rotate(int *a, int b, int m, int e)
{
  int i;
  int tmp[e-b];
  for (i=0; i<e-b; i++)
    tmp[i] = a[b+i];
  for (i=0; i<e-b; i++)
    a[(i+e-m)%(e-b)+b] = tmp[i];
}

int main()
{
  int i, n, q, b, e, m;
  fscanf(stdin, "%d", &n);
  int a[n];
  for (i=0; i<n; i++)
    fscanf(stdin, "%d", &a[i]);

  fscanf(stdin, "%d", &q);
  for (i=0; i<q; i++) {
    fscanf(stdin, "%d %d %d", &b, &m, &e);
    rotate(a, b, m, e);
  }
  for (i=0; i<n-1; i++)
    printf("%d ", a[i]);
  printf("%d\n", a[i]);
  
  return 0;
}



Measured memory_bytes: 2100
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i,a,b) for (int i=a; i<(b); i++)
#define FOR(i,a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b); i >= a; i--)
#define FORd(i,a) for (int i = (a); i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy

int main() {


    int n;
    int k;
    cin>>n>>k;
    vi a(n);
    FOR(i,n)
    {
        cin>>a[i];
    }
    vector <ll> dp(n);
    fill(dp.begin(),dp.end(),1e12);
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i-j<0)
            {
                break;
            }
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<dp[n-1];
	return 0;
}













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

using namespace std;
#define _for(i,j,N) for(int i = (j); i < (N);i++)
#define _rep(i,j,N) for(int i = (j); i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= 0;i--)
#define _dep(i,j,N) for(int i = (N); i>= 0;i--)
#define ALL(x) x.begin(),x.end()
#define LL long long
#define ULL unsigned LL
#define PB push_back

int R,G,B,N;

int main()
{
    cin >> R >> G >> B >> N;
    LL cnt = 0;
    int i = 0;
    while(i*R <= N){
        int j = 0;
        while(i*R + j*G <= N){
            if((N - i*R - j*G)%B == 0) ++cnt;
            ++j;
        }
        ++i;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rep(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define forn(i,n,m) for(int (i)=(n);i<=(int)(m);(i)++)
#define pb push_back
#define mp make_pair
#define re return
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF=1e9;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef queue <int> qi;
ll pre[200007];
vector< pair<ll,ll> >v;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n,d,a;
    cin>>n>>d>>a;
    for(int i=1;i<=n;++i){
        long long x,y;
        cin>>x>>y;
        long long z=(y-1)/a+1;
        v.push_back({x,z});
    }
    sort(v.begin(),v.end());
    long long ans=0;
    long long sum=0;
    int r=1;
    for(int i=0;i<n;++i){
        while(r<n&&v[r].first<=v[i].first+2*d)
            ++r;
        sum-=pre[i];
        v[i].second-=sum;
        if(v[i].second<=0)
            continue;
        sum+=v[i].second;
        pre[r]+=v[i].second;
        ans+=v[i].second;
    }
    cout<<ans<<endl;
    return 0;
}

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

int a,b;
string s;

int main(){
    cin >> a >> b >> s;
    for(int i = 0; i < s.size(); i++){
        if( (i != a) && s[i] == '-'){
            cout << "No" << endl;
            return 0;
        }else if((i == a) && s[i] != '-'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
t = int(input())
for _ in range(t):
  n, k = map(int, input().split())
  xlst = list(map(int, input().split()))
  diff = [j - i for i, j in zip(xlst, xlst[1:])]
  diff.sort(reverse=True)
  print(xlst[-1] - xlst[0] - sum(diff[:min(n - 1, k - 1)]))


Measured memory_bytes: 21272
t = list(map(int, input().split()))
a = t[0]
b = t[1]
h = t[2]
m = t[3]
import math

h_c = 30*h + 0.5*m
m_c = 6*m

z = abs(h_c - m_c)
if z > 180:
  z = 360 - z
if z == 180:
  print(t[0]+t[1])
elif z == 0:
  print(abs(t[0]-t[1]))
else:
  a = a**2
  b = b**2
  k = round(math.cos(math.radians(z)),30)
  print(math.sqrt(a + b - 2*t[0]*t[1]*k))


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

int main(){
    int N,H;
    cin>>N>>H;
    vector<int> A(N);
    vector<int> B(N);
    for(int i=0; i<N; i++) cin>>A[i]>>B[i];

    sort(A.begin(),A.end(),greater<int>());
    sort(B.begin(),B.end(),greater<int>());

    int ans = 0;
    int life = 0;

    for(int i=0; i<N; i++){
        if(life >= H) break;
        if(B[i] < A[0] ) break;
        life += B[i];
        ans++;
    }

    while(life < H){
        life += A[0];
        ans++;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
int n;
set <int> s;

int main(){
  cin >> n;
  REP(i,n){
    int k;
    cin >> k;
    s.insert(k);
  }
  int ans = s.size();
  if(ans%2 ==0) ans --;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	int ans,val=INF,dum=0;
	rep(i,n)std::cin >> a[i];
	for (int i = -100; i <=100; i++) {
		/* code */
		dum=0;
		rep(j,n){
			dum+=(i-a[j])*(i-a[j]);
		}
		if(dum<val){val=dum;ans=i;}
	}
	std::cout << val<< std::endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = sc.nextLong()
    val x = sc.nextLong()
    val r = b / x - if (a > 0) (a - 1) / x else -1
    println(r)
}

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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1000000000;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;

int H, W;
char field[30][30];
int sx, sy;
ll d[30][30];
ll depth;

//移動4方向のベクトル
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll bfs() {
  queue<P> que;
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++) d[i][j] = INF;

  que.push(P(sx, sy));
  d[sx][sy] = 0;

  depth = 0;

  while (que.size()) {
    P p = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if (0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] == '.' &&
          d[nx][ny] == INF) {
        que.push(P(nx, ny));
        d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }
  ll res = 0;
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++) {
      if (d[i][j] == INF) continue;
      res = max(d[i][j], res);
    }
  return res;
}
int main() {
  cin >> H >> W;
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++) cin >> field[i][j];
  ll res = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (field[i][j] == '.') sx = i, sy = j;
      res = max(res, bfs());
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int H, W;
	while (std::cin>>H>>W) {
		if (H == 0 && W == 0) {
			break;
		}
		for (int i = 0;i < H;i++) {
			for (int j = 0;j < W;j++) {
				if (i% 2 == 0) {
					if (j % 2 == 0) {
						std::cout << "#";
					}
					else {
						std::cout << ".";
					}
				}
				else {
					if (j % 2 == 0) {
						std::cout << ".";
					}
					else {
						std::cout << "#";
					}
				}
				if (j == W - 1) {
					std::cout << std::endl;
				}
			}
			}
		std::cout << std::endl;
	}
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ( A+B > C+D ) {
    cout << "Left" << endl;
  }
  else if ( A+B < C+D ) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

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

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int a,b;
  cin>>a>>b;
  int ans=a-2*b;
  if(ans<0){
    ans=0;
  }
  cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

constexpr int MOD = 1000000007;


constexpr int LIM = 100000;
int N, M;
int v[100010];

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

    cin >> N >> M;
    fill(v, v+100010, 0);
    for (int j = 0; j < N; ++j) {
        int w;
        cin >> w;
        v[w] ++;
    }

    int ret = 0;

    for (int j = 0; j <= M/2; ++j) {
        int rj = (M - j) % M;

        int countj = 0;
        for (int k = j; k <= LIM; k += M) {
            countj += v[k];
        }

        int countrj = 0;
        for (int k = rj; k <= LIM; k += M) {
            countrj += v[k];
        }

        int del = min(countj, countrj);
        ret += del / (j == rj ? 2 : 1);
        int tmp = j == rj ? del / 2 * 2 : del;
        for (int k = j; k <= LIM; k += M) {
            if (v[k] % 2 == 1) {
                --v[k]; --tmp;
            }
        }
        for (int k = j; k <= LIM && tmp > 0; k += M) {
            int dec = min(v[k], tmp);
            tmp -= dec; v[k] -= dec;
        }

        if (rj != j) {
            tmp = del;
            for (int k = rj; k <= LIM; k += M) {
                if (v[k] % 2 == 1) {
                    --v[k]; --tmp;
                }
            }
            for (int k = rj; k <= LIM && tmp > 0; k += M) {
                int dec = min(v[k], tmp);
                tmp -= dec; v[k] -= dec;
            }
        }
    }

    for (int j = 0; j <= LIM; ++j) {
        ret += v[j] / 2;
    }

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 640
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#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 <limits>//setprecision
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
long long MOD = 1000000007;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

priority_queue<tuple<long long,int,int,int>> PQ;
set<tuple<int,int,int>> already;
vector<long long> OUTPUT;
void func(int K,vector<long long> &A,vector<long long>&B,vector<long long>&C){
    if(OUTPUT.size() >= K) return;
    tuple<long long,int,int,int> cake = PQ.top();PQ.pop();
    OUTPUT.push_back(get<0>(cake));
    long long delicious = get<0>(cake);
    int a = get<1>(cake),b = get<2>(cake),c = get<3>(cake);
    if(!already.count(make_tuple(a+1,b,c)) && a+1 < A.size()){
        PQ.push(make_tuple(delicious+A.at(a+1)-A.at(a),a+1,b,c));
        already.insert(make_tuple(a+1,b,c));
    }
    if(!already.count(make_tuple(a,b+1,c)) && b+1 < B.size()){
        PQ.push(make_tuple(delicious+B.at(b+1)-B.at(b),a,b+1,c));
        already.insert(make_tuple(a,b+1,c));
    }
    if(!already.count(make_tuple(a,b,c+1)) && c+1 < C.size()){
        PQ.push(make_tuple(delicious+C.at(c+1)-C.at(c),a,b,c+1));
        already.insert(make_tuple(a,b,c+1));
    }
    func(K,A,B,C);
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int a,b,c;cin >> a >> b >> c;
    int K;cin >> K;
    vector<long long> A(a),B(b),C(c);
    for(int i = 0;i<a;i++) cin >> A.at(i);
    for(int i = 0;i<b;i++) cin >> B.at(i);
    for(int i = 0;i<c;i++) cin >> C.at(i);
    sort(A.begin(),A.end(),greater<long long>());
    sort(B.begin(),B.end(),greater<long long>());
    sort(C.begin(),C.end(),greater<long long>());

    PQ.push(make_tuple(A.at(0)+B.at(0)+C.at(0),0,0,0));
    func(K,A,B,C);
    sort(OUTPUT.begin(),OUTPUT.end(),greater<long long>());
    for(long long ans : OUTPUT) cout << ans << endl;
}


Measured memory_bytes: 4828
#include<stdio.h>
int main()
{
	int n,x,max=-1,i,s=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&x);
		if(x>max)
		max=x;
		s+=x;
	}
	printf("%d",s-max/2); 
}

Measured memory_bytes: 128
/*
    Reference :-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
ll mod=1e9+7;
ll fac[100001];
ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2);
}
ll nCrModPFermat(ll n, ll r, ll p)
{
   // Base case
   if (r==0)
      return 1;
    if (n < 0 || r < 0) return 0;

    // Fill factorial array so that we
    // can find all factorial of r, n
    // and n-r

    return (fac[n]* (modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p)) % p;
}
int main(){
    //std::ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,m;
    cin>>n>>m;
    ll ar[n];
    forn(i,n)cin>>ar[i];
    sort(ar,ar+n);
    fac[1]=1;fac[0]=1;
    for(int i=2;i<100001;i++)fac[i]=(fac[i-1]*i)%mod;
    ll cal[n-2+1]={0};
    for(int i=m-2;i<n-1;i++)cal[i]=(cal[i-1]+nCrModPFermat(i,m-2,mod))%mod;
    ll ans=0,ans1=0;
    for(ll i=0;i<=n-m;i++){
        ll sub=(mod+ar[i])%mod;
        ans1=(ans1+(ar[i]*nCrModPFermat(n-1-i,m-1,mod))%mod)%mod;
        if (ans1 < 0) ans1 += mod;
    }
    for(ll i=m-1;i<n;i++){
        ll add=(ar[i]+mod)%mod;
        ans=(ans+(ar[i]*nCrModPFermat(i,m-1,mod))%mod)%mod;
        if (ans < 0) ans += mod;
    }
    ll ans3=ans-ans1;
    ans3%=mod;
    if(ans3<0)ans3+=mod;
    cout<<ans3;

	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin >> n;

    long long sum = 0;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            for (int k = 1; k <= n; k++)
            {
                sum += __gcd(i, __gcd(j, k));
            }
        }
    }

    cout << sum << endl;
}

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

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

  long int b_multiple;//1からbまでのxの倍数の数
  long int a_multiple;

  if(a == 0){
    b_multiple = b / x + 1;//+1するのはaが0だった場合は0も倍数に含まれるから
  }else{
    b_multiple = b / x ;
  } 

  if(a == 0){
    a_multiple =  0;
  }else{
    a_multiple =  (a - 1) / x;//−１するのは問題文でa以上としてあるので、aがxの倍数だった場合、a自身はa_multipleから除いてあげないといけないから
  } 
  cout << b_multiple - a_multiple << endl;
}

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

int main() {
	int n;
	cin >> n;
	
	string s, t;
	cin >> s >> t;
	
	string ans = "";
	bool x = true;
	for(int i = 0, j = 0; i<n || j<n;) {
		if(x) ans += s[i], i++;
		else ans += t[j], j++;
		x = !x;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  string S;
  cin >> S;
  if (S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi") {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
s = input()

kisu = ["R", "U", "D"]
gusu = ["L", "U", "D"]

flag = True

for i in range(len(s)):
    if (((i + 1) % 2 == 0) and not s[i] in gusu) or (((i + 1) % 2 == 1) and not s[i] in kisu):
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e6 + 100;
const LL INF = 1e9;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    VI v(MX,0);
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
        ++v[a[i]];
    }

    int ans = 0, f;
    loop(i,0,n)
    {
        f = 1;
        if(v[a[i]] > 1) f = 0;
        else if(a[i] != 1 && v[1]) f = 0;
        else
        {
            int n1 = sqrt(a[i]);
            loop(j,2,n1+1)
            {
                if(a[i] % j == 0)
                {
                    if(v[j]) {f = 0; break;}
                    if(v[a[i]/j]) {f = 0; break;}
                }
            }
        }

        if(f) ++ans;
    }

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

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

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 7960
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long mod = 1000000007;
int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}
ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}
bool prime[100005];
void seive()
{  memset(prime,true,sizeof(prime));
    for(int i=2;i*i<=100005;i++)
    {
         if(prime[i]==true) {
        for(int j=2*i;j<=(100005);j+=i)
           { prime[j]=false;}
           }

    }
}
int main()
{
   ios::sync_with_stdio(false);
	cin.tie(0);
	int f=0;
	int a,b;
	cin>>a>>b;
	int x=min(a,b);
	int y= max(a,b);
	for(int i=x;i<=y;i++)
    {
        if((i*x*y)&1) {
            f=1;
            break;
        }
    }
    if(f)
    cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


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

using ll=long long;
const ll MOD=1e9+7;
class SegmentTree{
    int N=1;
    ll E;
    vector<ll> dat;
    function<ll(ll,ll)> merge;
    void updateAll(){
        for(int i=N-2;i>=0;i--){
            ll v0=dat[i*2+1];
            ll v1=dat[i*2+2];
            dat[i]=merge(v0,v1);
        }
    }
    ll queryImpl(int a,int b,int k,int l,int r){
        if(a<=l && r<=b) return dat[k];
        if(b<=l || r<=a) return E;
        int mid=(l+r)/2;
        ll v0=queryImpl(a,b,k*2+1,l,mid);
        ll v1=queryImpl(a,b,k*2+2,mid,r);
        return merge(v0,v1);
    }
    public:
    SegmentTree(int n,function<ll(ll,ll)> merge,ll E):merge(merge),E(E){
        while(N<n) N*=2;
        dat.assign(2*N-1,E);
    }
    void update(vector<ll> vec){
        for(int i=0;i<vec.size();i++) dat[i+N-1]=vec[i];
        updateAll();
    }
    ll query(int a,int b){
        return queryImpl(a,b,0,0,N);
    }
};
ll gcd(ll x,ll y){
    return y==0 ? x : gcd(y,x%y);
}
ll lca(ll x,ll y){return x/__gcd(x,y)*y;}
ll add(ll x,ll y){return (x+y)%MOD;}
ll powm(ll x,ll k){
    ll res=1;
    while(k){
        if(k&1) res=(res*x)%MOD;
        x=(x*x)%MOD;
        k>>=1;
    }
    return res;
}
ll modInv(ll x){
    return powm(x,MOD-2);
}
int main(){
    int n,q; cin>>n>>q;
    vector<ll> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
        p[i]--;
    }
    vector<ll> sum(n);
    vector<ll> sz(n);
    for(int i=0;i<n;i++){
        int x=i;
        do{
            x=p[x];
            sum[i]+=x+1;
            sz[i]++;
        }while(x!=i);
        sum[i]*=modInv(sz[i]);
    }
    SegmentTree lcaSeg(n,lca,1LL);
    SegmentTree sumSeg(n,add,0LL);
    lcaSeg.update(sz);
    sumSeg.update(sum);
    while(q--){
        int l,r;
        cin>>l>>r;
        l--;
        ll lcaVal=lcaSeg.query(l,r);
        ll sumVal=sumSeg.query(l,r);
        cout<<(sumVal*(lcaVal%MOD))%MOD<<endl;
    }
    return 0;
}


Measured memory_bytes: 10228
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

struct UnionFind {
  vector<int> d;
  UnionFind(int n): 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 deg[100005];
vector<int> to[100005];

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        deg[a]++;
        deg[b]++;
        uf.unite(a,b);
    }
    rep(i,k) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i,n) {
        int ans = uf.size(i)-1-deg[i];
        for (int u : to[i]) {
            if (uf.same(i,u)) ans--;
        }
        cout << ans << endl;
    }
    return 0;
}

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

#define repo(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;


int uclid(int m,int n){
    while(true){
        int r = m % n;
        if (r == 0){
            return n;
        }
        return uclid(n,r);
    }
}
int main(){
    
   int K;
  cin >> K; 
  int sum = 0;
    for(int i =1; i <= K; i++ ){
        for(int j = 1; j <= K; j++){
            for(int k = 1; k <= K; k++){
                sum += uclid(uclid(i,j),k);
            }
        }
    }
    
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3592
#include<cstdio>
#include<iostream>
using namespace std;
int n,m,ans;
int main()
{
	scanf("%d%d",&m,&n);
	int x;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&x);
		ans+=x;
	}
	if(ans>=m)puts("Yes");
	else puts("No");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> str(H,vector<char>(W));
  for(int i=0;i<H;i++){
  	for(int j=0;j<W;j++){
    	cin >> str.at(i).at(j);
    }
  }
  for(int i=0;i<H+2;i++){
  	for(int j=0;j<W+2;j++){
    	if(i==0||i==H+1||j==0||j==W+1) cout << '#';
      	else cout << str.at(i-1).at(j-1);
    }
    cout << endl;
  }
}

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

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#define ll              long long int
#define ull             unsigned long long
#define vi              vector<int>
#define vl              vector<ll>
#define vvi             vector<vector<int> >
#define pi              pair<int,int>
#define vii             vector<pi>

#define sz(v)           ((int)(v).size())
#define all(s)          s.begin(),s.end()
#define allr(s)         s.rbegin(),s.rend()
#define unq(c)          (sort(all(c)), c.resize(distance(c.begin(),unique(all(c)))))
#define get_pos(c,x)    (lower_bound(all(c),x)-c.begin())

#define MS0(v)          memset((v), 0, sizeof((v)))
#define MS1(v)          memset((v), -1, sizeof((v)))
#define LEN(v)          strlen(v)

#define MP              make_pair
#define pb              push_back
#define pob             pop_back
#define ff              first
#define ss              second
#define sc              scanf
#define pf              printf
#define endl            "\n"

#define TEST_CASE       int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define PRINT_CASE      printf("Case %d: ",cs)

#define vpf(v)          for(int i=0;i<v.size();i++){cout<<v[i];if(i!=v.size()-1)cout<<" ";else cout<<"\n";}
#define vsc(v)          for(int i=0;i<v.size();i++)cin>>v[i];

#define REP(i, n)       for (int i = 0; i < (n); i++)
#define REPP(i, a, b)   for (int i = (a); i < (b); i++)
#define FOR(i, a, b)    for (int i = (a); i <= (b); i++)
#define FORS(i, s)      for (int i = 0; s[i]; i++)

#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fileio          freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)

#define intlim          2147483648
#define infinity        (1LL<<50)

#define gcd(a, b)       __gcd(a, b)
#define lcm(a, b)       ((a)*((b)/gcd(a,b)))


int on_bit(int N,int pos){return N = N | (1<<pos);}
int off_bit(int N,int pos){return N = N & ~(1<<pos);}
bool check_bit(ll N,int pos){return (bool)(N & (1<<pos));}


#define start_clock     clock_t tStart = clock()
#define end_clock       printf("\n>>Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC)



//____________________________________________________________________________________________________________




int main(){ 
    ll x, y;
    cin>>x>>y;

    if(x > y) x = y + (x%y);

    set<ll> st;

    ll mn = LONG_MAX;

    while(st.count(x) == 0){
        st.insert(x);
        x = abs(x-y);
        mn = min(mn, x);
    }

    cout<<mn<<"\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(a, max(b, c))-min(a, min(b, c)) << endl;
}


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

int main(){
	string str;
	int q, l;
	deque<char> de;
	deque<char> :: iterator it;
	cin >> str >> q;
	l = str.size();
	for(int i = 0; i < l; i++)
		de.push_back(str[i]);
	bool f = false;
	int t, c;
	char s;
	for(int i = 0; i < q; i++){
		scanf("%d",&t);
		if(t == 1) f = !f;	//直接记录翻转 
		else if(t == 2){
			scanf("%d %c", &c, &s);
			if(!f){		//如果没翻转，或者又翻转回来了 
				if(c == 1) de.push_front(s);
				else if(c == 2) de.push_back(s);
			}
			else {
				if(c == 2) de.push_front(s);
				else if(c == 1) de.push_back(s);				
			}
		}
	}
	if(!f){
		for(it = de.begin(); it != de.end(); it++)
			printf("%c", *it);		
	}
	else{	//注意-1 
		for(it = de.end() - 1; it != de.begin() - 1; it--)
			printf("%c", *it);			
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    int sl = s.length();
    vector<char> sv(sl);
    for (int i=0;i<sl;i++) {
        sv[i] = s[i];
    }
    int gp=999;
    set<char> use_char;
    for (auto c:s) {
        auto it = use_char.find(c);
        if (it!=use_char.end()) {}
        else {
            use_char.insert(c);
            vector<char> usevec(sv);
            if (count(usevec.begin(),usevec.end(),c)==usevec.size()) {
                gp = 0;
                break;
            }
            else {
                for (int k=sl-1;k>=1;k--) {
                    vector<char> newvc;
                    for (int t=0;t<k;t++) {
                        if (usevec[t]==c or usevec[t+1]==c) newvc.push_back(c);
                        else newvc.push_back('*');
                    }
                    if (count(newvc.begin(),newvc.end(),c)==newvc.size()) {
                        gp = min(gp,sl-k);
                        break;
                    }
                    else {
                        usevec=newvc;
                        newvc.clear();
                    }
                }
            }
        }
    }
    cout << gp << endl;
    return 0;
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll calc(ll N, ll C, ll D) {
    ll nc = N / C;
    ll nd = N / D;
    ll ncd = N / (C * D / gcd(C, D));
    return N - (nc + nd - ncd);
}

signed main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll ans = calc(B, C, D) - calc(A - 1, C, D);
    cout << ans << endl;

    return 0;
}


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


 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  long long int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  long long int balance=1000;
  vector<int> min;
  vector<int> max;
  if(a[0]<a[1]){
    min.push_back(0);
  }

  for(int i=1;i<n-1;i++){
    if(a[i]<=a[i-1] && a[i]<a[i+1]){
       min.push_back(i);
    }
  }
  for(int i=1;i<n-1;i++){
    if(a[i]>a[i-1] && a[i]>=a[i+1]){
      max.push_back(i);
    }
  }
  if(a[n-1]>a[n-2]){
    max.push_back(n-1);
  }
  
  int x=min.size();
  int y=max.size();
  
  for(int i=0;i<x;i++){
     
     for(int j=0;j<y;j++){
      if(max[j]>min[i]){
        long long int p=balance/a[min[i]];
       
        long long int q=p*(a[max[j]]-a[min[i]]);
        balance+=q;
       
        j=y;

      }
     }
     
  }
  cout<<balance<<endl;




}


Measured memory_bytes: 3660
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
#define INF 0x3f3f3f3f

int N;
vector <pii> G[101];
int mcos[101];

void dijkstra(int s)
{
   priority_queue < pii, vector<pii>, greater<pii> > pq;
   pq.push( mkp(0, s) );
   memset( mcos, INF, sizeof(mcos) );
   mcos[s] = 0;
   while( !pq.empty() ){
      const pii tmp = pq.top(); pq.pop();
      if( mcos[tmp.se] < tmp.fi )continue;
      for( const auto& v : G[tmp.se] ){
         const int nc = v.fi + tmp.fi;
         if( chmin( mcos[v.se], nc )) pq.push( mkp(nc, v.se) );
      }
   }
}

signed main()
{
   FAST();
   cin >> N;

   rep(i, N){
      int u, k, to, c;
      cin >> u >> k;
      while(k--){
         cin >> to >> c;
         G[i].pb( mkp(c,to) );
      }
   }
   dijkstra(0);
   rep(i, N) cout << i << ' ' << mcos[i] << '\n';
}



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

int main()
{
	int x,y;
	for (int i = 0; i < 10000; i++) {
		cin >> x >> y;
		if (x!= 0 || y!=0) {
			if (x > y) {
				swap(x, y);
			}
			cout << x << " " << y << endl;
		}
		else break;
	}
	return 0;
}

Measured memory_bytes: 3024
using System;
using System.Collections.Generic;
using System.Linq;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var vals = IOUtils.ReadInts();
            var s = vals[0];
            var w = vals[1];

            Console.WriteLine(s <= w ? "unsafe" : "safe");


        }
    }

    static class IOUtils
    {
        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        public static ulong ReadUlong()
        {
            return ulong.Parse(Console.ReadLine());
        }
        public static int[] ReadInts()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
        public static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


Measured memory_bytes: 19052
#include<stdio.h>

int main(void) {
   int x,i;
   int happy = 0;
   scanf("%d",&x);

   while(x > 0) {
      if(x%500 == 0) {
         happy += 1000;
         x -= 500;
      } else if(x%5 == 0) {
         happy += 5;
         x -= 5;
      } else if(x%100 == 0) {
         x -= 100;
      } else if(x%50 == 0) {
         x -= 50;
      } else if(x%10 == 0) {
         x -= 10;
      } else if(x%1 == 0) {
         x -= 1;
      }
   }
   printf("%d\n",happy);

   return 0;
}


Measured memory_bytes: 1732
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
int main()
{
string str;
int K,TB=0,TA=0,Tab=0,TM=0;
char ch,chc;
while(scanf("%d,%c%c",&K,&ch,&chc)!=EOF)
{
	
	if(ch=='A'){if(chc=='B')Tab++;else TA++;}
else if(ch=='B')TB++;
//else if(str=="AB")Tab++;
else if(ch=='O')TM++;
}
printf("%d\n%d\n%d\n%d\n",TA,TB,Tab,TM);

return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    string s;cin>>s;
    int c[26]={0};
    rep(i,s.size()){
        c[(int)(s[i]-'a')]++;
    }
    rep(i,26){
        if(c[i]%2==1){co("No");return 0;}
    }
    co("Yes");
}

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

int ans = 0;
int n, m;


struct edge{
    int to;
    int cost;
};

int check(vector<int> list){
    for(int i = 0; i < n; i++){
        if(list[i] == -1){
            return 0;
        }
    }
    return 1;
}

int solve(vector<vector<edge> > tree, vector<int> list, int from, vector<vector<int> >flag){
    //cout << from << endl;
    list[from] = 1;
    if(check(list) == 1){
        ans++;
    }else{
        int c = tree[from].size();
        if(c == 0){
            return 0;
        }else{
            for(int i = 0; i < c; i++){
                int t = tree[from][i].to;
                //cout << "flag is" << flag[from][t] << endl;
                if(flag[from][t] == 1  && list[t] == -1){
                    //cout << from << t << endl;
                    flag[from][t] = 0;
                    flag[t][from] = 0;
                    solve(tree, list, t, flag);
                }else{
                    continue;
                }
            }
        }
    }
}

int main(){
    cin >> n >> m;
    vector<vector<edge> > tree(n);
    vector<vector<int> >flag(8, vector<int>(8, 0));
    vector<int> list(n, -1);
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        edge e = {b-1, 0};
        edge e1 = {a-1, 0};
        tree[a-1].push_back(e);
        tree[b-1].push_back(e1);
        flag[a-1][b-1] = 1;
        flag[b-1][a-1] = 1;
    }
    solve(tree, list, 0, flag);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
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;}
const long long INF = 1LL << 60;

// --------write my code!!!!!----------//

int main(){
    string s; cin >> s;
    int res=10000000;
    rep(i,s.length()-2){
        int a,b,c,tmp;
        a=s[i]; b=s[i+1]; c=s[i+2];
        tmp=100*(a-48) + 10*(b-48) + c-48;
        res = min(res,abs(753-tmp));
    }
    cout << res << endl;
}


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

int main(){
    bool data[4][13]={0};
    int n;
    cin>>n;
    char s;
    int c;
    
    while(n>0){
        cin>>s>>c;
        if(s=='S') data[0][c-1]=1;
        else if(s=='H') data[1][c-1]=1;
        else if(s=='C') data[2][c-1]=1;
        else data[3][c-1]=1;
        n--;
    }
    
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            if(data[i][j]==0){
                if(i==0) cout<<"S "<<(j+1)<<endl;
                else if(i==1) cout<<"H "<<(j+1)<<endl;
                else if(i==2) cout<<"C "<<(j+1)<<endl;
                else cout<<"D "<<(j+1)<<endl;
            }
        }
    }
    
    
    
}


Measured memory_bytes: 3100