akhauriyash/Code-Regression huggingface dataset:
from collections import deque
n, m = map(int, input().split())
room_adjacent = [[] for _ in range(n)]
for _ in range(m):
  room1, room2 = map(int, input().split())
  room_adjacent[room1-1].append(room2)
  room_adjacent[room2-1].append(room1)

room_labels = [1]+[0]*(n-1)
old_room = 1
path_queue = deque((old_room, room) for room in room_adjacent[old_room-1])
while path_queue:
  old_room, new_room = path_queue.pop()
  if room_labels[new_room-1] == 0:
    room_labels[new_room-1] = old_room
    for another_room in room_adjacent[new_room-1]:
      path_queue.appendleft((new_room, another_room))
  
if 0 in room_labels:
  print("No")
else:
  print("Yes")
  [print(value) for value in room_labels[1:]]

Measured memory_bytes: 52664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>

int main()
{
    long N,T;
    long t[200000];
    std::cin >> N >> T;
    for(long i=0; i<N; i++){
        std::cin >> t[i];
    }
    long time=0;
    for(long i=0; i<N-1; i++){
        long timebetween=t[i+1]-t[i];
        if(timebetween<=T){//止まる前に押すとき
            time+=timebetween;
        }else{
            time+=T;
        }
    }
    time+=T; //最後の人
    std::cout << time << std::endl;
    return 0;
}

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

int main(void){
    ll a,b;
    cin>>a>>b;
    string s0="",s1="";
    rep(0,i,b)s0+=to_string(a);
    rep(0,i,a)s1+=to_string(b);
    if(s0<s1)cout<<s0<<endl;
    else cout<<s1<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int i,n,t,time,cost,min_cost;
  min_cost = 0;
  scanf("%d %d", &n, &t);
  for(i=0;i<n;i++) {
    scanf("%d %d", &cost, &time);
    if(time <= t && (min_cost == 0 || min_cost > cost)) {
	min_cost = cost;
    }
  }
  if(min_cost == 0) {
    printf("TLE");
  }else{
    printf("%d",min_cost);
  }
}

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

int main(){
  int N;cin>>N;
  int d[N+10];for(int i=0;i<N;i++)cin>>d[i];
  int sum=0;
  for(int i=1;i<N;i++){
    for(int k=0;k<i;k++){
      sum+=d[i]*d[k];
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

char s[101];
char C[][9]={"..rr....",
             "..rr....",
             "ggyybbww",
             "ggyybbww",
             "..oo....",
             "..oo...."};

inline void cyc_(char& a, char& b, char& c, char& d){
    char t=a;
    a=b, b=c, c=d, d=t;
}
void cyc(char c){
    switch(c){
    case 'U':
        cyc_(C[2][4],C[2][6],C[2][0],C[2][2]);
        cyc_(C[1][3],C[0][3],C[0][2],C[1][2]);
        cyc_(C[2][5],C[2][7],C[2][1],C[2][3]);
        break;
    case 'F':
        cyc_(C[2][1],C[4][2],C[3][4],C[1][3]);
        cyc_(C[2][2],C[3][2],C[3][3],C[2][3]);
        cyc_(C[2][4],C[1][2],C[3][1],C[4][3]);
        break;
    case 'R':
        cyc_(C[2][3],C[4][3],C[3][6],C[0][3]);
        cyc_(C[3][5],C[2][5],C[2][4],C[3][4]);
        cyc_(C[2][6],C[1][3],C[3][3],C[5][3]);
        break;
    case 'D':
        cyc_(C[3][1],C[3][7],C[3][5],C[3][3]);
        cyc_(C[4][3],C[4][2],C[5][2],C[5][3]);
        cyc_(C[3][4],C[3][2],C[3][0],C[3][6]);
        break;
    case 'B':
        cyc_(C[3][0],C[0][2],C[2][5],C[5][3]);
        cyc_(C[3][6],C[3][7],C[2][7],C[2][6]);
        cyc_(C[5][2],C[2][0],C[0][3],C[3][5]);
        break;
    case 'L':
        cyc_(C[3][2],C[1][2],C[2][7],C[5][2]);
        cyc_(C[2][1],C[2][0],C[3][0],C[3][1]);
        cyc_(C[3][7],C[4][2],C[2][2],C[0][2]);
        break;
    }
}

int main(){
    cin>>s;
    for(char c:s) cyc(c);
    for(auto s:C) cout<<s<<endl;
}

Measured memory_bytes: 1144
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#include <memory>
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define l_double long double
#define vtr vector
#define PB push_back
#define EB emplace_back
#define gcd __gcd
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define TEST uint _ {}; cin >> _; while (_--)
#define PIE (3.1415926535897932384626433832795)
#define MOD 1'00'00'00'007
using namespace std;

template<typename T>
void vtrS(const vector<T> &ARR) { for (auto const &val: ARR) cout<<val<<" "; cout<<endl; }

template<typename T>
void vtrV(const vector<T> &ARR) { for (auto const &val: ARR) cout<<val<<endl; }

ull lcm (ull a, ull b) { return ((a*b)/gcd(a, b)); }
ull countDigits(const ull &N) { return (floor(log10(N)) + 1); }
bool isPowOfTwo(ull const &N) { return (N && (!(N&(N-1)))); }
// ---------------------------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<boolalpha<<fixed<<setprecision(3); 
    // --------------------------------------
    
    int x {}, y {}, z {};
    cin >> x >> y >> z;

    cout<<z<<" "<<x<<" "<<y<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;



int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
ll n, m;
cin >> n >> m;
ll i = m-n+1;
ll j = m+n-1;
for(int k = i; k<=j; k++){
	cout << k << " ";
}
return 0;
}



Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1,n,m,k;
vll_t a,b;

int main(){
	//scanf("%d",&t);
	while(t--){
		int a,b,k;
		cin>>a>>b>>k;
		int c=__gcd(a,b);
		vector<int>f;
		for(int i=1;i<=sqrt(c);i++){
			if(c%i==0){
				f.push_back(i);
				if(i*i!=c){
					f.push_back(c/i);
				}
			}
		}
		sort(f.begin(),f.end(),greater<int>());
		cout<<f[k-1]<<endl;
	}
}

Measured memory_bytes: 256
Al=list(input())
Bl=list(input())
Cl=list(input())

TURN="a"

for i in range(400):
    if TURN=="a":
        if Al==[]:
            print("A")
            exit()
        else:
            TURN=Al[0]
            del Al[0]
        
    elif TURN=="b":
        if Bl==[]:
            print("B")
            exit()
        else:
            TURN=Bl[0]
            del Bl[0]
            
        
    elif TURN=="c":
        if Cl==[]:
            print("C")
            exit()
        else:
            TURN=Cl[0]
            del Cl[0]

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
typedef pair<int, int> PII;

int N, M[200], D[200];
int dd[5] = { 0, 1, 0, -1, 0 };

int main(void) {
  while(cin >> N, N) {
    REP(i, 0, N - 1) cin >> M[i] >> D[i];

    vector<PII> v;
    v.push_back(PII(0, 0));

    REP(i, 0, N - 1) v.push_back(PII(v[M[i]].first + dd[D[i]], v[M[i]].second + dd[D[i] + 1]));

    int t = 100000000, l = 100000000, b = -100000000, r = -100000000;
    REP(i, 0, N) {
      t = min(t, v[i].first);
      l = min(l, v[i].second);
      b = max(b, v[i].first + 1);
      r = max(r, v[i].second + 1);
    }

    cout << (r - l) << " " << (b - t) << endl;
  }

  return 0;
}

Measured memory_bytes: 3076
a, b, c, d = list(map(int, input().split()))
tak, m = divmod(c, b) 
aok, mo = divmod(a, d)
if m > 0:
    tak += 1
else:
    pass
if mo > 0:
    aok += 1
else:
    pass
if tak > aok:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
int hm(vector<int> vi,int pos)
{
	int sum =0;
	for(int i=pos;i<vi.size();i++)
		if(vi[i]<vi[pos])sum++;
	return sum;
}
int jc(int a)
{
	int sum = 1;
	if(a == 0)return 0;
	else if(a>0)
	{
		for(int i=a;i;i--)
		{
			sum*=i;
		}	
	}	
	return sum;
} 
vector<int> ap,bp;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		ap.push_back(a);
	}
	for(int i=0;i<n;i++)
	{
		int b;
		cin>>b;
		bp.push_back(b);
	}
	int sum =0,sum1 =0;
	for(int i=0;i<n-1;i++)
	{
		int m = hm(ap,i);
		sum+=m*jc(ap.size()-i-1);
		int m1 = hm(bp,i);
		sum1+=m1*jc(bp.size()-i-1);
	}
	cout<<abs(sum-sum1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}








int main()
{
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
         cin>>a[i];
     }
     ll res=0LL;
    for(int i=0;i<60;i++){
              ll bit=1LL<<i;
              int ct=0;
              for(int j=0;j<n;j++){
                   if(a[j]&bit)ct++;

              }
              res+=(((bit%mod)*ct)%mod*(n-ct))%mod;
              res%=mod;
         }
         cout<<res;
    
}

















 
 
 
 
 
 



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

int main(){
  ll n=0;
  cin >> n;
  vector<ll> vec(n);
  rep(i,n) cin >> vec[i];
  //sort(vec.begin(),vec.end());
  
  ll ans = 0;
  
  rep(i,n-1){
    ll j = i+1;
    if(vec[i] > vec[j]){
    	ans = ans + (vec[i] -vec[j]);
      	vec[j] = vec[j] + (vec[i] -vec[j]);
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4768
#include <iostream>
using namespace std;
int main() {
    int n, a;
    int min = 1000000 + 1;
    int max = -1000000 - 1;
    long long sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a < min) {
            min = a;
        }
        if (a > max) {
            max = a;
        }
        sum += a;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;


int main(){
  int i,j;
  int N;cin>>N;
  string S;cin>>S;
  if(S.size()<=N)cout<<S<<endl;
  else{
    for(i=0;i<N;i++){
      cout<<S[i];
    }
    cout<<"..."<<endl;
  }
}
  

Measured memory_bytes: 3596
#pragma region Preparation
/* competitive programming */
#include "bits/stdc++.h"
using namespace std;

/* using */
// long
using ll = long long;
using ld = long double;
// vector
using vi = vector<int>;
using vd = vector<double>;
using vll = vector<ll>;
using vld = vector<ld>;
using vs = vector<string>;
using vi2 = vector<vector<int>>;
using vll2 = vector<vector<ll>>;

/* define */
// array
#define ari(x) array<int, x>
#define ard(x) array<double, x>
#define arll(x) array<ll, x>
#define arld(x) array<ld, x>
#define ars(x) array<string, x>
#define ari2(x, y) array<array<int, y>, x>
#define arll2(x, y) array<array<ll, y>, x>
// int -> ll
#define int ll // int -> ll
// push_back系
#define pb(x) push_back(x)    // push_back
#define eb(x) emplace_back(x) // emplace_back
// all range
#define all(x) x.begin(), x.end() // all_range
// gcd, lcm
#define gcd(x, y) __gcd(x, y)         // gcd
#define lcm(x, y) (x / gcd(x, y) * y) // lcm
// PI
#define PI M_PI // PI
// 大文字・小文字変換
#define cup(x) toupper(x)                                              // char_toupper
#define clow(x) tolower(x)                                             // char_tolower
#define strup(x) *transform(x.begin(), x.end(), x.begin(), ToUpper())  // string_toupper
#define strlow(x) *transform(x.begin(), x.end(), x.begin(), ToLower()) // string_tolower
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// 大文字・小文字変換
struct ToUpper
{
    char operator()(char c) { return toupper(c); }
};
struct ToLower
{
    char operator()(char c) { return tolower(c); }
};
#pragma endregion

/* A・B問題用外部変数 */
ll a, b, c; // 基本変数
ll n, k;    // 範囲・長さ・整数用
string s;   // 文字列用

/* main */
void Main(void)
{
    cin >> a;
    b = a / 100;
    c = a % 100;
    if (1 <= b && b <= 12 && 1 <= c && c <= 12)
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if (0 <= b && b <= 99 && 1 <= c && c <= 12)
    {
        cout << "YYMM" << endl;
    }
    else if (1 <= b && b <= 12 && 0 <= c && c <= 99)
    {
        cout << "MMYY" << endl;
    }
    else
    {
        cout << "NA" << endl;
    }
}

signed main(void)
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0LL;
}


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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";
 
using namespace std;

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

signed main(){
    io();
    int n, k, q; cin >> n >> k >> q;
    --k;
    vector<int> v(n, 0);
    for(int i = 0, x; i < q; ++i){
        cin >> x; --x; ++v[x];
    }
    for(auto &x : v) cout << (q - x <= k ? "Yes" : "No") << '\n';
    return 0;
}

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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define FORR(v, c) for (auto &v : c)
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define dbg(x) cerr<<#x<<" = " << (x) << endl
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

struct Arrete { int v, c;};
struct Point {int x, y; double distance(Point other) const {return sqrt(SQ(x-other.x)+SQ(y-other.y));}};

typedef	vector<int>	vi;
typedef pair<int,int>	ii;
typedef vector<string>	vs;
typedef vector<ii>	vii;
typedef vector<Arrete>	vg;
typedef vector<long long>	vl;
typedef	long long ll;

const int MAX = 3001;

int longest[MAX][MAX];
bool used[MAX][MAX];
ii nxt[MAX][MAX];
string s,t;

void run(int i, int j)
{

	if (longest[i][j] != -1) return;
	if (i == s.size() or j == t.size())
	{
		longest[i][j] = 0;
		return ;
	}
	longest[i][j] = 0;
	nxt[i][j] = {-1, -1};

	if (s[i] == t[j])
	{
		run(i+1, j+1);
		longest[i][j] = 1 + longest[i+1][j+1];
		nxt[i][j] = {i+1, j+1};
		used[i][j] = true;
	}

	run(i, j+1);
	run(i+1, j);
	if (longest[i][j] < longest[i+1][j])
	{
		longest[i][j] = longest[i+1][j];
		nxt[i][j] = {i+1, j};
		used[i][j] = false;
	}
	if (longest[i][j] < longest[i][j+1])
	{
		longest[i][j] =  longest[i][j+1];
		nxt[i][j] = {i, j+1};
		used[i][j] = false;
	}
}

int		main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	FOR(i,0, MAX) FOR(j,0, MAX) longest[i][j] = -1;
	read2(s, t);

	run(0, 0);
	
	int i(0), j(0);

	while (i < s.size() and j < t.size())
	{
		if (used[i][j]) cout << s[i];
		int ii = nxt[i][j].first;
		int jj = nxt[i][j].second;
		i = ii;
		j = jj;
	}
	cout << endl;
}



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

int num_count, sum;

void dfs(int i, int s, int n) {
  if (s == sum && n == 0) {
    num_count++;
    return;
  }

  if (i == 10 || n == 0) {
    return;
  }

  dfs(i + 1, s + i, n - 1);
  dfs(i + 1, s, n);
}


int main(void) {
  int i, n;

  while (true) {
    cin >> n >> sum;
    if (n == 0 && sum == 0) break;

    num_count = 0;
    dfs(0, 0, n);
    cout << num_count << endl;
  }

  return 0;
}

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

int main() {
    int n,K;    cin>>n>>K;
    int a[n];
    long long dp[n];
    for(int i=0;i<n;i++)        cin>>a[i];
    
    dp[0]=0;
    
    for(int i=1;i<n;i++){
        long long add=1e9;
        for(int k=1;k<=K;k++)if(i-k>=0){
            add=min(add, dp[i-k] + abs(a[i]-a[i-k]));
        }
        dp[i]= add; 
        
    }
    cout<<dp[n-1]<<endl;    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;

// to container
template <class C>
void input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

int main()
{
    int N = input<int>();
    vector<int> d(N, 0);
    input(d);

    long res = 0;
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            res += d[i] * d[j];
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

//Declaration
class Card{
public:
    Card( const std::string str );
    char GetSymbol();
    int GetNumber();
    std::string GetString();

private:
    std::string pair;
};

void MySwap( Card& a, Card& b );
void BubbleSort( std::vector<Card>& vec );
void SelectionSort( std::vector<Card>& vec );
std::string CheckStable( std::vector<Card> initial, std::vector<Card> sorted );

int main(){
    //----Initialization Section----
    int n;
    std::cin >> n;
    std::string str;
    std::vector<Card> input;
    std::vector<Card> bubble;
    std::vector<Card> select;
    int i = 0;
    for( ; i < n; ++i ){
        std::cin >> str;
        input.push_back( Card(str) );
        bubble.push_back( Card(str) );
        select.push_back( Card(str) );
    }

    //----Sort Section----
    BubbleSort(bubble);
    SelectionSort(select);

    //----Output Section----
    for( i = 0; i < n; ++i ){
        std::cout << bubble[i].GetString() << ( ( i != n-1 )? " " : "" );
    }
    std::cout << "\n" << CheckStable( input, bubble ) << "\n";

    for( i = 0; i < n; ++i ){
        std::cout << select[i].GetString() << ( ( i != n-1 )? " " : "" );
    }
    std::cout << "\n" << CheckStable( input, select ) << std::endl;;
}

//Definition
Card::Card( const std::string str ){
    pair = str;
}

char Card::GetSymbol(){
    return pair[0];
}

int Card::GetNumber(){
    return static_cast<int>( pair[1] - '0' );
}

std::string Card::GetString(){
    return pair;
}

void MySwap( Card& a, Card& b ){
    Card tmp = std::move(a);
    a = std::move(b);
    b = std::move(tmp);
}

void BubbleSort( std::vector<Card>& vec ){
    int n = vec.size();
    for( int i = 0; i < n; ++i ){
        for( int j = n - 1; j > i; --j ){
            if( vec[j].GetNumber() < vec[j-1].GetNumber() ){
                MySwap( vec[j], vec[j-1] );
            }
        }
    }
}

void SelectionSort( std::vector<Card>& vec ){
    int n = vec.size();
    int minj;
    int j;
    for( int i = 0; i < n; ++i ){
        minj = i;
        for( j = i; j < n; ++j ){
            if( vec[j].GetNumber() < vec[minj].GetNumber() ){
                minj = j;
            }
        }
        if( i != minj ){
            MySwap( vec[i], vec[minj] );
        }
    }
}  

std::string CheckStable( std::vector<Card> initial, std::vector<Card> sorted ){
    int N = sorted.size();
    for( int i = 0; i < N; ++i ){
        for( int j = i+1; j < N; ++j ){
            for( int a = 0; a < N; ++a ){
                for( int b = a+1; b < N; ++b ){
                    if( initial[i].GetNumber() == initial[j].GetNumber() &&
                        initial[i].GetString() == sorted[b].GetString() &&
                        initial[j].GetString() == sorted[a].GetString() ){
                            return "Not stable";
                    }
                }
            }
        }
    }
    return "Stable";
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double aa = (double)a;
    double bb = (double)b;

    double pi = 3.1415926535897932384;

    double thetaM = 2.0*pi * (double)m/60.0;
    double thetaH = 2.0*pi * ((double)h+((double)m/60.0))/12.0;
    
    double theta = abs(thetaM - thetaH);
    
    double ans = sqrt(aa*aa + bb*bb - 2*aa*bb*(cos(theta)));
    printf("%.15lf",ans);
}

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

class Program
{
    static void Main(string[] args) {
        long n = long.Parse(Console.ReadLine());
        long l = digitLength(n);
        long f = digitFirst(n);
        Console.WriteLine((l-1)*9 + f);
    }
    static long digitLength(long x) {
        long length = 0;
        while(x>0) {
            length++;
            x /= 10;
        }
        return length;
    }
    static long digitFirst(long x) {
        long first = 0;
        List<long> digit = new List<long>();
        while(x>0) {
            first = x%10;
            digit.Add(x%10);
            x/=10;
        }
        for(int i = 0; i < digit.Count()-1; i ++) {
            if(digit[i] != 9) {
                first -= 1L;
                break;
            }
        }
        return first;
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<VV> VVV;
vector<pair<int,int>> G[1000000];
/*
辺に属性がある場合
struct edge{int to,cost;};
vector<edge> G[10000];
*/
long long int co[1000000],t[1000000];
void Representing_graph(long long int s, long long int t,long long int c) {
	G[s].push_back(make_pair(t,c));
	G[t].push_back(make_pair(s, c));
}

void dfs(long long int n,long long int r) {
	
	t[n] = 1;
	for (long long int i = 0; i < G[n].size(); i++) {
		long long int len = G[n][i].second, po = G[n][i].first;
		if ((r + len) % 2 == 0) {
			co[po] = 1;
		}
		if(t[po]==0)dfs(po, r + len);
	}
	return;
};

int main() {
	long long int n,a,b,c;
	cin >> n;
	vector<pair<long long int,long long int>>vec(n);

	for (long long int i = 0; i < n-1; i++) {
		cin >>a >> b>>c;
		Representing_graph(a-1,b-1,c);
	}
	co[0] = 1;
	dfs(0,0);
	for (long long int i = 0; i < n; i++) {
		cout << co[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 36736
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max(a,b)-min(a,b))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)n,(int)n)
#define nHr(n,r) nCr((int)(n+r+1),(int)r)
#define sankaku(x) ((1+x)*x)/2
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,result=0;
  int a[LIMIT2]={0},b[LIMIT2]={0};
  char s[LIMIT1];

  scanf("%lld",&n);
  rep(i,n) scanf("%d",&a[i]);
  rep(i,n) b[i]=a[i];
  qsort(b,n,sizeof(int),downint);
  result = b[0]+b[1];
  rep(i,n) printf("%d\n",result-max(b[1],a[i]));

  return 0;
}

Measured memory_bytes: 5492
h,w,n = map(int,input().split())
sr,sc = map(int,input().split())
s = input()
t = input()
r,l,u,d = sc,sc,sr,sr
ans = "YES"
for i,j in zip(s,t):
  if i == "R":
    r+=1
    if r>w:
      ans = "NO"
      break
  elif i =="L":
    l-=1
    if l<1:
      ans = "NO"
      break
  elif i =="U":
    u-=1
    if u<1:
      ans = "NO"
      break
  else:
    d+=1
    if d>h:
      ans = "NO"
      break
  if j == "L":
    r=max(1,r-1)
  elif j == "R":
    l=min(w,l+1)
  elif j == "D":
    u=min(h,u+1)
  else:
    d=max(1,d-1)
print(ans)

Measured memory_bytes: 3784
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


int main(){
  int m;
  cin >> m;
  cout << 24 + 24 - m << endl;

}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys

def input():
    return sys.stdin.readline().rstrip()

N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
a.sort()
price = [a[i][0] for i in range(N)]
stock = [a[i][1] for i in range(N)]
bought = 0
total_price = 0

for i in range(N):
    if bought + stock[i] <= M:
        total_price += price[i] * stock[i]
        bought += stock[i]
    else:
        total_price += price[i] * (M - bought)
        break
print(total_price)

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

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

Measured memory_bytes: 256
import sys
if sys.version_info[0]>=3: raw_input=input
 
def insertionSort(a,g):
    global cnt
    for i in range(g,len(a)):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            cnt+=1
            a[j+g] = v
 
def shellSort(a):
    global cnt
    cnt = 0
    g = []
    h = 1
    while h <= len(a):
        g.append(h)
        h = 3*h+1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(a,g[i])
 
a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)


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

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

void solve() {
    i64 n;
    cin >> n;
    vector<p64> a(n);
    for (i64 i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(begin(a), end(a), greater());

    vector<vector<i64>> dp(n + 1, vector<i64>(n + 1));
    for (i64 i = 0; i < n; i++) {
        const auto& [ e, p ] = a[i];
        for (i64 j = 0; j <= i; j++) {
            dp[j+1][i-j] = max(dp[j+1][i-j], e * abs(p-j) + dp[j][i-j]);
            dp[j][i-j+1] = max(dp[j][i-j+1], e * abs(p-(n-1-(i-j))) + dp[j][i-j]);
        }
    }

    i64 ans = 0;
    for (i64 i = 0; i <= n; i++) ans = max(ans, dp[i][n-i]);
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 34624
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var A = ReadLong();

            if (N % 500 <= A)
            {
                return "Yes";
            }

            return "No";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27368
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val t = (1..n).map { sc.nextLong() }

  val ans = nlcm(t)
  println(ans)


}

// 最大公約数
private fun gcd(a: Long, b: Long): Long {
  if (b > 0) {
    return gcd(b, a % b)
  }
  return a
}

// 最大公約数
private fun ngcd(a: List<Long>): Long {
  var res: Long
  res = a.get(0)
  for (i in 1 until a.size) {
      if (res == 1L) break
      res = gcd(a.get(i), res)
  }
  return res
}

// 最小公倍数
private fun lcm(a: Long, b: Long): Long {
    return a / gcd(a, b) * b
}

// 最小公倍数
private fun nlcm(numbers: List<Long>): Long {
  var res: Long
  res = numbers.get(0)
  for (i in 1 until numbers.size) {
      res = lcm(res, numbers.get(i))
  }
  return res
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int res = 0;

void selection(vector<int> &a, int n)
{
    for (int i = 0; i < n; i++)
    {
        int minj = i;
        for (int j = i; j < n; j++)
        {
            if (a[j] < a[minj])
                minj = j;
        }
        if (a[i] != a[minj])
        {
            swap(a[i], a[minj]);
            res++;
        }
    }
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    selection(a, n);
    printv(a);
    cout << res << endl;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<string,string> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  string s;
  cin>>n>>s;
  P a[1<<n];
  rep(i,0,1<<n){
    string t,u;
    rep(j,0,n){
      if(i>>j & 1){
        t+=s[j];
      }
      else{
        u+=s[j];
      }
    }
    a[i]=P(t,u);
  }
  sort(a,a+(1<<n));
  
  ll ans=0;
  rep(i,0,1<<n){
    string t,u;
    rep(j,0,n){
      if(i>>j & 1){
        t+=s[2*n-1-j];
      }
      else{
        u+=s[2*n-1-j];
      }
    }
    ans+=upper_bound(a,a+(1<<n),P(t,u))-lower_bound(a,a+(1<<n),P(t,u));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 33792
#include<cstdio>
int a,b,k;
int main()
{
	scanf("%d%d%d",&a,&b,&k);
	for(int i=a>b?b:a;;i--)
	{
		if(a%i==0&&b%i==0)k--;
		if(k==0)
		{
			printf("%d",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll x,k,d; cin>>x>>k>>d;
    x = abs(x);
    if (k <= x/d) {
        cout << x-(k*d) << '\n';
        return 0;
    }
    ll sho = x/d;
    ll yo = x%d;

    if (k%2 == sho%2) {
        cout << yo << '\n';
    }
    else {
        cout << abs(d-yo) << '\n';
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <bitset>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <iomanip>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y;
  Point(){x=0;y=0;}
  Point(double d_x,double d_y){x=d_x,y=d_y;}
  double operator*(Point obj){return obj.x*x+obj.y*y;}
  double operator%(Point obj){return obj.y*x-obj.x*y;}
  Point operator*(double b){Point tmp;tmp.x=x*b;tmp.y=y*b;return tmp;}
  Point operator/(double b){Point tmp;tmp.x=x/b;tmp.y=y/b;return tmp;}
  Point operator+(Point obj){Point tmp;tmp.x=x+obj.x;tmp.y=y+obj.y;return tmp;}
  Point operator-(){Point tmp;tmp.x=-x;tmp.y=-y;return tmp;}
  Point operator-(Point obj){Point tmp;tmp.x=x-obj.x;tmp.y=y-obj.y;return tmp;}
  Point operator-=(Point obj){x-=obj.x;y-=obj.y;return *this;}
  Point operator+=(Point obj){x+=obj.x;y+=obj.y;return *this;}
  Point operator/=(double b){x=x/b;y=y/b;return *this;}
  Point operator*=(double b){x=x*b;y=y*b;return *this;}
  double size(){return hypot(x,y);}
  Point unit(){return Point(x/size(),y/size());}
  Point normal(){return Point(y,-x);}
  double atan(){return atan2(y,x);}
};

bool operator<(Point a,Point b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
bool operator>(Point a,Point b){return b<a;}
bool operator<=(Point a,Point b){return !(b<a);}
bool operator>=(Point a,Point b){return !(a<b);}
bool operator==(Point a,Point b){return (a-b).size()<eps;}
bool operator!=(Point a,Point b){return !(a==b);}

bool equal(double a,double b){return abs(a-b)<eps;}
double cross(Point a,Point b){return a%b;}
double dot(Point a,Point b){return a*b;}

int ccw(Point a,Point b,Point c)
{
  b=b-a;
  c=c-a;
  if(b%c>0) return +1;
  else if(b%c<0)return -1;
  else if(b*c<0) return +2;
  else if(b.size()<c.size()) return -2;
  else return 0;
}

char tochar(int i)
{
  if(i<10) return (char)('0' + i);
  else return (char) ('A'+(i-10));
}

int n,m,q,cnt;

int main(int argc,char const* argv[])
{
  while(1)
    {
      cin >> n >> m >> q;
      if(n==0 && m==0 && q==0) break;
      char c,ans[1005];
      int f[37][1005],s[37]={},b[1005];
      for(int i=0;i<n;i++)
	{
	  for(int j=0;j<m;j++)
	    {
	      f[i][j]=1;
	    }
	}
      for(int i=0;i<q;i++)
	{
	  for(int i=0;i<n;i++) cin>>c,s[i]=(s[i]+(c-'0'))%2;
	  for(int i=0;i<m;i++) cin>>c,b[i]=c-'0';

	  for(int i=0;i<n;i++)
	      for(int j=0;j<m;j++)
		{
		  if(f[i][j]==2) continue;
		  else if(s[i]==b[j]) f[i][j]=1;
		  else f[i][j]=2;
		}
	}
      for(int j=0;j<m;j++)
	{
	  int flag=0;
	  for(int i=0;i<n;i++)
	    {
	      if(f[i][j]==1 && flag==0)
		{
		  flag=1;
		  ans[j]=tochar(i);
		}
	      else if(f[i][j]==1 && flag==1) ans[j]='?';
	    }
	}
      for(int i=0;i<m;i++)
	{
	  cout << ans[i];
	}
      cout << endl;
    }
  return 0;
}



Measured memory_bytes: 3244
s = list(input())
t = list(input())

count = 0
n = 0
ans = []
flag = 0
n=len(s)-len(t)
while n >=0:
    count = 0
    for m in range(len(t)):
        if s[n+m] == "?" or s[n+m]==t[m]:
            count += 1
        else:
            break
    if count == len(t):
        flag = 1
        break
    else:
        n -= 1

if flag == 1:
    for i in range(len(s)):
        if s[i] == "?":
            s[i] = "a"
    for i in range(m+1):
        s[n+i] =t[i]
    
    for _ in s:
        print(*_,end="")

else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

int H, W, c[10][10], tmp, minc[10], ans=0;

int main() {
    cin >> H >> W;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) cin >> c[i][j];
        minc[i] = c[i][1];
    }

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                minc[j] = min(minc[j], c[j][k]+minc[k]);
            }
        }
    }

    for (int i = 0; i < H*W; i++) {
        cin >> tmp;
        if (tmp != -1) ans += minc[tmp];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
long long qSum[200003],n, num;
int main()
{
    cin>>n;
    for (int i = 1; i <= n; ++i)
    {
        cin>>num;
        qSum[i] = num+qSum[i-1];
    }
    sort(qSum, qSum+(n+1));
    long long sum = 0, k = 1;
    for (int i = 1; i <= n; i++)
    {
        if(qSum[i] != qSum[i-1]){
            sum = sum + k*(k-1)/2;
            k = 1;
        } else {
            k++;
        }
    }
    cout<<sum+k*(k-1)/2;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		if(s.equals("SSS")) {
			System.out.println(0);
			return;
		}
		int out = 1;
		for(int i = 1; i < s.length(); i++) {
			if(s.charAt(i) == 'R' && s.charAt(i - 1) == s.charAt(i)) {
				out++;
			}
		}
		System.out.println(out);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


Measured memory_bytes: 35620
#include<iostream>
#include<cstring>
using namespace std;
#define MAXN 200007
#define MO (int(1e9)+7)
int f[MAXN];
int cnt[MAXN];
inline int findf(int x) {
	int ff=x;
	while(f[ff]!=ff) ff=f[ff];
	while(x!=ff) {
		int t=f[x];
		f[x]=ff;
		x=t;
	}
	return ff;
}
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n,m; cin>>n>>m;
	for(int i=1; i<=n; i++) f[i]=i;
	for(int i=0; i<m; i++) {
		int a,b; cin>>a>>b;
		int f1=findf(a), f2=findf(b);
		f[f1]=f2;
	}
	memset(cnt,0,sizeof cnt);
	int ans=0;
	for(int i=1; i<=n; i++) {
		int fi=findf(i);
		cnt[fi]++;
		ans = max(ans, cnt[fi]);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int S, up, dw;
  cin >> S;
  up = S / 100;
  dw = S % 100;
  if (1 <= up && up <= 12){
    if(1<= dw && dw <= 12)
      cout << "AMBIGUOUS" << endl;
    else
      cout << "MMYY" << endl;
  }
  else{
    if (1<= dw && dw <= 12)
      cout << "YYMM" << endl;
    else
      cout << "NA" << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		
		if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5))
			System.out.println("Yes");
		else
			 System.out.println("No");
		
	}
}




Measured memory_bytes: 23764
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = s.nextInt();
        }
        Arrays.sort(a);
        int count = 1;
        for (int i = 0; i < n - 1; i++) {
            if (a[i] != a[i + 1]) {
                count++;
            }
        }

        System.out.println(count);
    }
}

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

bool sim(bool turn){

  int n = str.size();
  char pos = str[0];
  for(int i=1;i<n;i++){
    if(pos == str[i]) return 0;
    if(turn == 1 && str[i] == 'R') return 0;
    if(turn == 0 && str[i] == 'L') return 0;
    pos = str[i];
    turn = !turn;
  }
  return 1;
}

int main(){
  int q;
  cin>>q;
  while(q--){
  cin>>str;
  int ans = sim(0)|sim(1);
  cout<< (ans? "Yes":"No")<<endl;
  }
  

  return 0;  
}

Measured memory_bytes: 3240
#include <iostream>
#include <map>
#include <cstdio>

using namespace std;

int main()
{
	int n;
	char to,from,*str;
	map<char,char> hyou;

	str = new char [10000001];

	while(cin >> n && n ){
		for(int i = 0; i < n; i++){
			cin >> to;
			cin >> from;
			hyou.insert( make_pair(to,from) );
		}

		cin >> n;

		for(int i = 0; i < n; i++){
			cin >> str[i];
			if(hyou.find(str[i]) != hyou.end()){
				str[i] = hyou[str[i]];
			}
		}
		str[n] = '\0';

		printf("%s\n",str);

		hyou.erase(hyou.begin(),hyou.end());
	}

	return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
//const int mod = 1000000007;
const ll mod = INF / 1000;

int main() {
    int w, a, b;
    cin >> w >> a >> b;

    if (a <= b && b <= a + w) {
        cout << 0 << endl;
        return 0;
    }

    if (a <= b + w && b + w <= a + w) {
        cout << 0 << endl;
        return 0;
    }

    int ans1 = abs(b - a);
    int ans2 = abs(b - (a + w));
    int ans3 = abs(b + w - (a + w));
    int ans4 = abs(b + w - a);

    int ans = ans1;
    cmin(ans, ans2);
    cmin(ans, ans3);
    cmin(ans, ans4);

    cout << ans << endl;

}


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

int main(){
  int N,W,H;
  cin >> W;
  cin >> H;
  cin >> N;

  int x_min = 0;
  int x_max = W;
  int y_min = 0;
  int y_max = H;

  for(int i = 0;i < N;i++){
    int x,y,a;
    cin >> x;
    cin >> y;
    cin >> a;

    if(a == 1){
      x_min = std::max(x_min, x);
    }else if(a == 2){
      x_max = std::min(x_max, x);
    }else if(a == 3){
      y_min = std::max(y_min, y);
    }else if(a == 4){
      y_max = std::min(y_max, y);
    }else{
      std::cerr << "unknown a " << a;
    }
  }

  int ans = std::max(x_max - x_min,0)*std::max(y_max - y_min,0);

  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

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

    int H1, H2, M1, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    cout << (H2 - H1) * 60 + (M2 - M1) - K << endl;

    solve();
    return 0;
}


Measured memory_bytes: 3660
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	
	long long int A,B,C;
	cin>>A>>B>>C;
	if((A*B*C)%2==0){
		cout<<"0"<<endl;
	}else{
		long long int tmp=max(A,max(B,C));
		if(tmp==A){
			cout<<B*C<<endl;
		}else if(tmp==B){
			cout<<A*C<<endl;
		}else{
			cout<<A*B<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256