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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N)
  cin >> A[i];
  int minus_count = 0;
  ll abs_sum = 0;
  int abs_min = INT32_MAX;
  REP(i, N)
  {
    if (A[i] < 0)
      minus_count++;
    abs_sum += abs(A[i]);
    if (abs(A[i]) < abs_min)
      abs_min = abs(A[i]);
  }
  if (minus_count % 2 == 0)
    cout << abs_sum << endl;
  else
    cout << abs_sum - 2 * abs_min << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

ll F(ll x)
{
	return x * x * x * x * x;
}

int main()
{
	ll x;	cin >> x;
	
	for(ll A = -4000; A <= 4000; A++)
	{
		for(ll B = -4000; B <= 4000; B++)
		{
			if(F(A) - F(B) == x)
			{
				return cout << A << " " << B << endl, 0;
			}
		}
	}
}

Measured memory_bytes: 3640
#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<=n;i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(V) V.begin(), V.end()
#define PB push_back
using namespace std;
typedef long long ll;

int main() {
    int x;
    cin >> x;
    if(x >= 30) cout << "Yes" <<endl;
    else cout << "No" <<endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;


//最大フロー
const int MAX_N = 510, MAX_K = 510;
const int MAX_V = 510 * 510;

struct edge{
    int to, cap, rev;
};

//vector<edge> G[MAX_N];
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}

//二部マッチング
int N, K;
bool can[MAX_N][MAX_K];

int solve(){
    int s = N + K, t = s + 1;
    for(int i = 0; i < N; i++){
        add_edge(s, i, 1);
    }
    for(int i = 0; i < K; i++){
        add_edge(N + i, t, 1);
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < K; j++){
            if(can[i][j]){
                add_edge(i, N + j, 1);
            }
        }
    }
    return max_flow(s, t);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    N = K = n;
    vector<P> d(n), e(n);
    rep(i, 0, n){
        cin >> d[i].first >> d[i].second;
    } 
    rep(i, 0, n){
        cin >> e[i].first >> e[i].second;
    }
    rep(i, 0, n){
        rep(j, 0, n){
            if(d[i].first < e[j].first && d[i].second < e[j].second){
                can[i][j] = true;
            }
        }
    }
    cout << solve() << endl;
}

Measured memory_bytes: 6912
#include <iostream>

using namespace std;

const int maxn = 1e2 + 10;

int n, k;
int arr[maxn];

void solve() {
	for (int ans = n; ; ans++) {
		int tmp = ans;
		int flag = true;
		while (tmp) {
			int num = tmp % 10;
			for (int i = 1; i <= k; ++i) {
				if (arr[i] == num) {
					flag = false;
					break;
				}
			}
			if (flag == false) {
				break;
			}
			tmp = tmp / 10;
		}
		if (flag) {
			printf("%d\n", ans);
			return;
		}
	}
}

int main(){
	while (~scanf("%d %d", &n, &k)) {
		for (int i = 1; i <= k; ++i) {
			scanf("%d", arr + i);
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int a,b,c,d,e,f;
  cin>>a;
  b=(a/4)*4;
  c=a/4;
  while(true){
    if(a==b){
      cout<<"Yes";
      break;
    }
    if(c==0){
      cout<<"No";
      break;
    }
    if(b<a) b+=7;
    if(b>a) b-=4,c--;
  }
  cout<<"\n";
  }

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

int main(){
	char moji[100000];
	scanf("%s",moji);
	char en[]="abcdefghijklmnopqrstuvwxyz";
	char an[0];

	int i=0;
	while (i<26){
		int j=0;
		int emarge=1;
		while (j<100000&&moji[j]!=0){
			if (en[i]==moji[j]){
				emarge=0;
				break;
			}
			else{
				j++;
			}
		}
		if (emarge==1){
			an[0]=en[i];
			printf("%c\n",an[0]);
			break;
		}
		else{
			i++;
		}
	}
	if (an[0]==0){
		printf("None\n");
	}
	return 0;
}

Measured memory_bytes: 256
# C - Sum of gcd of Tuples (Easy)

k = int(input())

def gcd(x, y):
    if x==0:
        return y
    else:
        return gcd(y%x, x)

ans = 0

for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(gcd(a, b), c)

print(ans)

Measured memory_bytes: 77104
n=int(input())
s=input()
a=['SS','WS','SW','WW']
for i in range(n):
    for j in range(4):a[j]+='SW'[::-1 if s[i]=='o' else 1][a[j][i]==a[j][i+1]]
for i in range(4):
    if a[i][1]==a[i][n+1] and a[i][0] == a[i][n]:print(a[i][1:n+1]);exit()
print(-1)

Measured memory_bytes: 3840
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<stack>
#include<map>
#include<vector>
#include<queue>
#define N 15
using namespace std;
typedef long long ll;
char s[N];
int main()
{
    ios::sync_with_stdio(false);
    int n,left,right,mid;
    int M1,M2;//用于标记性别
    cin>>n;
    cout << "0" << endl;
    cin>>s;
    if (s[0]=='V')
       return 0;
    if (s[0]=='M')  M1=1;
    else  M1=0;
    left=0,right=n;
    while (left<right)
    {
        mid=(right+left)/2;
        cout << mid << endl;
        cin>>s;
        if (s[0]=='V')
          return 0;
        if (s[0]=='M')  M2=1;
        else  M2=0;
        int t=(mid-left);
        if (t%2==0)
        {
            if (M1==M2) left=mid;
            else right=mid;
        }
        else
        {
            if (M1==M2) right=mid;
            else left=mid,M1=M2;
        }
    }
    cout << flush;
    return 0;
}



Measured memory_bytes: 852
#include<bits/stdc++.h>
#define For(i,j,k)for(int i=j;i<=k;++i)
using namespace std;
const int N=2010;
int A[N];

bool cmp(int x,int y){
	return A[x]<A[y];
}
int bel[N],cnt[N],rk[N],n,k,q;

int main(){
	scanf("%d%d%d",&n,&k,&q);
	For(i,1,n)scanf("%d",&A[i]),rk[i]=i;
	sort(rk+1,rk+n+1,cmp);
	int ans=1e9;
	For(i,1,n-q+1){
		For(j,0,n)cnt[j]=0;
		For(j,0,n){
			bel[j]=A[j]<A[rk[i]]?j:bel[j-1];
			if(bel[j]!=j)++cnt[bel[j]];
		}
		int ret=0;
		For(j,i,n){
			if(cnt[bel[rk[j]]]>=k){
				++ret,--cnt[bel[rk[j]]];
				if(ret>=q){
					ans=min(ans,A[rk[j]]-A[rk[i]]);
					break;
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

char a[1000];
int main()
{
    int i;
    scanf("%s",a);
    for(i=0;i<3;i++)
        printf("%c",a[i]);
    printf("\n");
    return 0;
}


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

int main() {
    int n, m; cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
namespace AGC015A
{
    class Program
    {
        static void Main()
        {
            long[] nab = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            if (nab[1] > nab[2])
            {
                Console.WriteLine(0);
                Environment.Exit(0);
            }
            if (nab[0] == 1 && nab[1] != nab[2])
            {
                Console.WriteLine(0);
                Environment.Exit(0);
            }
            long max = (nab[0] - 1) * nab[2] + nab[1];
            long min = (nab[0] - 1) * nab[1] + nab[2];
            Console.WriteLine(max - min + 1);
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==5&&a[1]==5&&a[2]==7)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
	
 } 


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

int main() {
  ll N; cin >> N;
  auto A = vector<ll>(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  for (int i = 0; i < N; ++i) A[i] -= i + 1;
  sort(begin(A), end(A));

  ll ans = 0;
  ll b = A[N / 2];
  for (int i = 0; i < N; ++i) ans += abs(A[i] - b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main()
{
  int n,i,j,k,yet;
  double ave,sell;
  
  scanf("%d",&n);

  double array[n];
  for(i=0;i<n;i++)
    {
      scanf("%lf",&array[i]);
    }

  yet=1;
  while(yet==1)
    {
      yet=0;
      for(j=0;j<n-1;j++)
	{
	  if(array[j]>array[j+1])
	    {
	      yet=1;
	      sell=array[j];
	      array[j]=array[j+1];
	      array[j+1]=sell;
	    }
	}
    }

  for(k=0;k<n-1;k++)
    {
      ave=(array[k]+array[k+1])/2;
      array[k+1]=ave;
    }
  
  printf("%lf\n",ave);
  

  return 0;
}


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

using namespace std;

const int INF = 1 << 30;

int main()
{
  int H, W, D[10][10];

  while(cin >> H >> W, H) {
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
        cin >> D[i][j];
      }
    }
    int ret = 0;
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
        for(int k = i + 2; k < H; k++) {
          for(int l = j + 2; l < W; l++) {
            int low = 114514, high = -114514, beet = 0;
            for(int m = i; m <= k; m++) low = min(low, D[m][j]);
            for(int m = i; m <= k; m++) low = min(low, D[m][l]);
            for(int m = j; m <= l; m++) low = min(low, D[i][m]);
            for(int m = j; m <= l; m++) low = min(low, D[k][m]);
            for(int m = i + 1; m < k; m++) {
              for(int n = j + 1; n < l; n++) {
                high = max(high, D[m][n]);
                beet += low - D[m][n];
              }
            }
            if(low <= high) continue;
            ret = max(ret, beet);
          }
        }
      }
    }
    cout << ret << endl;
  }
}

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

int main(void){
    int x,y;
    while(true){
        cin >> x;
        cin >> y;
        if(x==0 && y==0){
            break;
        }
        if(x<y){
           cout << x << " " << y << endl;
        }
        else {  
           cout << y << " " << x << endl;
        }
    }
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s, t;
set<string> se;

int main() {
	cin >> s >> t;
	
	inc(i, s.size() - t.size() + 1) {
		string ss = s;
		bool f = true;
		inc(j, t.size()) { if(ss[i + j] != '?' && ss[i + j] != t[j]) { f = false; } }
		if(! f) { continue; }
		inc(j, s.size()) { if(ss[j] == '?') { ss[j] = 'a'; } }
		inc(j, t.size()) { ss[i + j] = t[j]; }
		se.insert(ss);
	}
	
	string ans = "UNRESTORABLE";
	if(se.size() != 0) { ans = *(se.begin()); }
	
	cout << ans << endl;
	
	return 0;
}


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

int main(int argc, char const *argv[])
{
	std::vector<int> v(3);
	for (int i = 0; i < v.size(); ++i)
	{
		cin >> v[i];
	}
	std::sort(v.begin(), v.end());
	for (int i = 0; i < v.size(); ++i)
	{
		cout << v[i];
		if (i != 2)
		{
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define si(x) x.size()

char A[200005];
ll dp[200005];
map<char,ll> MP;

int main(){

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

cin>>A;
string S=A;
MP[A[0]]++;
rep1(i,si(S)){
    ll add=0;
    rep(k,26){
        char a='a'+k;
        if(A[i]!=a) add+=MP[a];
    }
    dp[i]=dp[i-1]+add;
    MP[A[i]]++;
}
cout<<dp[si(S)-1]+1<<endl;
 
}
    


Measured memory_bytes: 5372
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::string S, T;
  std::cin >> N >> S >> T;
  for (auto S_it = S.begin(), T_it = T.begin(); S_it != S.end() && T_it != T.end(); ++S_it, ++T_it) {
    std::cout << *S_it << *T_it;
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 764
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

//https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a

ll mod_pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MOD;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,M; cin>>N>>M;
  vector<vector<ll>> graph(N,vector<ll>(0));
  rep(i,M){
    ll A,B; cin>>A>>B; A--; B--;
    graph.at(A).push_back(B);
    graph.at(B).push_back(A);
  }
  
  vector<ll> labeled(N,-1);
  ll label=0;
  rep(i,N){
    if(labeled[i]>-1) continue;
    queue<ll> que; que.push(i); labeled[i]=label;
    while(!que.empty()){
      ll v=que.front(); que.pop();
      for(auto nv:graph.at(v)){
        if(labeled[nv]>-1) continue;
        labeled[nv]=labeled[v];
        que.push(nv);
      }
    }
    label++;
  }
  
  vector<ll> vec(label,0);
  for(auto l:labeled) vec[l]++;
  
  cout<<*max_element(vec.begin(),vec.end())<<endl;
  
  return 0;
}

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

using namespace std;

int n,t;
int ans;
int now;

int main()
{
    int nextT;
    cin>>n>>t;
    cin>>nextT;
    ans=t;
    now = t;
    for(int i=1;i<n;i++){
        scanf("%d",&nextT);
        if(nextT+t>=now){
            ans+=min((nextT+t-now),t);
            now=nextT+t;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define szof(x) int32_t((x).size())

using namespace std;

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

const ll MOD = 1e9 + 7;
const ll MOD998 = 998244353;

mt19937 rnd((uint) chrono::steady_clock::now().time_since_epoch().count());

const int N = 444;
const ll INF = 1e18;

int a[N], p[N][N];
ll pref[N];
ll dp[N][N];

void solve(int l, int r) {
	if (l == r) {
		dp[l][r] = 0;
		p[l][r] = l;
		return;
	}
	ll &res = dp[l][r];
	if (res != INF) {
		return;
	}
	solve(l, r - 1);
	solve(l + 1, r);
	for (int i = p[l][r - 1]; i <= min(p[l + 1][r], r - 1); i++) {
		ll val = dp[l][i] + dp[i + 1][r] + pref[r + 1] - pref[l];
		if (res >= val) {
			res = val;
			p[l][r] = i;
		}
	}
}

void run() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			dp[i][j] = INF;
		}
	}
	for (int i = 0; i < n; i++) {
		pref[i + 1] += pref[i] + a[i];
	}
	solve(0, n - 1);
	cout << dp[0][n - 1] << "\n";
}

int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cout.precision(10); cout << fixed;
	int tests;
	tests = 1;
	// cin >> tests;
	while (tests--) {
		run();
	}
	return 0;
}


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

class Cube{
public:
    int f[6];
    Cube(){}
    void roll_z(){roll(1, 2, 4, 3);}
    void roll_y(){roll(0, 2, 5, 3);}
    void roll_x(){roll(0, 1, 5, 4);}
    void roll(int i, int j, int k, int l){
        int t = f[i];
        f[i] = f[j];
        f[j] = f[k];
        f[k] = f[l];
        f[l] = t;
    }
};

bool eq(Cube c1, Cube c2){
    for (int i = 0; i < 6; i++){
        if(c1.f[i] != c2.f[i]) return false;
    }
    return true;
}

bool equal(Cube c1, Cube c2){
    for (int i = 0; i < 6; i++ ){
        for (int j = 0; j < 4; j++){
            if(eq(c1, c2)) return true;
            c1.roll_z();
        }
        if (i % 2 == 0) c1.roll_y();
        else c1.roll_x();
    }
    return false;

}

int main(){
    Cube c1, c2;

    for(int i = 0; i < 6; i++) cin >> c1.f[i];
    for(int i = 0; i < 6; i++) cin >> c2.f[i];

    if (equal (c1, c2)) cout << "Yes" << endl;
    else cout << "No" << endl;

}


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

const ll MAX = 2002002, MOD = 1e9+7;
ll fac[MAX], finv[MAX], inv[MAX];
// 前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数の計算
ll COM(int n, int k){
    if (n < 0 || k < 0 || n < k) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int r,c,rr,cc; cin >> r >> c >> rr >> cc;
    COMinit();
    ll ans = COM(rr+cc+2,rr+1) - COM(rr+c+1,c) - COM(r+cc+1,r) + COM(r+c,c) + MOD;
    cout << ans%MOD << endl;
}

Measured memory_bytes: 50464
*j, N = map(int,input().split())
j.sort()
a,b,c = j
cnt = 0
for r in range(N//b+1):
    for g in range((N-b*r)//c+1):
        v = b*r+c*g
        if (N-v)%a == 0:
            cnt += 1
print(cnt)


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

int main(){
  int n;
  cin >> n;
  VI a(n);
  rep(i,n) cin >> a.at(i);
  
  int alice=0, bob=0;
  sort(a.begin(), a.end(), greater<int>());
  rep(i,n){
    if(i%2==0) alice += a.at(i);
    else bob += a.at(i);
  }
  
  cout << (alice - bob) << endl;    
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int h, n;  
  scanf("%d %d", &h, &n);
    
  int a[n];
  long long sum=0;
  for(int i=0;i<n;i++){
    scanf("%d", &a[i]);
    sum += a[i];
  }
  
  if(sum >= h) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 512
// 用Java实现一遍吧
#include <stdio.h>

/* 按顺序输出数组元素 */
void trace(int A[], int N) {
    int i;
    for (i = 0; i < N; i++) {
        if (i > 0) printf(" "); /* 在相邻元素之间输出1个空格 */
        printf("%d", A[i]);
    }
    printf("\n");
}

/* 插入排序(0起点数组) */
void insertionSort(int A[], int N) {
    int j, i, v;
    for (i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}
int main(){
    int N,i,j;
    int A[100];

    scanf("%d",&N);
    for(i = 0;i<N;i++) scanf("%d",&A[i]);

    trace(A,N);
    insertionSort(A,N);

    return 0;
}


Measured memory_bytes: 2664
N,Y = map(int,input().split(" "))
 
t = int(Y/10000)
end=False
for x in range(0,t+1):
    for y in range(0,N+1):
        if x+y>N:
            break
        z = N-x-y
        num = x*10000+y*5000+z*1000
        if num==Y:
            print(str(x)+" "+str(y)+" "+str(z))
            end=True
            break
    if end:
        break
if end==False:
    print("-1 -1 -1")

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
using namespace std;

char buf[100000];
string table1[256];
map<string, char> table2;

int main() {
  table1[' '] = "101";
  table1['\''] = "000000";
  table1[','] = "000011";
  table1['-'] = "10010001";
  table1['.'] = "010001";
  table1['?'] = "000001";
  table1['A'] = "100101";
  table1['B'] = "10011010";
  table1['C'] = "0101";
  table1['D'] = "0001";
  table1['E'] = "110";
  table1['F'] = "01001";
  table1['G'] = "10011011";
  table1['H'] = "010000";
  table1['I'] = "0111";
  table1['J'] = "10011000";
  table1['K'] = "0110";
  table1['L'] = "00100";
  table1['M'] = "10011001";
  table1['N'] = "10011110";
  table1['O'] = "00101";
  table1['P'] = "111";
  table1['Q'] = "10011111";
  table1['R'] = "1000";
  table1['S'] = "00110";
  table1['T'] = "00111";
  table1['U'] = "10011100";
  table1['V'] = "10011101";
  table1['W'] = "000010";
  table1['X'] = "10010010";
  table1['Y'] = "10010011";
  table1['Z'] = "10010000";

  table2["00000"] = 'A';
  table2["00001"] = 'B';
  table2["00010"] = 'C';
  table2["00011"] = 'D';
  table2["00100"] = 'E';
  table2["00101"] = 'F';
  table2["00110"] = 'G';
  table2["00111"] = 'H';
  table2["01000"] = 'I';
  table2["01001"] = 'J';
  table2["01010"] = 'K';
  table2["01011"] = 'L';
  table2["01100"] = 'M';
  table2["01101"] = 'N';
  table2["01110"] = 'O';
  table2["01111"] = 'P';
  table2["10000"] = 'Q';
  table2["10001"] = 'R';
  table2["10010"] = 'S';
  table2["10011"] = 'T';
  table2["10100"] = 'U';
  table2["10101"] = 'V';
  table2["10110"] = 'W';
  table2["10111"] = 'X';
  table2["11000"] = 'Y';
  table2["11001"] = 'Z';
  table2["11010"] = ' ';
  table2["11011"] = '.';
  table2["11100"] = ',';
  table2["11101"] = '-';
  table2["11110"] = '\'';
  table2["11111"] = '?';

  while (1) {
    if (fgets(buf, sizeof(buf), stdin) == NULL) return 0;
    char *p = strchr(buf, '\n');
    if (p) *p = '\0';
    
    int n = strlen(buf);
    string encoded;
    for (int i=0; i<n; i++) {
      encoded += table1[buf[i]];
    }
    encoded += string((5-encoded.size()%5)%5, '0');

    string decoded;
    for (int i=0; i<encoded.size()/5; i++) {
      decoded += table2[encoded.substr(i*5, 5)];
    }

    printf("%s\n", decoded.c_str());
  }
}

Measured memory_bytes: 2648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	string S;
	cin >> S;
	bool ok = 1;
	if (S[0] != 'A'||isupper(S[1])||isupper(S.back())) ok = 0;
	int cnt = 0;
	for (int i = 2; i + 1 < S.size(); i++) {
		if (S[i] == 'C') cnt++;
		else if (isupper(S[i])) ok = 0;
	}
	if (cnt != 1) ok = 0;
	if (ok) cout << "AC" << endl;
	else cout << "WA" << endl;
}

Measured memory_bytes: 256
spot_num = int(input())
spot_place = [ int(p) for p in input().split(" ") ]
diff_table = []
max_num = 0

for i in range(spot_num):
  if i == 0:
    max_num += abs(spot_place[0] - 0)
    diff_table.append(abs(spot_place[1] - 0) - \
    (abs(spot_place[0] - 0) + abs(spot_place[1] - spot_place[0])))
  elif i == spot_num-1:
    diff_table.append(abs(0 - spot_place[i-1]) - \
    (abs(spot_place[i] - spot_place[i-1]) + abs(0 - spot_place[i])))
    max_num += abs(spot_place[i] - spot_place[i-1])
  else:
    diff_table.append(abs(spot_place[i+1] - spot_place[i-1]) - \
    (abs(spot_place[i] - spot_place[i-1]) + abs(spot_place[i+1] - spot_place[i])))
    max_num += abs(spot_place[i] - spot_place[i-1])
    
max_num += abs(0 - spot_place[spot_num-1])

for i in range(spot_num):
  print(max_num+diff_table[i])


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

using namespace std;

int main() {
	int n, k;
	string a;
	cin >> n >> k >> a;
	int l = 0;
	int r = 0;
	int answer = 0;
	for (int i = 1; i < n; ++i) {
		if (a[i - 1] == 'R' && a[i] == 'L') {
			l += 1;
		}
		else if (a[i - 1] == 'L' && a[i] == 'R') {
			r += 1;
		}
		else {
			answer += 1;
		}
	}
	if (a[0] == 'L') {
		l += 1;
	}
	else {
		r += 1;
	}
	if (l == r) {
		answer += min(2 * k, (l - 1) * 2 + 1);
	}
	else{
		answer += min(2 * k, min(l, r) * 2);
	}
	cout << answer;
}

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

#define INF INT_MAX

int main(void)
{
	int v,e;
	int s,t,d;
	int i,j,k;
	int flg=0;
	int rin[100][100];
	
	cin>>v>>e;
	for(i=0;i<v;i++){
		for(j=0;j<v;j++) rin[i][j]=INF;
	}
	for(i=0;i<v;i++) rin[i][i]=0;
	for(i=0;i<e;i++){
		cin>>s>>t>>d;
		rin[s][t]=d;
	}
	
	/*cout<<endl;
	for(i=0;i<v;i++){
		for(j=0;j<v;j++) cout<<rin[i][j]<<" ";
		cout<<endl;
	}*/
	
	for(k=0;k<v;k++){ 
		for(i=0;i<v;i++){
			for(j=0;j<v;j++) if(rin[i][k]!=INF&&rin[k][j]!=INF) rin[i][j]=min(rin[i][j],rin[i][k]+rin[k][j]);
		}
	}
	
	for(i=0;i<v;i++) if(rin[i][i]!=0) flg=1; 
	
	if(flg==1) cout<<"NEGATIVE CYCLE"<<endl;
	else{
		for(i=0;i<v;i++){
			for(j=0;j<v;j++){
				if(j==0){
					if(rin[i][j]==INF) cout<<"INF";
					else cout<<rin[i][j];
				}
				else{
					if(rin[i][j]==INF) cout<<" "<<"INF";
					else cout<<" "<<rin[i][j];
				}
			}
			cout<<endl;
		}
	}
	
	return 0;
}


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

int main(){
    int a, b, c, m;
    cin>>a>>b>>c;
    
    if(a>b){m=a;a=b;b=m;}
    if(b>c){m=b;b=c;c=m;}
    if(a>b){m=a;a=b;b=m;}
    
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        String S;
        int Mod = 1000000007;

        try (Scanner sc = new Scanner(System.in)) {
            S = sc.next();
        }

        long[][] dp = new long[S.length()+1][13];
        dp[0][0] = 1;
        int result = 0;
        char[] arr = S.toCharArray();
        int row = 1;
        for(char c : arr){
            if(c == '?'){
                for(int i = 0; i <13;i++){
                    long temp = dp[row -1][i];
                    for(int k = 0; k <=9;k++){
                        int col = ((i * 10) + k) %13;
                        dp[row][col] += temp;
                        dp[row][col] = dp[row][col]%Mod;
                    }
                }
            }else{
                int k = toInt(c);
                for(int i = 0; i <13;i++){
                    long temp = dp[row -1][i];
                    int col = ((i * 10) + k) %13;
                    dp[row][col] += temp;
                    dp[row][col] = dp[row][col]%Mod;
                }
            }
            row++;
        }
        //System.out.println(Arrays.toString(dp[S.length()]));
        System.out.println(dp[S.length()][5]);

    }

    private static int toInt(char c){
        return c - 0x30;
    }

}


Measured memory_bytes: 38348
/*Frog2*/

#include <bits/stdc++.h>
using namespace std;

#define rep(i, N) for(int i = 0; i < (int)N; i++)

const long long INF = 1LL << 60;

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

    long long h[N];
    rep(i, N)   cin >> h[i];

    //DP配列の宣言
    long long dp[N + 100];
    rep(i, N + 100) dp[i] = INF;

    dp[0] = 0;

    rep(i, N)
    {
        for(int j = 1; j <= K; j++)
        {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[N - 1] << endl;
}

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

int p[5000000];

bool prime(int x){
  if(x==2) return false;
  
  if(x<1||x%2==0) return false;

  int i=3;
  while(i<=sqrt(x)){
    if(x%i==0)return false;
    i+=2;
  }
  return true;
}

int main(){
  int n,ans;
 

  int j=0;
  for(int i=3;i<=1000000;i++) if(prime(i)) p[j++]=i;
  while(1){
    ans=0;
    cin>>n;
    if(n==0) break;
    for(int i=0;p[i]<=(n+1)/2;i++){
      if(prime(n-p[i])) ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s == "SUN") cout << 7 << endl;
    else if(s == "MON") cout << 6 << endl;
    else if(s == "TUE") cout << 5 << endl;
    else if(s == "WED") cout << 4 << endl;
    else if(s == "THU") cout << 3 << endl;
    else if(s == "FRI") cout << 2 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
"use strict";
    
const lowerBound = (arr, n) => {
    let first = 0, last = arr.length - 1, middle;
    while (first <= last) {
        middle = 0 | (first + last) / 2;
        if (arr[middle] < n) first = middle + 1;
        else last = middle - 1;
    }
    return first;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const X = arg[1].split(" ").map(n=>parseInt(n));
    const Xa = [...X].sort((a,b)=>a-b);
    
    const median = Xa[Xa.length / 2]
    const left = Xa[(Xa.length / 2) - 1];
    const right = Xa[(Xa.length / 2) + 1];
    
    // console.log(median);
    
    let answer = [];
    
    for(let i in X) {
        if(X[i] < median) {
            answer.push(median);
        } else {
            answer.push(left);
        }
    }
    
    console.log(answer.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 65020
#include<iostream>
#include<utility>
#include<queue>
using namespace std;

int n, l, ans = 0, a[100004];
priority_queue<pair<int,int> > longer;

int main()
{
	cin >> n >> l;
	a[0] = a[1] = a[n + 2] = a[n + 3] = 0;
	for (int i = 2; i <= n + 2; i++){
		if (i <= n + 1) cin >> a[i];
		if (a[i - 1] > a[i - 2] && a[i - 1] > a[i]){	
			pair<int, int> in = make_pair(a[i - 1], i - 1);
			longer.push(in);
		}
	}

	while (!longer.empty()){
		pair<int, int> giveup = longer.top();
		ans = l - giveup.first;
		a[giveup.second] = 0;
		if (a[giveup.second - 1] > a[giveup.second - 2]){
			pair<int, int> in = make_pair(a[giveup.second - 1] - ans, giveup.second - 1);
			longer.push(in);
		}
		if (a[giveup.second + 1] > a[giveup.second + 2]){
			pair<int, int> in = make_pair(a[giveup.second + 1] - ans, giveup.second + 1);
			longer.push(in);
		}
		longer.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    vector<P> Edges;
    typedef vector<vector<ll>> tree;
    tree T(N);

    ll K = 0;

    rep(i,N-1){
        ll a, b;
        cin >> a >> b;
        --a, --b;
        Edges.pb({a, b});
        T[a].pb(b);
        T[b].pb(a);
        K = max({K, len(T[a]), len(T[b])});
    }
    print(K);

    vector<ll> node(N);
    map<P, ll> color;
    node[0] = 0;

    rep(i,N){
        ll now = node[i];
        for(auto e : T[i]){
            if(color[{i,e}] == 0){
                ++now;
                node[e] = color[{i,e}] = color[{e,i}] = now;
            }
        }
    }

    for(auto e : Edges) print(color[e] % K + 1);

    return 0;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(c)     for(bool p=1;p;p=next_permutation(ALL(c)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll inf = 1e15;
const ll mod = 1e9+7;
const double eps = 1e-10;

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

int main() {
    ll N; cin >> N;
    vector<ll> A(N); REP(i, N) cin >> A[i];
    
    SORT(A);
    A.push_back(-1);
    
    ll temp = -1;
    ll ans = 0;
    REP(i, N) {
        if (A[i] == A[i+1]) {
            if (temp == -1) {
                temp = A[i];
            } else {
                temp = -1;
            }
        } else {
            ans++;
        }
    }
    if (temp != -1) ans--;
    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while(cin >> n, n){
        vector<int> p(n), t(n);
        rep(i, 0, n){
            cin >> p[i] >> t[i];
        }
        n++;
        p.push_back(0);
        t.push_back(INF);
        int dp[42][4] = {};
        rep(i, 0, n) rep(j, 0, 4) dp[i][j] = INF;
        if(p[0] <= t[0]) dp[0][1] = p[0];
        rep(i, 0, n - 1){
            rep(j, 0, 4){
                int prv = dp[i][j];
                if(prv == INF) continue;
                if(j != 3){
                    int leng = abs(p[i] - p[i + 1]);
                    int nxtT = t[i] + (j + 1) * leng;
                    // cout << i << ' ' << j << ' ' << nxtT << ' ' << dp[i][j] << ' ' << leng << endl;
                    if(nxtT <= t[i + 1]){ 
                        dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + leng);
                    }
                }
                int leng2 = p[i] + p[i + 1];
                int nxtT2 = t[i] + (j + 1) * p[i] + p[i + 1];
                // cout << i << ' ' << j << ' ' << nxtT2 << ' ' << dp[i][j] << ' ' << leng2 << endl;
                if(nxtT2 > t[i + 1]) continue;
                dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + leng2);
            }
        }
        int ans = INF;
        rep(i, 0, 4){
            ans = min(ans, dp[n - 1][i]);
        }
        if(ans != INF){
            cout << "OK " << ans << endl;
            continue;
        }
        int ng = 0;
        rep(i, 0, n){
            int MIN = INF;
            rep(j, 0, 4) MIN = min(MIN, dp[i][j]);
            if(MIN == INF){
                ng = i + 1;
                break;
            }
        }
        cout << "NG " << ng << endl;
    }   
}


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

typedef long long ll;

vector<int> H;

int main(void) {
	int N, K;
	cin >> N >> K;
	H.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> H[i];

	sort(H.begin(), H.end());
	ll ans = (ll)0;
	if (K < N)
		ans = accumulate(H.begin(), H.begin() + N - K, (ll)0);

	cout << ans << '\n';
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
const int mod = 1000000007;

#define INF 1e+9
#define MAX_V 100001

struct edge {
    int to;
    int cost;
};
// <最短距離, 頂点の番号>
using P = pair<int, int>;

int N, M;
vector<edge> G[MAX_V];
pii d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    for(int i = 0; i < MAX_V; i++) {
        d[i] = mp(INF, INF);
    }
    d[s] = mp(0, 0);
    que.push(P(0, s));

    while(!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v].first < p.first)
            continue;
        for(int i = 0; i < G[v].size(); ++i) {
            edge e = G[v][i];
            if(d[e.to].first > d[v].first + e.cost) {
                d[e.to].second = p.second;
                d[e.to].first = d[v].first + e.cost;
                que.push(P(d[e.to].first, e.to));
            }
        }
    }
}

int main() {
    int A, B;
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        cin >> A >> B;
        edge e1 = {B - 1, 1};
        G[A - 1].push_back(e1);
        edge e2 = {A - 1, 1};
        G[B - 1].push_back(e2);
    }
    dijkstra(0);
    for(int i = 1; i < N; ++i) {
        if(d[i].first != INF) {
        } else {
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < N; ++i) {
        cout << d[i].second + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 13620
def ascan;gets.split.map(&:to_i);end

H,W = ascan
field = H.times.map{gets.chomp}

check = lambda do |y,x|
    next false if x < 0 || y < 0 || W <= x || H <= y
    next false if field[y][x] == '.'
    field[y][x] = '@'
    next true
end

move4 = [[-1,0],[1,0],[0,-1],[0,1]]

H.times do |y|
    W.times do |x|
        next if field[y][x] == '.'
        ok = false
        move4.each do |vy,vx|
            if check.call(y+vy,x+vx)
                ok = true
                break
            end
        end
        if !ok
            puts "No"; exit
        end
    end
end

puts "Yes"


Measured memory_bytes: 1788
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<unordered_map>
using namespace std;
#define ll long long
int main() {
	ll ans;
	cin >> ans;
	string str = "";
	while (ans > 0) {
		int m = ans % 26;
		if (m == 0) m = 26;
		str += (char)(m + 'a'-1);
		ans = (ans - m) / 26;
	}
	reverse(str.begin(), str.end());
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 3592
for _ in range(20000):
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(a//b)
    else:
        break



Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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 ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    int prev = 0;
    rep(i, n){
        if(prev + 1 == v[i]) prev++;
    }

    if(prev == 0) cout << -1 << endl;
    else cout << n-prev << endl;
}

Measured memory_bytes: 1152
private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

private inline fun <T> T.also(block: (T) -> Unit): T { block(this); return this }

fun query(a: Long, b: Long): Long {
    val ab = a * b
    val f = (a - 1) * 2
    return f +
            when {
                (a + 1) * (a + 1) < ab -> {
                    val pairCentre = Math.ceil(Math.sqrt(ab.toDouble()) - 1).toLong()
                    val alpha = pairCentre - a
                    if (pairCentre * (pairCentre + 1) < ab) 2 * alpha else (alpha - 1) * 2 + 1
                }
                else -> 0L
            } +
            when {
                a + 1 < b -> 1L
                else -> 0L
            }
}

fun main(args: Array<String>) {
    val Q = readInts()[0]
    (0 until Q).forEach {
        val (a, b) = readInts().sorted()
        println(query(a.toLong(), b.toLong()))
    }
}

Measured memory_bytes: 37996
#include<stdio.h>

int main(void){
	int i,j,minj;
	int n,a[100];
	int tmp,cnt;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&(a[i]));
	}
	cnt=0;
	for(i=0;i<n;i++){
		minj=i;
		for(j=i;j<n;j++){
			if(a[j]<a[minj]){
				minj=j;
			}
		}
		if(i!=minj){
			tmp=a[i];
			a[i]=a[minj];
			a[minj]=tmp;
			cnt++;
		}
	}
	for(i=0;i<n;i++){
		printf("%d",a[i]);
		printf("%c",i==n-1?'\n':' ');
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int h1 = 0;
		int h2 = 0;
		Scanner sc = new Scanner(System.in);
		h1 = sc.nextInt();
		h2 = sc.nextInt();
		sc.nextLine();
		String strValue = "";
		for (int i = 0; i < h1 + 2; i++) {
			strValue = "#";
			if (i == 0 || i == h1 + 1) {
				for (int j = 0; j < h2; j++) {
					strValue += "#";
				}
			} else {
				strValue += sc.nextLine();
			}
			strValue += "#";
			System.out.println(strValue);
		}
		sc.close();
	}
}

Measured memory_bytes: 21844
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int X,ans = 1,hako;
    cin >> X;

    for(int i = 2;i <= X /2;i++){
        hako = i;
        while(hako <= X){
            hako *= i;
            if(hako <= X and ans < hako)
                ans = hako;

        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3552
// Problem : A - Frog 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define ll long long 
#define ull unsigned long long
const int INF = 1e9 + 5;
#define pb push_back
#define eb emplace_back
#define vll vector<long long int>
#define vi vector<int>
#define loop(i, a, b) for(long long int i = a; i < b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<ll, ll>
#define vpair vector<pii>
#define vbool vector<bool>
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define sec second
#define fir first
#define br '\n'
#define permute next_permutation
#define pqua priority_queue<ll>
#define pqud priority_queue<ll, vector<ll>, greater<ll> >
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define maxi *max_element
#define pi acos(-1)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(10)

vector<long long int> sieve(long long int n){
 	vector<long long int> primes;
 	bool isPrime[n+1] = {false};
 	isPrime[1] = isPrime[0] = false;
 	for(long long int i = 2;i<=n;i++)
 	{
 		isPrime[i] = true;
 	}
 	for(long long int i = 2;i*i<=n;i++)
 	{
 		if(isPrime[i])
 		{
 			for(long long int j = i*i;j<=n;j+=i)
 			{
 				isPrime[j] = false;
 			}
 		}
 	}
 	for(long long int i = 2;i<=n;i++)
 	{
 		if(isPrime[i])
 		{
 			primes.push_back(i);
 		}
 	}
 	return primes;
}

void print_vector2(vector<vector<ll> >v) {
    for(ll i=0;i<v.size();i++){
        for(ll j=0;j< v[i].size();j++){
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
}

void print_vector1(vector<ll> v) {
    for(ll i=0; i<v.size();i++){
        cout<<v[i]<<" ";
    }cout<<"\n";
}

ll gcd(ll a, ll b) {
    return __gcd(a, b);
}

// v.back()
// v.erase(v.begin(), v.brgin + k)
// v.insert(at which place v.bigin() + 1 implines at i = 1, no. of times, value)
// v.insert(position, copy.begin(), copy.end())
// v1.swap(v2)
// v.clear() to clear v.empty() to check empty
// map assending order and set descending order 
// stringstream ss(str) Used for breaking words

int main(){
    FastIO;
    PRECISION;
	
	ll n;
	cin>>n;
	vll dp(n, -1);
	vll h(n);
	scan(h, n);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(ll i = 2; i < n; i++){
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
    cout<<dp[n - 1];
    return 0;
}

Measured memory_bytes: 4784