akhauriyash/Code-Regression huggingface dataset:
a = list(map(int,input().split()))
ans = False
if (a[1] % 6 % 2 == 0) and (a[1] // 6 *2 + a[1] % 6 //2 == a[0]):
  ans = True
elif (a[1] % 2 == 0) and (a[1] //2 == a[0]):
  ans = True
elif (a[1] % 4 == 0) and (a[1] //4 == a[0]):
  ans = True
else:
  for i in range(a[0]):
    if ((a[1] - i * 4) %2 == 0) and((a[1] - i * 4) //2 + i) == a[0]:
      ans = True
    elif((a[1] - i * 4) %4 == 0) and ((a[1] - i * 2) //4 + i) == a[0]:
      ans = True
if ans:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9248
import java.io.*;

class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        int[][][] room = new int[4][3][10];
        int n;
        String[] strArr;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        n = Integer.parseInt(br.readLine());

        for(int i = 0; i < n; i++){
            strArr = br.readLine().split(" ");
            int b = Integer.parseInt(strArr[0]);
            int f = Integer.parseInt(strArr[1]);
            int r = Integer.parseInt(strArr[2]);
            int v = Integer.parseInt(strArr[3]);

            room[b-1][f-1][r-1] += v;
        }

        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 3; j++){
                for(int k = 0; k < 10; k++){
                    System.out.print(" " + room[i][j][k]);
                }
                System.out.print("\n");
            }
            if(i != 3)
                System.out.println("####################");
        }
    }
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    ll ans = 0;
    rep(i, 1, n + 1) {
        if (i % 3 != 0 && i % 5 != 0) { ans += i; }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define F first
#define S second
#define ld long douroote
#define pb push_back
#define ll long long
#define INF 0x7f7f7f7f
#define sc(a) scanf("%d",&a)
#define scll(a) scanf("%I64d",&a)
#define scc(a) scanf(" %c",&a)
#define scs(a) scanf(" %s",a)
#define me(a,b) memset(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define allr(a,n) a,a+n
#define loop(a,s,e) for(ll a=s;a<=e;a++)
#define read_arr(a,s,n) for(ll i=s;i<n+s;i++){sc(a[i]);}
#define read_arr_ll(a,s,n) for(ll i=s;i<n+s;i++){scll(a[i]);}
#define open(in,out) freopen(in,"r",stdin);freopen(out,"w",stdout);
#define err(a,s) cerr<<a<<s;
#define err_arr(a,s,n) for(ll i=s;i<n+s;i++){cerr<<a[i]<<" ";}cerr<<endl;
#define prtll(x) printf("%lld",x);
#define prt(x) printf("%d",x);
using namespace std;
const int N=1e5+10;
ll mem[N],n,a[N],k;
int main(){
scll(n);scll(k);
read_arr(a,1,n);
mem[n]=0;
for(int i=n-1;i>=1;i--){
        ll ans=1e18;
        for(int j=1;j<=k && j+i<=n;j++){
          ans=min(abs(a[i]-a[i+j])+mem[i+j],ans);
        }
        mem[i]=ans;
}
//err_arr(mem,1,n);
printf("%lld\n",mem[1]);
}
/**
n=0
n-1=20
n-2= 20 , 10
n-3=

**/


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    puts(a!=c ? "1" : "0");
    return 0;
}


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

#define ll long long
#define ld long double
#define mod 1000000007LL
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define pb(x) push_back(x)
#define fo(i, a, n) for (i = (a); i < (n); i++)
#define foe(i, a, n) for (i = (a); i <= (n); i++)
// clang-format off
#define vin(a) for (ll i = 0; i < sz(a); i++) { cin >> a[i]; } 
#define vout(a) for (auto x : a) { cout << x << " "; }
#define sws                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0)
// clang-format on
#define pd(x) cout << x
#define sd(x) cin >> x
#define nl cout << endl
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define foreach(i, a)                                                          \
  for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
// int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
void solve() {
  ll m, n;
  ll i, j = 0;
  cin >> n;
  ll x, y;
  bool ok = false;
  fo(i, 0, n) {
    cin >> x >> y;
    if (x == y) {
      j++;
      if (j == 3)
        ok = true;
    } else {
      j = 0;
    }
  }

  ok ? cout << "Yes" : cout << "No";
  nl;
}

int main() {
  sws;
  solve();
  return 0;
}

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

int main(){
  int n; cin >> n;
  int a[100010], b[100010];
  for (int i = 0; i < n + 1; i++){
    cin >> a[i];
  }
  for (int i = 0; i < n; i++){
    cin >> b[i];
  }
  int64_t ans = 0;
  for (int i = 0; i < n; i++){
    ans += min(a[i], b[i]);
    b[i] = max(b[i] - a[i], 0);
    ans += min(a[i + 1], b[i]);
    a[i + 1] = max(a[i + 1] - b[i], 0);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
N, Y = map(int, input().split())
flag = False
for i in range(N + 1):
    if(flag):
        break
    for j in range(N + 1):
        k = N - i - j
        if(k < 0):
            continue
        sum = 10000 * i + 5000 * j + 1000 * k
        if(sum == Y):
            print(i, j, k)
            flag = True
            break
if(flag == False):
    print(-1, -1, -1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
void solve1() {
    // Greedy
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    ll M = 1000;
    for (int i = 0; i < N - 1; i++) {
        if (a[i] < a[i+1]) {
            ll k = M / a[i];
            M %= a[i];
            M += k * a[i+1];
        }
    }
    cout << M << '\n';
}
void solve2() {
    // DP
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    vector<ll> dp(N+1);
    dp[0] = 1000;
    for (int i = 0; i < N; i++) {
        dp[i+1] = dp[i];  // i日目に何もしない
        for (int j = 0; j < i; j++) {
            ll m = dp[j] / a[j] * a[i] + dp[j] % a[j];  // j日目に全部買って, i日目に全部うる
            dp[i+1] = max(dp[i+1], m);
        }
    }
    cout << dp[N] << '\n';
}
/* main */
int main(){
    // solve1();
    solve2();
}


Measured memory_bytes: 3620
N, K = map(int, input().split())
A=list(map(int, input().split()))
L=[0 for _ in range(40)]
ans=[]
ans.append(sum(a^K for a in A))
for a in A:
    i=0
    while a:
        if a&1==1:
            L[i]+=1
        a=a>>1
        i+=1

opt_str=''
for l in L[::-1]:
    if l > N-l:
        opt_str+='0'
    else:
        opt_str+='1'
opt=int(opt_str,2)

for i in range(40):
    if ((K>>i)&1)==1:
        Kr=(K&((((1<< 40-i)-1)<<(i+1))))|(opt&(1 << i)-1)
        ans.append(sum(a ^ Kr for a in A))

print(max(ans))


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

using namespace std;
int main()
{

    int N;
    cin >> N;
    for(int i = 0; i*7 <= N; i++){
        if((N-7*i)%4==0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
arrp = tuple(map(int,input().split()))
arrq = tuple(map(int,input().split()))

import itertools
for i,j in enumerate(itertools.permutations(range(1,n+1),n)):
    if j == arrp:
        a = i
    if j == arrq:
        b = i
        
print(abs(a-b))

Measured memory_bytes: 3060
def main():
    s = input()
    w = ["dream", "dreamer", "erase", "eraser"]
    last = len(s)
    for _ in range(len(s)):
        if last < 1:
            break
        for ww in w:
            if s[last - len(ww):] == ww:
                s = s[:last - len(ww)]
                last -= len(ww)
    print("YES" if last < 1 else "NO")


if __name__ == '__main__':
    main()



Measured memory_bytes: 3188
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

helper = []
need, ans = 0, 0

if sum(A) < sum(B):
  print(-1)
  exit()

for i in range(N):
  if A[i] > B[i]:
    helper.append(A[i] - B[i])
  elif A[i] < B[i]:
    need += B[i] - A[i]
    ans += 1

helper = sorted(helper, reverse=True)
i = 0
while need > 0:
  need -= helper[i]
  i += 1
  ans += 1
print(ans)

Measured memory_bytes: 18356
#include<bits/stdc++.h>
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int a,b,c;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b>>c;
	if(a==b&&c!=a){
		cout<<"Yes"<<endl;
		return 0;
	}
	if(a==c&&b!=a){
		cout<<"Yes"<<endl;
		return 0;
	}
	if(b==c&&a!=b){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#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[]) {
    int n; cin>>n;
    string s; cin>>s;

    vector<vector<int>> dp(n+1, vector<int>(n+1));

    for (int i = n-1; i >= 0; --i) {
        for (int j = i; j >= 0; --j) {
            if (s[i]==s[j]) chmax(dp[i][j], min(dp[i+1][j+1]+1,i-j));
        }
    }
    
    int ans = 0;
    for (int i = 0; i <= n; ++i) for (int j = 0; j <= n; ++j) chmax(ans,dp[i][j]);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 98176
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    
    int cnt1 = 0,cnt2 = 0;
    for(int i = 0;i < s.size();i++){
        if(i % 2 == 0 && s[i] == '0')cnt1++;
        if(i % 2 != 0 && s[i] == '0')cnt2++;
        if(i % 2 == 0 && s[i] != '0')cnt2++;
        if(i % 2 != 0 && s[i] != '0')cnt1++;
    }
    cout << min(cnt1,cnt2) << endl;

}

Measured memory_bytes: 512
N, T = map(int, input().split())
min_cost = 1001
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
        min_cost = min(min_cost, c)

if min_cost == 1001:
    print('TLE')
else:
    print(min_cost)


Measured memory_bytes: 9084
#include <iostream>
#include <string>
using namespace std;
int main(){
	string list[] = {
		"",".,!? ","abc","def"
		,"ghi","jkl","mno"
		,"pqrs","tuv","wxyz"
	};
	string str,out;
	int times;
	cin >> times;
	for(int i =0 ;i<times;i++){
		cin >> str;
		char cur,cash='a';
		int count = 0,idx=0;
		int n = 0;
		while(n <str.size()){
			cur = str[n];

			if(cur == '0'){
					if (idx == 0) count = 0;
					else {
						out +=list[idx][count%=list[idx].size()];
						count =0;
						idx=0;
					}
			}
			else if(cur ==cash){
				count +=1;
			}
			else{
				idx= (int)(cur - '0');
			}
			cash = cur;
			n++;
		}//?????????????????°???????????????
		cout << out << endl;
		out ="";
	}
		return 0;
}

Measured memory_bytes: 1216
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    AB = [[int(i) for i in input().split()] for j in range(M)]
    AB.sort(key=lambda p: p[1])
    mx_b = AB[0][1]
    ans = 1
    for a, b in AB[1:]:
        if a < mx_b:
            continue
        else:
            mx_b = b
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 59484
#include<cstdio>
#include<algorithm>
#include<vector>
#define N_ 101000
using namespace std;
int n, C[N_], chk[N_], S, U[N_], D[N_], res;
vector<int>E[N_];
char p[N_];
void DFS(int a, int pp) {
	if (p[a] == 'W')C[a] = 1;
	for (auto &x : E[a]) {
		if (x == pp)continue;
		DFS(x, a);
		C[a] += C[x];
	}
}
void Do(int a, int pp) {
	for (auto &x : E[a]) {
		if (x == pp)continue;
		Do(x, a);
		res = max(res, D[a] + D[x]);
		D[a] = max(D[a], U[a] + D[x]);
	}
	res = max(res, D[a]);
}
int main() {
	int i, a, b;
	scanf("%d", &n);
	for (i = 1; i < n; i++) {
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
	scanf("%s", p + 1);
	int rt = 0;
	for (i = 1; i <= n; i++) {
		if (p[i] == 'W')rt = i;
	}
	if (!rt) {
		puts("0");
		return 0;
	}
	DFS(rt, 0);
	for (i = 1; i <= n; i++) {
		if (!C[i])continue;
		int sz = 0;
		for (auto &t : E[i]) {
			if (C[t])sz++;
		}
		if ((sz % 2 == 1) == (p[i] == 'W')) {
			S += sz;
		}
		else {
			S += sz + 1;
			if(sz)U[i] = 1;
		}
	}
	Do(rt, 0);
	printf("%d\n", S - res * 2);
}

Measured memory_bytes: 11392
if __name__ == "__main__":
    num_n = int(input())
    n = list(map(lambda x: int(x), input().split()))

    num_m = int(input())
    m = list(map(lambda x: int(x), input().split()))

    for idx in range(min(num_n, num_m)):
        if (n[idx] == m[idx]):
            continue
        elif (m[idx] < n[idx]):
            print(0)
            exit(0)
        elif (n[idx] < m[idx]):
            print(1)
            exit(0)

    if (num_n < num_m):
        print(1)
    else:
        print(0)



Measured memory_bytes: 5624
import sys
input = sys.stdin.readline
def main(R,C,K,rcv):
  inf=float('inf')
  dp0=[[-inf,-inf,-inf,0] for _ in range(C)]
  item=[[0]*C for _ in range(R)]
  for r,c,v in rcv:
    item[r-1][c-1]=v
  # dp0[c][j]:c列目の時点で残りちょうどj個取れる時の最大値
  for i in range(R):
    # i+1行目に対する操作
    # 遷移
    for j in range(C):
      if j>0:
        dp0[j][3]=max(dp0[j])
        dp0[j][0]=dp0[j-1][0]
        dp0[j][1]=dp0[j-1][1]
        dp0[j][2]=dp0[j-1][2]
      else:
        dp0[0][3]=max(dp0[0])
        dp0[0][2]=-inf
        dp0[0][1]=-inf
        dp0[0][0]=-inf 
      if item[i][j]>0:
        v=item[i][j]
        dp0[j][0]=max(dp0[j][0],dp0[j][1]+v)
        dp0[j][1]=max(dp0[j][1],dp0[j][2]+v)
        dp0[j][2]=max(dp0[j][2],dp0[j][3]+v)
  print(max(dp0[-1]))
if __name__=='__main__':
  R,C,K=map(int,input().split())
  rcv=[list(map(int,input().split())) for _ in range(K)]
  main(R,C,K,rcv)


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, A;
	cin >> N >> A;

	cout << (N%500<=A?"Yes":"No") << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int n;
  cin >> n  ;
  long a[3*n] ;  
  for(int i=0;i<3*n;i++)
    cin >> a[i] ;
  
  sort(a,a+3*n,greater<int>()) ; 
  long ans =0;  
  for(int i=0;i<2*n;i++){
    if(i%2!=0)ans+=a[i];
  }
    
  cout << ans << endl ;
  
    return 0;
}


Measured memory_bytes: 2560
n,m = map(int,input().split())

l1 = [[] for i in range(n)]
l2 = []

for i in range(m):
    p,y = map(int,input().split())
    l1[p-1].append(y)
    l2.append((p,y))

dic = {}

for p in range(n):
    l1[p].sort()
    for i in range(len(l1[p])):
        dic[l1[p][i]] = i+1
        

for i in range(m):
    p = l2[i][0]
    k = dic[l2[i][1]]
    p = str(p)
    k = str(k)
    ans = "0"*(6-len(p))+p+"0"*(6-len(k))+k
    print(ans)




Measured memory_bytes: 83100
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define pll pair <lli,lli> 
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
 
const lli MOD=1e9+7;
const lli MAXN=1e7+1;
const lli INF=2e18;
const ld PI=acos(-1);
 
int main(){
    rapgame
    //freopen("brokeday.in", "r", stdin);
    //freopen("richday.out", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
        read2(n,m);
        vi a(n,-1);
        bool ok=1;
        fr(i,m){
            read2(s,c);
            s--;
            if((a[s]!=-1 && a[s]!=c) || (s==0 && c==0 && n>1)) ok=0;
            else a[s]=c;
        }
        if(ok) fr(i,n) if(a[i]!=-1) cout << a[i]; else cout << (n>1 && i==0 ? "1":"0");
        else cout << -1;
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 3656
package main

import "fmt"
var N int
var A [][]int
var dp [][]int

func max(a, b int) int {
	if a > b { return a }
	return b
}

func min(a, b int) int {
	if a < b { return a }
	return b
}

func abs(a int) int {
	if a < 0 { return -a }
	return a
}

func main() {
	_,e := fmt.Scanf("%d", &N)
	if e != nil { return }
	A = make([][]int, N)
	for i:=0; i<N; i++ {
		A[i] = make([]int, 3)
		for j:=0; j<3; j++ {
			_,e = fmt.Scanf("%d", &A[i][j])
			if e != nil { return }
		}
	}
	for i:=1; i<N; i++ {
		for j:=0; j<3; j++ {
			A[i][j] += max(A[i-1][(j+1)%3], A[i-1][(j+2)%3])
		}
	}
	res := -(1<<31-1)-1
	for i:=0; i<3; i++ {
		if A[N-1][i] > res { res = A[N-1][i]}
	}
	fmt.Println(res)
}


Measured memory_bytes: 11864
#include <iostream>
using namespace std;
int main(){
	int n; cin >> n;
	int h[n];
	for(int i = 0; i < n; i++) cin >> h[i];
	for(int i = 1; i < n; i++){
		if(h[i-1] < h[i]) h[i]--;
	}
	for(int i = 1; i < n; i++){
		if(h[i-1] > h[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,n) REP(i,0,n)
int main(void){
	int num_first,num_second;
	int *array_first,*array_second;
	int cnt =  0;
	int *array_temp;
	cin  >> num_first ;
	array_first = new int [num_first];
	rep(i,num_first){
		cin >> array_first[i];
	}
	cin >> num_second;
	array_second = new int [num_second];
	array_temp = new int [num_second];
	rep(i,num_second){
		cin >> array_second[i];
	}
	int cnt_temp = 0;
	sort(array_second,array_second + num_second);
	sort(array_first,array_first + num_first);
	rep(j,num_second){
		rep(i,num_first){
			if(array_first[i] == array_second[j]){ cnt++;break; }
		}
	}
//	rep(i,cnt_temp){
//		rep(j,cnt_temp){
//			if(array_temp[i] == array_temp[j]) cnt--;
//			}
//		}
	cout << cnt << endl;
	//cout << num_second << endl <<num_first<< endl;



		





	return 0;
}

Measured memory_bytes: 1240
import itertools


s = [int(i) for i in input()]
for bs in itertools.product((0, 1), repeat=3):
    res = s[0]
    expr = [str(s[0])]
    for b, n in zip(bs, s[1:]):
        if b:
            res += n
            expr.append("+")
            expr.append(str(n))
        else:
            res -= n
            expr.append("-")
            expr.append(str(n))
    if res == 7:
        print("".join(expr) + "=7")
        break



Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (b > a && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}



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

ll x, k, d, ans;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> x >> k >> d;

	if(x < 0) x = -x;

	ll a = x / d;

	if(k > a){
		if((k - a) % 2 == 0){
			ans = x - a * d;
		}else{
			ans = abs(x - (a + 1) * d);
		}
	}else{
		ans = x - d * k;
	}

	cout << ans;
}

Measured memory_bytes: 3604
N = int(input())
h = [int(i) for i in input().split()] 

cnt = 0
# 最大値を抽出

hmax = max(h)
while hmax > 0:
    for i in range(N):
        if h[i] == hmax:
            h[i] = h[i] - 1
            cnt = cnt + 1
            if i != N-1:
                if h[i+1] == hmax:
                    cnt = cnt - 1
    hmax = max(h)

print(cnt)

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

#define ll long long

int main()
{
   ll a,b;
   cin>>a>>b;
   for(int i=1;i<=1e4; ++i){
    int tax1 = i*8/100; int tax2 = i*10/100;
    if(tax1==a && tax2==b){
        cout<<i;
        return 0;
    }
   }
   cout<<-1;

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll h, a;
    cin >> h >> a;
    cout << ((h + (a - 1)) / a) << endl;
    
    return 0;
}


Measured memory_bytes: 256
from collections import deque
n,q = map(int,input().split())
v = [[0,0] for i in range(n+1)]
# print(v)
for i in range(n-1):
    a,b = map(int,input().split())
    v[a].append(b)
    v[b].append(a)
for i in range(q):
    p,x = map(int,input().split())
    v[p][1] += x
que = deque([1])
# print(v)
v[1][0] = 1
while que:
    temp = que.popleft()
    for i in v[temp][2:]:
        if v[i][0] == 0:
            v[i][0] = 1
            que.append(i)
            v[i][1] += v[temp][1]
# print(v)
ans = []
for i in v[1:]:
    ans.append(i[1])
    # print(i[1])
print(*ans)

Measured memory_bytes: 58420
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>

int rec(int,int,int);

using namespace std;

int n;
int k_n;
int k_prise,t_prise;
vector<int> topi;
vector<vector<int> > dp;

int main(){
	cin >> n;
	cin >> k_prise >> t_prise;
	cin >> k_n;

	dp.resize(n+1);
	int p = k_prise+t_prise*n;
	topi.resize(n+1);

	for(int i=1;i<n+1;i++){
		int tmp;
		dp[i-1].resize(p+1);
		cin >> tmp;
		topi[i] = tmp;;
	}
	dp[n].resize(p+1);
	for(int i=k_prise;i<=p;i++){
		dp[0][i] = k_n;
	}

	for(int i=1;i<=n;i++){
		for(int j=k_prise;j<=p;j++){
			dp[i][j] = dp[i-1][j];
			if(k_prise+t_prise <= j)dp[i][j] = max(dp[i][j],dp[i-1][j-t_prise]+topi[i]);
		}
	}

	//method
	//int ans = rec(0,k_n,k_prise);
	int ans = 0;
	for(int i=k_prise;i<=p;i++)ans = max(ans,dp[n][i]/i);

	cout << ans << endl;

	return 0;
}

int rec(int i,int cal,int prise){
	if(dp[i][prise] > -1){
		return dp[i][prise];
	}
	int res;
	if(i==n){
		res = cal/prise;
		dp[i][prise] = res;
	}
	else{
		int n1 = rec(i+1,cal,prise);
		int n2 = rec(i+1,cal+topi[i],prise+t_prise);
		res = max(n1,n2);
		if(res == n2)dp[i][prise+t_prise] = res;
		else dp[i][prise] = res;
	}
	return res;
}

Measured memory_bytes: 1800
#include<iostream>
using namespace std;
int main(){
  int A[3];
  for(int i=0;i<3;i++){
    cin >> A[i];
  }
  int min,max;
  min = 100;
  max = 0;
  for(int i=0;i<3;i++){
    if(min>A[i]){
      min = A[i];
    }
    if(max<A[i]){
      max = A[i];
    }
  }
  
  cout << max - min << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>

int main()
{
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if (c >= b || d <= a)
		printf("0\n");
	else{
		if (c >= a){
			if (b < d)
				printf("%d\n", b - c);
			else printf("%d\n", d - c);
		}
		if (c < a){
			if (d < b)	printf("%d\n", d - a);
			else printf("%d\n", b - a);
		}
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<math.h>

int main()
{
  int a,b,c;
  std::cin >> a >> b >> c;
  
  if((a < b) && (b < c)){
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3100
import sys
import numpy as np


def main(stdin):
    N, K, Q = stdin[:3]
    ans = np.full(N + 1, K - Q, dtype=np.int64)
    for i in stdin[3:]:
        ans[i] += 1
    return ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', 'i8[:](i8[:],)')(main)
    # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :]
    cc.compile()
else:
    #from my_module import main
    stdin = np.array([int(_) for _ in open(0).read().split()])
    ans = main(stdin)
    print(*np.where(ans > 0, 'Yes', 'No')[1:], sep='\n')


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

int solve(int a,int b,int c,int n){
  int ans=0;
  for(int i=0;i<=n/a;i++){
    for(int j=0;j<=(n-i*a)/b;j++){
      if((n-i*a-j*b)%c==0){
        ans++;
        //cout << i << "#" << j << "#" << endl;
      }
    }
  }
  return ans;
}

int main(){
  int a,b,c,n,ans;
  cin >> a >> b >> c >> n;
  ans=solve(a,b,c,n);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3496
// @date 2020-02-07 19:29 

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

#define ll long long

ll calc(ll H) {
    if(H ==1) return 1;
    return 2 * calc(H/2) + 1;
}

int main(void) {
    ll H;
    scanf("%lld", &H);
    printf("%lld", calc(H));

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)

const int mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<ll> v(1001);
    
    repn(i, 2, n){
        int x = i;
        repn(j, 2, i){
            while(x%j==0){
                v[j]++;
                x /= j;
            }
        }
    }

    ll ans = 1;
    rep(i, 0, v.size()){
        ans = (ans * (v[i] + 1)) % mod;
    }
    cout << ans;
    

    
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>

#define MAX_LEN (1200)

using namespace std;

int main()
{
    char* str = new char[MAX_LEN + 1];
    int*  counter = new int[26];

    for (int i = 0; i < 26; i++) {
         counter[i] = 0;
    }
    
    while (cin >> str) {
           for (int i = 0; str[i] != '\0'; i++) {
                if (str[i] >= 'A' && str[i] <= 'Z') {
                    str[i] = tolower(str[i]);
                }
           

           if (str[i] >= 'a' && str[i] <= 'z') {
               int num = str[i] - 'a';
               counter[num]++;
           }
}
    }

    for (int i = 0; i < 26; i++) {
         cout << (char)('a' + i) << " : " << counter[i] << endl;
    }

    delete[] str;
    delete[] counter;

    return (0);
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  vi H(n);
  for(auto &a:H)cin>>a;
  sort(ALL(H),greater<ll>());
  ll ans=0;
  for(int i=k;i<n;i++)ans+=H[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int p[100000];
int y[100000];

int n, m;
int main()
{
    cin >> n >> m;
    vector<vector<int>> v(n + 1, vector<int>(1));

    for (int i = 0; i < m; i++)
    {
        cin >> p[i] >> y[i];
        v[p[i]].push_back(y[i]);
    }

    for (int i = 0; i < n; i++)
    {
        sort(v[i + 1].begin(), v[i + 1].end());
    }
    for (int i = 0; i < m; i++)
    {
        printf("%06d", p[i]);
        int id = lower_bound(v[p[i]].begin(), v[p[i]].end(), y[i]) - v[p[i]].begin();
        printf("%06d\n", id);
    }
    return 0;
}

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

int main() {
  long long a, b;
  cin >> a >> b;
  if (a <= 0 && b >= 0)
    puts("Zero");
  else if (a > 0)
    puts("Positive");
  else if ((b - a + 1) & 1)
    puts("Negative");
  else
    puts("Positive");
  return 0;
}


Measured memory_bytes: 256
object Main extends App {

  import scala.io.StdIn._

  val n = readLine.trim.toInt
  val happiness = Array.tabulate(n){_ ⇒
    val Array(a, b, c) = readLine.trim.split(' ').map(_.toInt)
    Happiness(a, b, c)
  }
  println(solve(happiness))
  def solve(happiness: Array[Happiness]): Long = {
    val memo = Array.tabulate(happiness.length){_ ⇒ Array.tabulate(3){_ ⇒ None: Option[Long]}}
    def calMax(happiness: Array[Happiness], current: Int, prev: Int, memo: Array[Array[Option[Long]]]): Long = {
      if (!happiness.indices.contains(current)) 0L
      else {
        memo(current)(prev) match {
          case Some(r) ⇒ r
          case None ⇒ (0 until 3).filterNot(_ == prev).map { next ⇒ calMax(happiness, current + 1, next, memo) + happiness(current)(next) }.max.also { max ⇒ memo(current)(prev) = Some(max) }
        }
      }
    }
    for (i ← (happiness.indices by 100).reverse) calMax(happiness, i, 0, memo)
    (0 until 3).map(i ⇒ calMax(happiness, 0, i, memo)).max
  }
  case class Happiness(a: Int, b: Int, c: Int) {
    def apply(nTh:Int): Int = nTh match {
      case 0 ⇒ a
      case 1 ⇒ b
      case 2 ⇒ c
      case _ ⇒ ???
    }
  }
  implicit class Extend[T](value: T){
    def also(func: T ⇒ Unit): T = {func(value); value}
    def let[A](func: T ⇒ A): A = func(value)
  }
}

Measured memory_bytes: 137316
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

int main() {
    ll L, N;
    cin >> L >> N;

    vector <ll> X(N+1), Y(N+1), Xs(N+1), Ys(N+1);
    for (int i = 1; i <= N; i++) {
        cin >> X[i];
        Y[N + 1 - i] = L - X[i];
    }
    for (int i = 1; i <= N; i++) {
        Xs[i] = Xs[i - 1] + X[i];
        Ys[i] = Ys[i - 1] + Y[i];
    }

    ll ans = 0;
    for (int d = 0; d <= N; d++) {
        int xt = d, yt = N - d;
        for (int k1 = 0; k1 < 2; k1++) {
            for (int k2 = 0; k2 < 2; k2++) {
                int cx = min(xt, yt + (-dy[k1] - dy[k2] + dx[k1] + dx[k2]) / 2);
                int cy = min(yt, xt + (-dx[k1] - dx[k2] + dy[k1] + dy[k2]) / 2);
                if (cx < 0 || cy < 0) continue;

                ll result = 0;
                result += (Xs[xt] - Xs[xt - cx]) * 2;
                result += (Ys[yt] - Ys[yt - cy]) * 2;
                result -= (k2 ? Y[yt] : X[xt]);
                ans = max(ans, result);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

void fst()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
int mod = 1e9 + 7;
int binpow(int a, int b)
{
    int res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res = res * a;
            res %= mod;
        }
        a = a * a;
        a %= mod;
        b >>= 1;
        b %= mod;
    }
    return res;
}
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

#define Darr(x)           \
    cerr << #x << " = ";  \
    for (auto i : x)      \
        cerr << i << " "; \
    cerr << "\n";

#define deb(x) cerr << #x << "=" << x << " ";
#define int long long
#define R(n) for (int i = 0; i < n; i++)
#define Rj(n) for (int j = 0; j < n; j++)
#define F(i, a, n) for (int i = a; i <= n; i++)
int n, k, m, tc, x;


main(){
    int d,l,r;
    cin>>l>>r>>d;
    int cnt=0;
    for(int i=l;i<=r;i++)if(i%d==0)cnt++;
    cout<<cnt;
    
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N; cin>>N;
    vector<long long int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    long long int ans=0;
    for(int i=0;i<N;i++){
        ans=ans+(a[i]-1);
    }
        cout<<ans;
    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	double d; cin >> d;
	cout << max(d*sqrt(2.0), floor(d)+1.0) << el;
}

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



Measured memory_bytes: 3284
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	string S;
	cin >> S;
	string T = "AKIHABARA";
	bool used[9] = {};
	int pos = 0;
	bool ok = 1;
	for (int i = 0; i < S.size(); i++) {
		while (pos < T.size() && T[pos] != S[i]) pos++;
		if (pos >= T.size()) {
			ok = 0;
			break;
		}
		used[pos] = 1;
		pos++;
	}
	for (int i = 0; i < T.size(); i++) {
		if (!used[i] && T[i] != 'A') ok = 0;
	}
	if (ok) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

string s;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    int len = s.length();
    cout << s;
    if (s[len - 1] == 's') cout << "es" << '\n';
    else cout << 's' << '\n';
    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
typedef struct{char mark; int num;}Card;

void BubbleSort(Card* a, int n){
	int i,j;
	Card tmp;
	for(i=0;i+1<n;i++){
		for(j=n-1;j>=i+1;j--){
			if(a[j-1].num>a[j].num){
				tmp=a[j];
				a[j]=a[j-1];
				a[j-1]=tmp;
			}
		}
	}
}

void SelectionSort(Card* a, int n){
	int i,j,min,pos;
	Card tmp;
	for(i=0;i+1<n;i++){
		min=a[i].num;	pos=i;
		for(j=i+1;j<n;j++){
			if(min>a[j].num){
				min=a[j].num;
				pos=j;
			}
		}
		if(i!=pos){
			tmp=a[i];
			a[i]=a[pos];
			a[pos]=tmp;
		}
	}
}

int main(){
	int n,i,flag;	scanf("%d",&n);
	Card cards[36], a[36],b[36];
	for(i=0;i<n;i++){
		scanf(" %c%d",&cards[i].mark, &cards[i].num);

		a[i]=b[i]=cards[i];
	}

	BubbleSort(a,n);
	for(i=0;i<n;i++){
		if(i)printf(" ");
		printf("%c%d",a[i].mark, a[i].num);
	}printf("\nStable\n");

	SelectionSort(b,n);
	flag=1;
	for(i=0;i<n;i++){
		if(i)printf(" ");
		printf("%c%d",b[i].mark, b[i].num);
		if(!(a[i].num==b[i].num && a[i].mark==b[i].mark)){
			flag=0;
		}
	}printf("\n");

	if(flag)printf("Stable\n");
	else printf("Not stable\n");

	return 0;
}



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

int main()
{
	//??\??????????§?
	int S;
	//????????????????§?
	int h,m,s;
	
	//S????§??????\????????????????±???????
	cin >> S;
	h=S/3600;
	
	//S???3600??§?????£????????????S?????£??\??????????±???????
	S%=3600;
	m=S/60;
	
	//??\??????????§???????????????¨??????????????????S????§???§??????
	S%=60;
	s=S;
	cout << h << ":" << m << ":" << s << endl;
	//????????????????????????cout << S/3600 << ":" << S%3600/60 << ":" << S-(S/3600*3600+ << endl;
	
	return 0;
}

Measured memory_bytes: 3092
#include <iostream>

using namespace std;

using ll = long long int;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll ans = (n / (a + b) * a);
  if (n % (a + b) > a)
    ans += a;
  else
    ans += n % (a + b);

  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

n = int(input())
H = list(map(int, input().split()))

for i in range(1,n)[::-1]:
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        print("No")
        sys.exit()
print("Yes")

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a<=b){
        if(b<=c){
            cout<<a<<" "<<b<<" "<<c<<'\n';
        }
        else if(c<=b){
            cout<<a<<" "<<c<<" "<<b<<'\n';
        }
        else{
            cout<<c<<" "<<a<<" "<<b<<'\n';
        }
    }
    else{
        if(c<=b){
            cout<<c<<" "<<b<<" "<<a<<'\n';
        }
        else if(a<=c){
            cout<<b<<" "<<a<<" "<<c<<'\n';
        }
        else{
            cout<<b<<" "<<c<<" "<<a<<'\n';
        }
    }
    
    return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll N;
    cin >> N;

    vector<ll> L(N);
    rep (i, N) {
        cin >> L[i];
    }

    sort(L.begin(), L.end());

    ll ans = 0;
    rep (i, N) {
        for (ll j = i+1; j < N; j++) {
            for (ll k = j+1; k < N; k++) {
                if (L[i]+L[j] > L[k]) {
                    ans++;
                }
            }
        }
    }

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

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

LL X[112345];
LL W[112345];
typedef pair<LL,LL> P;
int N;
LL L,T;

bool check(vector<LL> res){
    REP(t,T){
        REP(i,N)
            if(W[i]==1)X[i]=(X[i]+1)%L;
            else X[i]=(X[i]+L-1)%L;
        REP(i,N)REP(j,N)if(i<j)if(X[i]==X[j]){
                swap(W[i],W[j]);
            }
    }
    REP(i,N){
        if(res[i]!=X[i]/2)return false;
        //  cout<<" "<<X[i]/2<<endl;
    }
    return true;
}

int main(){
    cin>>N>>L>>T;
    L*=2;
    T*=2;
    vector<LL> pos;
    vector<LL> res(N);
    vector<P> a,b;
    REP(i,N){
        LL w,x;
        cin>>x>>w;
        x*=2;
        X[i]=x;W[i]=w;
        if(w==1){
            a.pb(P(x,i));
            pos.pb((x+T)%L);
        }
        if(w==2){
            b.pb(P(x,i));
            pos.pb((x+L-T%L)%L);
        }
    }
    //corner
    if(a.size()==0||b.size()==0){
        REP(i,N)cout<<pos[i]/2<<endl;
        return 0;
    }
    sort(ALL(pos));
    LL k=0;
    LL t=T;
    {
        LL l=L/2;
        k+=(t/l)*b.size();
        t-=(t/l)*l;
        k%=N;
        //  cout<<k<<endl;
        for(auto &it:b){
            LL latte=a.front().fi;
            LL malta=it.fi;
            if(malta<latte)malta+=L;
            if((malta-latte)/2<t)k++;
        }
        k%=N;
        k=(k+a.front().se)%N;
    }
    LL K=(a.front().fi+T)%L;
    int i=0;
    while(pos[i]<K)i++;
    //cout<<k<<"  "<<K<<endl;
    REP(j,N)res[(k+j)%N]=pos[(i+j)%N]/2;
    REP(j,N)cout<<res[j]<<endl;
    //assert(check(res));
    
    return 0;
}


Measured memory_bytes: 6256
A = [None] * 3
A[0] = [int(i) for i in input().split()]
A[1] = [int(i) for i in input().split()]
A[2] = [int(i) for i in input().split()]
N = int(input())
b = [0] * N
for i in range(N):
  b[i] = int(input())

c = [[False for _ in range(3)] for _ in range(3)]
for _b in b:
  for i in range(3):
    for j in range(3):
      if A[i][j] == _b:
        c[i][j] = True

is_bingo = False
for i in range(3):
  if c[i][0] and c[i][1] and c[i][2]:
    is_bingo = True
  if c[0][i] and c[1][i] and c[2][i]:
    is_bingo = True
if c[0][0] and c[1][1] and c[2][2]:
  is_bingo = True
if c[2][0] and c[1][1] and c[0][2]:
  is_bingo = True

print("Yes" if is_bingo else "No")


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

const int maxn = 1e5 + 10;
int n;
vector <int> ad[maxn];
int sz[maxn];

bool dfs(int root, int P) {
	sz[root] = 1;
	bool ret = 0, C = 0;
	for (auto x : ad[root]) {
		if (x != P) {
			ret |= dfs(x, root);
			if (sz[x] % 2 == 1) {
				if (C)
					ret = 1;
				C = 1;
			}
			sz[root] += sz[x];
		}
	}
	return ret;
}

int main() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		ad[u].push_back(v);
		ad[v].push_back(u);
	}
	if (dfs(0, -1) || (n % 2 == 1))
		return cout << "First", 0;
	return cout << "Second", 0;
}

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

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)round(x))<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

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

  string s;
  int w;
  while (cin >> s >> w) {
    for (int i = 0; i < s.size(); i += w) {
      cout << s[i];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	int d[100000];
	for (int i = 0; i < n; i++)cin >> d[i];
	sort(d, d + n);
	cout << d[n / 2] - d[n / 2 - 1] << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll K;
  cin >> K;
  string S;
  rep(i, K)
    S += "ACL";
  cout << S << endl;
}


Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        int ans=0;
        for(int i=0;i<s.length();i++) {
            if(i == s.length()-2) {
                if(s.charAt(i)==s.charAt(i+1)) {
                    i++;
                }
            } else if (i!=s.length()-1){
                if(s.charAt(i)==s.charAt(i+1)) {
                    i++;
                    ans++;
                    i++;
                }
            }
            ans++;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 40676
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;


/***************/
 #define amin main
/***************/

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i;
	long double a;
	long double b;
	cin>>a>>b;
	a = a*b;
	ll k = a;
	cout<<k<<endl;


	
	

	
	


	
	return 0;
}

Measured memory_bytes: 3732