akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

const int MAX = 100005;
const int NIL = -1;
int n;
vector<int> G[MAX];
int color[MAX];


void dfs(int r, int c) {
  color[r] = c;
  for (int u: G[r]) {
    if (color[u] == NIL) {
      dfs(u, c);
    }
  }
}

int main() {
  int m, s, t, q;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  int color_id {0};
  memset(color, NIL, sizeof color);
  for (int i = 0; i < n; i++) {
    if (color[i] == NIL) {
      dfs(i, color_id++);
    }
  }

  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> s >> t;
    if (color[s] == color[t]) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 12044
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int a[MAXN];
vector<pii > p;
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) read(a[i]);
    sort(a + 1,a + N + 1,[](int c,int d){return c > d;});
    for(int i = 1 ; i <= N ; ++i) {
	if(a[i + 1] != a[i]) {
	    p.pb(mp(i,i - a[i]));
	}
    }
    int c = -1,d = p.size();
    
    while(c < (int)p.size() - 1 && p[c + 1].se <= 0) ++c;
    while(d > 0 && p[d - 1].se >= 0) --d;
    if(c >= 0) {
	if(p[c].se == 0) {puts("Second");return;}
    }
    bool f = 0;
    if(c >= 0 && d < (int)p.size()) {
	if(!((abs(p[c].se) ^ abs(p[d].se)) & 1)) {
	    f = (abs(p[c].se) & 1);
	}
	else {
	    int t = p[c].fi - a[p[c].fi + 1];
	    if(t == 0) f = 1;
	    else if(0 < t) {f |= abs(p[c].se) & 1;}
	    else f |= abs(p[d].se) & 1;
	}
    }
    else if(c >= 0) { f |= abs(p[c].se) & 1;}
    else if(d < (int)p.size()) {f |= p[d].se & 1;}
    if(f) puts("First");
    else puts("Second");
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i,n) cin >> l.at(i);
  sort(ALLR(l));
  int ans = 0;
  rep(i,k){
    ans+=l.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string s;
  cin >> s;
  map<int,int> used;
  rep(i,sz(s)) {
    used[s[i] - 'a']++;
  }
  if(sz(s) < 26) {
    char next = 0;
    while (true){
      if(used[next] > 0) {
         next++;
      } else {
        break;
      }
    }
    cout << s << (char)('a' + next) << endl;
    return 0;
  }
  char prev = s[25];
  drep(i,sz(s)) {
    if(i == 25) continue;
    if(s[i] - prev < 0) {
      cout << s.substr(0,i);
      map<int,int> pr;
      rep(x,i) {
        pr[s[x] - 'a']++;
      }
      char next = (char)(s[i] + 1);
      while(true) {
        if(pr[next - 'a'] > 0) {
          next++;
        } else {
          break;
        }
      }
      cout << next << endl;
      return 0;
    } else {
      prev = s[i];
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline
N = int(input())
A = [0] + [list(map(lambda x: tuple(sorted((i, int(x)))), input().split())) for i in range(1, N+1)]
Idx = [0]*(N+1)
pool = set()  # 対局待ち
q = deque([a[0] for a in A[1:]])
#day = [set() for _ in range(N*(N-1)//2)]
ans = 1
s = set()
while q:
    #print(pool, q)
    p = q.popleft()
    if p in pool:
        pool.remove(p)
        a, b = p
        Idx[a] += 1
        Idx[b] += 1
        if a in s or b in s:
            ans += 1
            s = {a, b}
        else:
            s.add(a)
            s.add(b)
        if Idx[a]<N-1:
            q.append(A[a][Idx[a]])
        if Idx[b]<N-1:
            q.append(A[b][Idx[b]])
    else:
        pool.add(p)
if pool:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 130824
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#define ll long long
int a[1005];
int main()
{
    int n,MIN=105,MAX=-105;
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            if(a[i]<MIN)
            {
                MIN=a[i];
            }
            if(a[i]>MAX)
            {
                MAX=a[i];
            }
        }
        int mini=4000005;
        for(int i=MIN;i<=MAX;i++)
        {
            int cost=0;
            for(int j=0;j<n;j++)
            {
                cost+=(int)pow(a[j]-i,2);
            }
            if(cost<mini)
            {
                mini=cost;
            }
        }
        printf("%d\n",mini);
    }
    return 0;
}


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

int main(){
    // input N
    int N;
    cin >> N;
    // input dish
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N-1);
    for( int i=0; i<N; i++){
        cin >> A[i];
    }
    for( int i=0; i<N; i++){
        cin >> B[i];
    }
    for( int i=0; i<N-1; i++){
        cin >> C[i];
    }

    // calc
    int ans = B[A[0] - 1];
    for( int i=1; i<N; i++){
        ans += B[A[i] - 1];
        if( A[i]-A[i-1] == 1 ){
            ans += C[A[i-1] - 1];
        }
    }
    // out
    cout << ans << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (998244353ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}


vl fact,finv;
ll modpw(ll x,ll k){
	ll res=1;
	while(k!=0){
		if(k&1)res=res*x%MOD;
		x=x*x%MOD;
		k=k>>1;
	}
	return res;
}

ll comb(ll n,ll k) {
	if(n==0&&k==0)return 1;
	if(n<k||n<0)return 0;
	return fact[n]*finv[n-k]%MOD*finv[k]%MOD;
}

struct ferm{
	ferm(ll n){
		fact.resize(n);
		finv.resize(n);
		fact[0]=1;
		finv[0]=1;
		rep(i,n-1){
			fact[i+1]=(fact[i]*(i+1))%MOD;
			finv[i+1]=modpw(fact[i+1],MOD-2);
		}
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m,k;
	cin>>n>>m>>k;
	ferm(200010);
	ll ans=0;
	rep(i,k+1){
		ll score=1;
		score=((m*modpw(m-1,n-i-1))%MOD)*comb(n-1,i)%MOD;
		ans=(ans+score)%MOD;
	}
	puta(ans);
}


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

int main() {
    int S;
    cin >> S;

    int h = S / 3600;
    int m = (S % 3600) / 60;
    int s = (S % 3600) % 60;

    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000000000000
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n,k;
    cin>>n>>k;
    lli h[n], dp[n];
    for(int i=0; i<n; i++)
    {
        dp[i]=inf;
        cin>>h[i];
    }
    dp[0]=0, dp[1]=abs(h[1]-h[0]);
    for(int i=2; i<n; i++)
    {
        for(int j=i-1; j>=max(0LL, i-k); j--)
            dp[i]=min(dp[i], dp[j]+abs(h[i]-h[j]));
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 5108
#include <stdio.h>

int main(void)
{
	int i;
	int data[3];
	int k;
	int max;
	int ans;
	
	
	for (i = 0; i < 3; i++){
		scanf("%d", &data[i]);
	}
	
	scanf("%d", &k);
	
	max = data[0];
	
	for (i = 1; i < 3; i++){
		if (max < data[i]) max = data[i];
	}
	
	ans = max;
	
	while (k > 0){
		ans *= 2;
		k--;
	}
	
	printf("%d\n", data[0] + data[1] + data[2] + ans - max);
	
	return (0);
	
}
	
	

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

using namespace std;
using uint = unsigned int;
using int64 = long long;
using i64 = int64;
using uint64 = unsigned long long;
using vint = vector<int>;
using vint64 = vector<int64>;
template<typename T>
using p_que = priority_queue<T>;
#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rep1(i,N) for(int i=1;i<=(int)(N);++i)
#define fs first
#define sc second
#define eb emplace_back
#define all(x) x.begin(),x.end()

template<typename T>
vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "[";
	for (auto& e : v) os << e << ", ";
	return os << "]";
}

template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U> p) {
	return os << "P(" << p.first << ", " << p.second << ")";
}

template<class T, class U> ostream& operator<<(ostream& os, const map<T, U>& mp) {
	os << "{";
	for (auto& e : mp) os << e << " ";
	return os << "}";
}

void Main();
signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
}

/* Cut from here! */

#define int long long

void Main() {
	i64 N, Q; cin >> N >> Q;
	using P = pair<i64, i64>;
	vector<i64> s(N);
	vector<P> v(N);
	rep(i, N) {
		cin >> s[i];
		s[i] *= -1;
		v[i].fs = s[i], v[i].sc = i;
	}

	sort(all(v));
	vector<int> t(N);
	map<i64, int> mp;
	rep(i, N) {
		t[v[i].sc] = i;
		s[i] = v[i].fs;
		if (mp.count(s[i]) == 0) mp[s[i]] = i;
		else mp[s[i]] = min(mp[s[i]], i);
	}

	multiset<int> L;
	rep(i, Q) {
		string com;
		int x;
		cin >> com >> x, x--;
		if (com == "ADD") {
			/*
			i64 num = s[t[x]];
			cout << num << " " << mp[num] << endl;
			L.emplace(mp[num]);
			*/
			L.emplace(x);
		}
		else if (com == "REMOVE") L.erase(x);
		else {
			x++;
			i64 ok = 1e9 + 1;
			int ng = -1;
			while (abs(ok - ng) > 1) {
				int i = 0;
				i64 m = (ok + ng) / 2;
				vector<P> res(L.size());
				for (auto& e : L) {
					auto itr = upper_bound(all(s), s[t[e]] + m);
					if (itr == s.begin()) continue;
					itr--;
					int idx = itr - s.begin();
					res[i] = P(mp[s[t[e]]], idx);
					++i;
				}

				sort(all(res));
				i64 sum = 0;
				i64 r = -1;
				for (int i = 0; i < res.size(); ++i) {
					if (res[i].sc <= r) continue;
					if (res[i].fs <= r) {
						sum += res[i].sc - r;
						r = res[i].sc;
					} else {
						sum += res[i].sc - res[i].fs + 1;
						r = res[i].sc;
					}
				}

				//cout << res << " " << m << " " << sum << endl;

				if (sum >= N - x) ok = m;
				else ng = m;
			}

			//for (auto& e : L) cout << e << " ";
			//cout << endl;

			if (ok == 1e9 + 1) cout << "NA" << endl;
			else cout << ok << endl;
		}
	}
}


Measured memory_bytes: 96452
#include<bits/stdc++.h>
#define DBG(x) cerr << #x << “ = ” << (x) << endl
#define Rep(i,a,b) for (int i = a, to = b; i < to; i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

typedef long long Long;

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	string n; cin>>n;
    Long sum = 0;
    Rep(i,0,n.size()){
        sum+=n[i]-'0';
    }
    if(sum%9==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
	return 0;
}

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

int main(void) {
    int n, ans = -1 << 30, f[100][10] = {}, p[100][11] = {};
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> f[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 10; j++) {
            cin >> p[i][j];
        }
    }
    for (int bit = 1; bit < (1 << 10); bit++) {
        int temp = 0;
        for (int i = 0; i < n; i++) {
            int c = 0;
            for (int j = 0; j < 10; j++) {
                if (f[i][j] && (bit >> j & 1)) c++;
            }
            temp += p[i][c];
        }
        ans = max(ans, temp);
    }
    cout << ans << endl;
}


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

class Program {
    static string ReadLine() { return Console.ReadLine().Trim(); }
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    static int Gcd(int m, int n) {
        int r = m % n;
        while (r != 0) {
            m = n;
            n = r;
            r = m % n;
        }
        return n;
    }

    static void Main() {
        var ab = ReadInts();
        int a = ab[0], b = ab[1];
        Console.WriteLine(Gcd(a, b));

    }
}

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

int n;
long long a[100000];
long long b[100001];

bool moveLeft(int middle) {
    for (int i = 0; i <=n ; i++) b[i]=0;
    b[0]=2*middle;
    for (int i = 1; i <= n; i++) {
        b[i]=(a[i-1]-b[i-1]/2)*2;
    }
    return b[n] <= b[0];
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    int left = 0, right=a[0];
    while (left <= right) {
        int middle = (left+right)/2;
        if (moveLeft(middle)) right = middle-1;
        else left = middle+1;
    }

    moveLeft(left);
    for (int i = 0; i < n; i++) cout << b[i] << " ";
    cout << endl;

    return 0;
}


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

int main(){
    int N, M;
    std::cin >> N >> M;
    std::vector< int > H(N);
    for(int i=0; i<N; i++){
        std::cin >> H[i];
    }
    std::vector< bool > ans(N, true);
    
    for(int i=0; i<M; i++){
        int a, b;
        std::cin >> a >> b;
        if(H[a - 1] == H[b - 1]){
            ans[b - 1] = false;
            ans[a - 1] = false;
        }else if(H[a - 1] > H[b - 1]){
            ans[b - 1] = false;
        }else{
            ans[a - 1] = false;
        }
    }
    
    int cnt = 0;
    for(int i=0; i<N; i++){
        if(ans[i]){
            cnt++;
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}



Measured memory_bytes: 3736
N = int(input())
L = list(map(int, input().split()))
# L.sort()
# print(L)
ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] == L[k] or L[k] == L[j] or L[i] == L[j]:
                continue
            if L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and L[k] + L[j] > L[i]:
                ans += 1
print(ans)


Measured memory_bytes: 68212
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];

    int ans = 0;
    for(int i = 0; i < n - 2; i++) {
        for(int j = i + 1; j < n - 1; j++) {
            for(int k = j + 1; k < n; k++) {
                if(l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) {
                    vector<int> v = {l[i], l[j], l[k]};
                    sort(v.begin(), v.end());
                    if(v[0] + v[1] > v[2]) ans++;
                }
            }
        }
    }

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

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

using namespace std;

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

    if(k >= a){
      k = k-a;
      a = 0;
    }
    else if(a > k){
        a = a-k;
        cout << a << " " << b;
        return 0;
    }
    if(k >= b){
        b = 0;
        cout << a << " " << b;
    }
    else if (b > k){
        b = b-k;
        cout << a << " " << b;
    }
}

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

int main(){
	int i,n,a,b,c,m;
	
	cin>>n;
	
	for(i=0;i<n;i++){
		m = 0;
		cin>>a>>b>>c;
		
		if(a*a == b*b+c*c)
			m = 1;
			
		else if(b*b == c*c+a*a)
			m = 1;
		
		else if(c*c == a*a+b*b)
			m = 1;
			
		if(m == 1)
			cout<<"YES"<<endl;
			
		else if(m == 0)
			cout<<"NO"<<endl;
			
		}
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
int main(){
  int N, i, j, k, ch = 0;
  int _N[100];
  scanf("%d",&N);
  for( i = 0 ; i < N ; i++)
    scanf("%d",&_N[i]);
  for(i = 0 ; i < N ; i++){
    for(j = N - 1 ; j >= i+1 ; j--){
      if(_N[j] < _N[j-1]){
    k = _N[j];
    _N[j] = _N[j-1];
    _N[j-1] = k;
    ch++;
      }
    }
  }
  for(i = 0 ; i < N-1 ; i++)
    printf("%d ",_N[i]);
  printf("%d\n",_N[i]);
  printf("%d\n",ch);
   return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
//#define random_shuffle(r...)random_shuffle(r,[](int _){return my_rand()%_;})


int main(){
  ll d,n;
  cin >> d >> n;

  ll counts = 0;
  ll i = 0;

  while(true){

  i++;
  ll k=0;
  ll copys = i;

  while(copys%100 == 0){
      k++;
      copys /= 100;
  }

   if(k ==d) counts++;

   if(counts == n){
      cout<<i<<endl;
      return 0;
   }

  }

 return 0;
}


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

int main()
{
	int n;
	cin >> n;
	vector<int> v( n );
	for( int i = 0; i < n; ++i )
	{
		cin >> v[i];
	}

	int ans = 0;
	int act = 0;
	for( int i = 0; i < n; ++i )
	{
		if( act < v[i] )	ans += v[i] - act;
		act = v[i];
	}

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

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

//input
int H, W;
vector<pair<int, int>> v, temp;
char field[1010][1010];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int bfs() {
    int ans = 0;
    while (v.size()) {
        bool flag = false; 
        for (int i = 0; i < v.size(); ++i){
           int y = v[i].first, x = v[i].second;
            for (int i = 0; i < 4; ++i) {
                int ny = y + dy[i], nx = x + dx[i];
                if (0 <= ny && ny < H && 0 <= nx && nx < W && field[ny][nx] == '.'){
                    field[ny][nx] = '#';
                    temp.push_back(make_pair(ny, nx));
                    flag = true;
                } 
            }
        }
        v.clear();
        v.resize(temp.size());
        copy(temp.begin(), temp.end(), v.begin());
        temp.clear();
        
        if (flag) ans++;
    }
    return ans;
}

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            char c;
            cin >> c;
            field[i][j] = c;
            if (c == '#') v.push_back(make_pair(i, j));
        }
    }
    cout << bfs() << endl;
    return 0;
}

Measured memory_bytes: 14184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll INF = 1000000000000000;
int K;
using P = pair<ll, double>;
vector<P> v;

int digitSum(ll x) {
  int res = 0;
  while (x) res += x % 10, x /= 10;
  return res;
}

double f(ll x) {
  return (double)x / digitSum(x);
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> K;
  for (int i = 1; i < 100000; i++) {
    ll tmp = i;
    while (tmp <= INF) {
      v.emplace_back(tmp, f(tmp));
      tmp = tmp * 10 + 9;
    }
  }
  sort(v.begin(), v.end(), [&](P a, P b) {
    if (a.second != b.second) return a.second < b.second;
    return a.first < b.first;
  });
  
  ll last = 0, cnt = 0;
  for (int i = 0; i < v.size(); i++) {
    if (v[i].first > last) {
      last = v[i].first;
      cout << last << endl;
      cnt++;
      if (cnt == K) break;
    }
  }

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n,k;
	cin >> n >> k;
	if (k == 1) {
		if (1 <= n)cout << "YES" << endl;
		else cout << "NO" << endl;
		return 0;
	}
	n--; k--;
	if (2 <= n / k){
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}



Measured memory_bytes: 3636
void main()
{
    string s = readln.chomp;

    writeln(s.canFind("AC") ? "Yes" : "No");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[]args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int[][] cell;
    int h, w;
    int i, j;
    
    void run(){
	while(sc.hasNext()){
	    h = sc.nextInt();
	    w = sc.nextInt();
	    if(h!=0 && w!=0){
		cell = new int[h+1][w+1];
		solve();
	    }
	}
    }

    void solve(){
	for(i=0; i<h; i++){
	    for(j=0; j<w; j++){
		cell[i][j] = sc.nextInt();
		cell[h][j] += cell[i][j];
		cell[i][w] += cell[i][j];
		cell[h][w] += cell[i][j];
	    }
	}
	print();
    }

    void print(){
	for(i=0; i<=h; i++){
	    for(j=0; j<=w; j++){
		System.out.print(cell[i][j]);
		if(j+1<=w)
		    System.out.print(" ");
	    }
	    System.out.println();
	}
    }
}

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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll n, a, x[50] = {}, dp[51][51][2501] = {};

int main() {
  cin >> n >> a;
  rep(i, 0, n) cin >> x[i];
  dp[0][0][0] = 1;

  rep(i, 0, n) for(int j = 0;j < i + 1;j++) for(int k = 0;k <= 2500;k++){
    dp[i + 1][j][k] += dp[i][j][k];
    dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
  }

  ll ans = 0;

  rep(i, 1, n + 1) {
    ans += dp[n][i][i * a];
  }

  cout << ans << endl;
}


Measured memory_bytes: 49152
/*
https://creep06.hatenablog.com/entry/20181031/1540979249
参考にさせて頂きました。
i write my code with looking this url's blog.
 */


#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)

#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

typedef unsigned long long ull;

ll n, m, s, t;

vll makedist(ll s,map<ll,set<pll>> branch){
    vll dist(n, infl);
    dist[s] = 0;
    set<ll> check;
    check.insert(s);
    while (!(check.empty())){
        ll now = *check.begin();
        check.erase(now);
        for (auto p:branch[now]){
            ll nex = p.F;
            ll d = p.S;
            if (dist[nex]>dist[now]+d){
                dist[nex] = dist[now] + d;
                check.insert(nex);
            }
        }
    }
    return dist;
}

int main(){
    map<ll, set<pll>> en;
    map<ll, set<pll>> snuuk;
    cin >> n >> m >> s >> t;
    s--;
    t--;
    ll u, v, a, b;
    rep(i,m){
        cin >> u >> v >> a >> b;
        u--;
        v--;
        en[u].insert(mp(v, a));
        en[v].insert(mp(u, a));
        snuuk[u].insert(mp(v, b));
        snuuk[v].insert(mp(u, b));
    }
    ll have = 1e15;
    vll endist = makedist(s, en);
    vll snukdist = makedist(t, snuuk);
    vll ans(n, infl);
    ans[n - 1] = endist[n - 1] + snukdist[n - 1];
    rep(i,n-1){
        ans[n - 2 - i] = min(ans[n - 1 - i], endist[n - 2 - i] + snukdist[n - 2 - i]);
    }
    rep(i, n) cout << have-ans[i] << endl;
}

Measured memory_bytes: 68992
N=int(input())
A=list(map(int,input().split()))
ans=float("inf")
S=[0]*(N+1)
S[0]=0
X=sum(A)
for i in range (1,N):
	S[i]=A[i-1]+S[i-1]
for i in range (1,N):
	ans=min(ans,abs(X-2*S[i]))
print(ans)

Measured memory_bytes: 24632
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    
    ll tmp = 0;
    
    if(N==1 || N==2){
        cout << 1 << endl;
        return 0;
        
    }
    for(int i=1;i<N;i++){
        tmp = i*i;
        if(tmp>N){
            cout << (i-1)*(i-1) << endl;
            return 0;
        }
    }
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll INF = 987654321987654321;

int main()
{
	int N, K;
	ll ans = -INF;
	cin >> N >> K;
	vector<int>P(N), C(N);
	for (auto&i : P)
	{
		cin >> i;
		i--;
	}
	for (auto&i : C)cin >> i;

	for (int i = 0; i < N; i++)
	{
		int cycleN = 0, now = i;
		ll cycleSum = 0;
		while (true)
		{
			cycleN += 1;
			cycleSum += C[now];
			now = P[now];
			if (now == i)break;
		}
		ll path = 0;
		int cnt = 0;
		while (true)
		{
			cnt++;
			path += C[now];
			if (cnt > K)break;
			ll score = path + max((ll)0, cycleSum)*((K - cnt) / cycleN);
			ans = max(ans, score);
			now = P[now];
			if (now == i)break;
		}
	}
	cout << ans;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long llong;
using namespace std;

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

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

#define ll long long
#define INF INT_MAX/3
#define pi 2*acos(0.0)
#define eps 1e-14

const int MAX_N = 1e+3;
const int MAX_M = 1e+2;
string s;
void input()
{
	cin >> s;
}
void solve() {
	string ans;
	ans = s;
	ans[5] = ' ';
	ans[13] = ' ';
	cout << ans << endl;
}
int main() {
	input();
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n,p=0,k=1;
  cin>>n;
  while(1)
  {
    if(k+(k*2)/25>n)
      break;
    else if(k+(k*2)/25==n)
    {
     p=k;
      break;
    }
    k++;
  }
  if(p)
    cout<<p;
  else
    cout<<":(";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fl(i,a,n)      for(int i=a;i<=n;i++)
#define pb             push_back
#define int            long long int
#define ump            unordered_map
#define pii            pair<int,int>
#define ff             first
#define ss             second
#define PI             3.1415926535898
#define inf            1e18
#define vi             vector<int>
#define endl           "\n"
#define print(a)       for(auto x:a){cout<<x<<" ";}cout<<endl;
#define mod            1000000007
 #define ONLINE_JUDGE
using namespace std;
template <typename Arg, typename... Args>
void db(Arg&& arg, Args&&... args) {
    cout << std::forward<Arg>(arg);
    using expander = int[];
    (void)expander{0, (void(cout << ',' << std::forward<Args>(args)), 0)...}; cout << endl;
}
inline void solve() {
    string  n; cin >> n;
    int s = 0;
    for (auto x : n) {
        s += x - '0';
    }
    if (s % 9 == 0) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    fl(i, 1, t)
    {
        solve();
    }

    return 0;
}

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

signed main() {
	int a,b;
	while (cin >> a >> b, a | b) {
		(a>b) ? (cout<<b<<" "<<a<<endl) : (cout << a << " " << b << endl);
}
}

Measured memory_bytes: 2960
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
	char name[100];
	int t;
} P;

P Q[LEN + 1];
int head, tail, n;

void enqueue(P x) {
	Q[tail++] = x;
	if (tail >= LEN) {
		tail = 0;
	}
}

P dequeue() {
	P u = Q[head++];

		if (head >= LEN) {
			head = 0;
		}
		return u;
}

int main() {
	int elaps = 0;
	int cnt = 0;
	int i, q;

	scanf("%d %d", &n, &q);

	tail = n;

	for (i = 0; i < n; i++) {
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}

	while (1) {
		if (Q[head].t <= q) {
			elaps += Q[head].t;
			printf("%s %d\n", Q[head].name, elaps);
			dequeue(Q[head]);
			cnt++;
			if (cnt == n) break;
		} else {
			Q[head].t -= q;
			elaps += q;
			enqueue(dequeue(Q[head]));
		}
	}

	return 0;
}

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

using namespace std;

const int maxn = 410;
const int maxm = 100010;

typedef pair<int,int> pi;

int n, m, ok;
int eu[maxm], ev[maxm], l[maxn], e;
int tag[maxm], vis[maxm], a[maxn];
vector<pi> vec[maxn];

struct Edge {
	int v, x, t;
} E[maxm << 1];

inline void addEdge(int u, int v, int t) {
	E[e].v = v, E[e].x = l[u], E[e].t = t, l[u] = e++;
	E[e].v = u, E[e].x = l[v], E[e].t = t, l[v] = e++;
}

void dfs(int u, int t, vector<pi> &vec) {
	vis[u] = 1;
	for (int p = l[u]; p >= 0; p = E[p].x) {
		if (E[p].t == t) continue;
		if (E[p].t <= t) {
			int v = E[p].v;
			if (vis[v]) ok = 0;
			else {
				vec.push_back(pi(E[p].t, u < v));
				dfs(v, E[p].t, vec);
			}
		}
	}
}

int main() {
	memset(l, -1, sizeof(l));
	memset(tag, -1, sizeof(tag));
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		scanf("%d%d", &eu[i], &ev[i]);
		addEdge(eu[i], ev[i], i);
	}
	for (int i = 1; i <= n; i++) {
		ok = 1;
		for (int j = 1; j <= n; j++) vis[j] = 0;
		dfs(i, m+1, vec[i]);
		a[i] = ok;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < vec[i].size(); j++) tag[vec[i][j].first] = vec[i][j].second;
		for (int j = i+1; j <= n; j++) {
			if (!a[i] || !a[j]) continue;
			int ok = 1;
			for (int k = 0; k < vec[j].size(); k++) {
				if (tag[vec[j][k].first] != -1 && tag[vec[j][k].first] != vec[j][k].second) {
					ok = 0;
				}
			}
			ans += ok;
		}
		for (int j = 0; j < vec[i].size(); j++) tag[vec[i][j].first] = -1;
	}
	printf("%d\n", ans);
	return 0;
}

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

const int MOD=1000000007;
//~ const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll sum[3][5000];

int id(char c){
	if(c=='R')return 0;
	if(c=='G')return 1;
	return 2;
}

int main(){
	int n;string s;cin>>n>>s;
	rep(i,n){
		if(s[i]=='R')sum[0][i]++;
		if(s[i]=='G')sum[1][i]++;
		if(s[i]=='B')sum[2][i]++;
	}
	rep(i,3){
		for(int j=n-2;j>=0;j--){
			sum[i][j]+=sum[i][j+1];
		}
	}
	ll ans=0;
	rep(a,n)for(int b=a+1;b+1<n;b++){
		if(s[a]==s[b])continue;
		int w=3-id(s[a])-id(s[b]);
		ll d=0;
		if(a+(b-a)*2<n){
			if(id(s[a+(b-a)*2])==w)d--;
		}
		d+=sum[w][b+1];
		ans+=d;
	}
	cout<<ans<<endl;
}

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

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

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  set<int> a;
  int q;
  cin >> q;
  vector<int> ans;
  rep(i,q) {
    int command; cin >> command;
    if (command == 0) {
      int x; cin >> x;
      a.insert(x);
      ans.push_back(a.size());
    } else if (command == 1) {
      int x; cin >> x;
      ans.push_back(a.find(x) != a.end());
    } else if (command == 2) {
      int x; cin >> x;
      a.erase(x);
    } else if (command == 3) {
      int l, r; cin >> l >> r;      
      auto itrl = a.lower_bound(l);
      auto itrr = a.upper_bound(r);
      for (auto itr = itrl; itr != itrr; itr++) ans.push_back(*itr);
    }
  }

  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 20312
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter

# import numpy as np
# import scipy as scp

# 入力の受け取り
s = input()
t = input()

ans = 0
for i,s in enumerate(s):
    if t[i] == s:
        ans += 1

print(ans)
# print("{:.10f}".format(ans))


Measured memory_bytes: 2940
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let (n, y): (i32, i32) = {
        let mut split = buf.split_whitespace();
        (split.next().unwrap().parse().unwrap(), split.next().unwrap().parse().unwrap())
    };
    for ten_thousand in 0..n + 1 {
        let remain = y - ten_thousand * 10000;
        let all_thousand = remain - (n - ten_thousand) * 1000;
        if all_thousand >= 0 && all_thousand % 4000 == 0 {
            let five_thousand = all_thousand / 4000;
            if ten_thousand + five_thousand <= n {
                writeln!(output, "{} {} {}", ten_thousand, five_thousand, n - ten_thousand - five_thousand).unwrap();
                return;
            }
        }
    }
    writeln!(output, "-1 -1 -1").unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "9 45000\n",
            "0 9 0\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "20 196000\n",
            "-1 -1 -1\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "1000 1234000\n",
            "2 54 944\n",
        );
    }

    #[test]
    fn case4() {
        test(
            "2000 20000000\n",
            "2000 0 0\n",
        );
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  vector<int> ans;
  VAR(string,s);
  REP(i,s.size()){
    switch(s[i]){
    case '0':
      ans.push_back(0);
      break;
    case '1':
      ans.push_back(1);
      break;
    default:
      if(!ans.empty()) ans.pop_back();
      break;
    }
  }

  EACH(ai,ans){
    OUT(ai);
  }
  BR;
  
  return 0;
}


Measured memory_bytes: 256
import numpy as np
S = input()
count = True
for i in np.arange(0, len(S), 2):
    if S[i] == "L":
        count = False
        
for i in np.arange(1, len(S), 2):
    if S[i] == "R":
        count = False

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

Measured memory_bytes: 22384
#include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n != -1)
	{
		string digits[10] = {"0111111", 
							 "0000110", 
							 "1011011", 
							 "1001111", 
							 "1100110", 
							 "1101101", 
							 "1111101", 
							 "0100111", 
							 "1111111", 
							 "1101111"};
		string current = "0000000";
		for(int i = 0; i < n; ++i)
		{
			int num;
			cin >> num;
			string ans = "";
			for(int j = 0; j < current.size(); ++j)
			{
				if(digits[num][j] == current[j])
				{
					cout << "0";
				}
				else
				{
					cout << "1";
					if(current[j] == '0')
					{
						current[j] = '1';
					}
					else
					{
						current[j] = '0';
					}
				}
			}
			cout << endl;
		}
	}
}

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

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0;; i++) {
        string a = s;
        for (int j = s.length() - i; j < s.length(); j++) {
            a += t[j];
        }
        bool f = 1;
        for (int j = 0; j < n; j++) {
            if (t[j] != a[a.length() - n + j]) f = 0;
        }
        if (f) {
            cout << a.length() << endl;
            return 0;
        }
    }
}

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

using namespace std;

#define ll long long
#define pii pair<ll, ll> //first is the number after the operations and second is the cost

int
main(void){
	int n; cin >> n;
	vector<ll> vec(n);
	for(int i = 0; i < n; i++) cin >> vec[i];
	vector<vector<pii> > dp(n + 1, vector<pii> (n + 1));
	for(int i = 0; i < n + 1; i++){
		for(int j = 0; j < n + 1; j++){
			dp[i][j].second = 1e15;
		}
	}
	for(int L = n - 1; L >= 0; L--){
		for(int R = L; R <= n - 1; R++){
			if(L == R){
				dp[L][R].first = vec[L];
				dp[L][R].second = 0;
			}
			else{
				for(int i = L; i < R; i++){
					//dp[L][R] = min(dp[L][R], dp[L][i] + dp[i + 1][R]);
					if(dp[L][R].second > (dp[L][i].first + dp[i + 1][R].first + dp[L][i].second + dp[i + 1][R].second)){
						dp[L][R].second = dp[L][i].first + dp[i + 1][R].first + dp[L][i].second + dp[i + 1][R].second;
						dp[L][R].first = dp[L][i].first + dp[i + 1][R].first;
					}
				}
			}
		}
	}
	
	/*for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cout << dp[i][j].first << " ";
		}
		cout << endl;
	}
	cout << endl;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cout << dp[i][j].second << " ";
		}
		cout << endl;
	}*/
	cout << dp[0][n - 1].second;
}

Measured memory_bytes: 2816
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {

	string s;
	cin >> s;

	int ans1 = 0, ans2 = 0;

	string ss="aaa";
	for (int i = 0; i < s.length();) {
		int j = 1;
		while (1) {
			string s1 = s.substr(i, j);
			
			if (s1 != ss) {
				ss = s1;
				ans1++;
				break;
			}
			j++;
			if ((i + j) > s.length()) { break; }
		}
		i += j;
	}

	reverse(s.begin(), s.end());

	ss = "aaa";
	for (int i = 0; i < s.length();) {
		int j = 1;
		while (1) {
			string s1 = s.substr(i, j);

			if (s1 != ss) {
				ss = s1;
				ans2++;
				break;
			}
			j++;
			if ((i + j) > s.length()) { break; }
		}
		i += j;
	}

	cout << max(ans1, ans2) << endl;

	return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll X(ll d) {
   return d*(d+1)/2;
}

ll get_value(ll len, ll l) {
   ll r = l + len;
   return X(r) - X(l);
}

int main() {
   ll B;
   while (cin >> B, B) {
      for (int len = 50000; len >= 0; len--) {
         if (X(len) > B) continue;

         ll ub = B + 10, lb = -1;
         while (ub - lb > 1) {
            ll mid = (ub + lb) / 2;

            if (get_value(len, mid) >= B) ub = mid;
            else lb = mid;
         }
         if (get_value(len, ub) == B) {
            printf("%lld %d\n", ub+1, len);
            break;
         }
      }
   }

   return 0;
}


Measured memory_bytes: 3188
A,B,C,D=map(int, input().split())
taka=0
ao=0
if C%B==0:
    taka=C//B
else:
    taka=C//B+1
if A%D==0:
    ao=A//D
else:
    ao=A//D+1

if taka<=ao:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61600
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

ll n, a, b, c, d;

int main() {
  cin >> a >> b >> c >> d;
  cin >> n;
  ll liter = min(c, min(4 * a, 2 * b));
  ll dva = min(d, 2 * liter);

  ll res = n / 2 * dva + liter * (n % 2);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
H=list(map(int,input().split()))
ans =[]
cnt = 0
if N == 1:
  print (0)
  exit()
for i in range( N-1 ):
  if H[i] >= H[i+1]:
    cnt += 1
  else:
    ans.append(cnt)
    cnt = 0
  ans.append(cnt)
print(max(ans))
       

Measured memory_bytes: 15020
let () = Scanf.scanf "%d\n%s\n" @@ fun n s ->
  Array.init (n + 1) (fun i ->
    Array.init 26 (fun c -> Char.chr @@ Char.code 'a' + c)
    |> Array.to_list
    |> List.filter (fun c ->
        List.exists (fun i -> s.[i] = c) (Array.to_list @@ Array.init i @@ fun j -> j) && List.exists (fun i -> s.[i] = c) (Array.to_list @@ Array.init (n - i) (( + ) i)))
    |> List.length)
  |> Array.fold_left max min_int
  |> Printf.printf "%d\n"


Measured memory_bytes: 2560
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());

    if(n%k==0){
      System.out.println(0);
    }else{
      System.out.println(1);
    }
 
  }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
	int w,n,i,j=1,lots[30],a,b,x,y,temp;	/*w:??????n:?¨?*/
	scanf("%d %d",&w,&n);
	for(i=0;i<w;i++){		/*lots???????????°???????????????*/
		lots[i]=j;
		j++;
		}
	for(i=0;i<w;i++){		/*?§?????????????????????\???*/
			for(i=0;i<n;i++){
					scanf("%d, %d",&a,&b);
					temp=lots[a-1];
					lots[a-1]=lots[b-1];
					lots[b-1]=temp;
				}
		}

	for(i=0;i<w;i++){
		printf("%d\n",lots[i]);
			}
	return 0;
}

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

char S[110] = {0};
int ans = 10e4;

int main()
{
    scanf("%s",S);
    for(int i = 0; i < 26; i++)
    {
        int MAX = -1,mem = 0;
        for(int j = 0; j < strlen(S) + 1; j++)
        {
            if(j == strlen(S))
            {
               MAX = max(MAX,mem);
               continue;
            }
            if(S[j] == 'a' + i)
            {
                MAX = max(MAX,mem);
                mem = 0;
            }
            else
            {
                mem++;
            }
        }
        ans = min(ans,MAX);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256