akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s,t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if (s < t){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}


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

using namespace std;

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

int main()
{
	int ans;
	vector<int> a;

	REP(i,3){
		int b;
		cin >> b;
		a.push_back(b);
	}

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

	if(a[0]==a[1]||a[0]==a[2]||a[1]==a[2]){
		if(a[0]==a[1]&&a[1]==a[2])
			ans = 0;
		else if(a[0]==a[1])
			ans = a[2]-a[1];
		else 
			ans = a[1]-a[0];
	}
	else
		ans = (a[1]-a[0])+(a[2]-a[1]);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 15;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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

	fread_unlocked(cn, 1, cm, stdin);
	int N = getint(), K = getint(), Q = getint();
	ll A[2002];
	int LR[2002];
	rep1(i, N) A[i] = ((ll)getint() << 16) + i;
	rep(i, N + 2) LR[i] = -1;

	priority_queue<int> q;
	priority_queue<int, vector<int>, greater<int>> q2[2002];
	int q3[2002];
	rep1(i, N) q3[i] = i;
	int kotae = 1e9;
	int saishou = 2e9;
	sort(A + 1, A + N + 1);
	const int m = (1 << 16) - 1;

	for (int i = N; i >= 1; i--) {
		int a = A[i] >> 16;
		int k = A[i] & m;

		int l = (LR[k - 1] == -1) ? k : LR[k - 1];
		int r = (LR[k + 1] == -1) ? k : LR[k + 1];
		LR[l] = r;
		LR[r] = l;

		int kosuu = max(min(K - 1, k - l), min(K - 1, r - k));
		if (k + k < l + r) swap(q3[l], q3[k + 1]);

		auto L = q2 + q3[l];
		auto R = q2 + q3[k + 1];

		while ((*R).size()) {
			(*L).push((*R).top());
			(*R).pop();
			if (kosuu == K - 1) {
				q.push((*L).top());
				(*L).pop();
			}
			else kosuu++;
		}
		(*L).push(a);
		if (kosuu == K - 1) {
			q.push((*L).top());
			(*L).pop();
		}
		while (q.size() >= Q) {
			int tmp = q.top();
			chmin(saishou, tmp);
			q.pop();
		}
		chmin(kotae, saishou - a);
	}

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,ave,total,te;
  cin>>N;
  total=0;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  for(int i=0;i<N;i++){
    total+=vec.at(i);
  }
  ave=total/N;
  te=ave+1;
  int ans=0,anns=0;
  for(int i=0;i<N;i++){
    ans+=(ave-vec.at(i))*(ave-vec.at(i));
    anns+=(te-vec.at(i))*(te-vec.at(i));
  }
  if (ans<anns){
    cout<<ans<<endl;
  }
  else if (ans>=anns){
    cout<<anns<<endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl enjoy_codeforces
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::string s;std::cin>>s;
    if((int)s.length()%2==1){
        std::cout<<"No"<<'\n';
        return 0;
    }
    for(int i=0;i<(int)s.length();i++){
        if(i%2==0&&s[i]!='h'||i%2==1&&s[i]!='i'){
            std::cout<<"No"<<'\n';
            return 0;
        }
    }
    std::cout<<"Yes"<<'\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using ll = long long;
int main()
{
    int N;
    ll MOD;
    std::cin >> N >> MOD;
    std::vector<std::vector<int>> g(N);
    for (int i = 0, x, y; i < N - 1; i++) { std::cin >> x >> y, x--, y--, g[x].push_back(y), g[y].push_back(x); }
    std::vector<ll> sub(N, 1LL);
    std::vector<ll> l(N, 1LL), r(N, 1LL);
    auto dp1 = [&](auto&& self, const int s, const int p) -> ll {
        ll L = 1;
        for (const int to : g[s]) {
            if (p == to) { continue; }
            const ll S = (1 + self(self, to, s)) % MOD;
            (sub[s] *= S) %= MOD;
            l[to] = L, (L *= S) %= MOD;
        }
        ll R = 1;
        for (int i = g[s].size() - 1; i >= 0; i--) {
            if (p == g[s][i]) { continue; }
            r[g[s][i]] = R, (R *= (sub[g[s][i]] + 1)) %= MOD;
        }
        return sub[s];
    };
    dp1(dp1, 0, -1);
    std::vector<ll> ans(N);
    auto dp2 = [&](auto&& self, const int s, const int p, const ll u) -> void {
        ans[s] = u * sub[s] % MOD;
        for (const int to : g[s]) {
            if (p == to) { continue; }
            self(self, to, s, ((l[to] * r[to] % MOD) * u + 1) % MOD);
        }
    };
    dp2(dp2, 0, -1, 1);
    for (int i = 0; i < N; i++) { std::cout << ans[i] << std::endl; }
    return 0;
}


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

int main() {
    int N, M, X;
    cin >> N >> M >> X;

    int A[M];
    for(int i = 0; i < M; i++) {
        cin >> A[i];
    }

    int i;
    for(i = 0; i < M; i++) {
        if(X < A[i]) {
            break;
        }
    }

    int ans;
    if(i < M-i) {
        ans = i;
    }
    else {
        ans = M-i;
    }

    cout << ans;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int mod = 1e9 + 7;

long modpow(long n, long p){
    long res = 1;
    while(p){
        if(p&1) res = res * n % mod;
        n = n * n % mod;
        p >>= 1;
    }
    return res;
}

int main(){
    string l;
    cin >> l;
    long ans = 0;
    int onenum = 0;
    for(int i=0;i<l.length();i++){
        if(l[i] == '1'){
            ans += modpow(3, l.length() - i - 1) * modpow(2, onenum) %mod;
            ans %= mod;

            onenum++;
        }
    }
    ans += modpow(2, onenum);
    
    cout << ans % mod << endl;
    return 0;
}


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

int main(){
	int card[4][13] = {};
	int maisuu;
	
	cin >> maisuu ;
	
	for(int i=0; i<maisuu; i++){
		char egara;
		int rank, egara2;
		cin >> egara >> rank;
		switch(egara){
			case 'S':
			  egara2 = 0;
			  break;
			case 'H':
			  egara2 = 1;
			  break;
			case 'C':
			  egara2 = 2;
			  break;
			case 'D':
			  egara2 = 3;
			  break;
		}
		card[egara2][rank - 1] = 1;
	}
	
	for(int i=0; i<4; i++){
		for(int j=0; j<13; j++){
			if(card[i][j] == 0){
				switch(i){
					case 0:
						cout << 'S' << " " ;
						break;
				    case 1:
						cout << 'H' << " " ;
						break;
				    case 2:
						cout << 'C' << " " ;
						break;
				    case 3:
					    cout << 'D' << " " ;
						break;
				}
				cout << j + 1 << endl;
			}
		}
	}
	
	
	return 0;
	 }
	

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

typedef long long int ll;

ll mod=1000000007;

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,m;
    cin>>n>>m;
    
    char v[n+1][m+1];
    vector<vector<ll> >dp(n+1,vector<ll>(m+1));
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>v[i][j];
        }
    }
    
    dp[n][m]=1;
    
    for(int i=n;i>=1;i--){
        for(int j=m;j>=1;j--){
            if(i==n && j==m)continue;
            
            if(v[i][j]=='#')continue;
            
            if(i==n)dp[i][j]=dp[i][j+1];
            else if(j==m)dp[i][j]=dp[i+1][j];
            else dp[i][j]=(dp[i+1][j]%mod+dp[i][j+1]%mod)%mod;
            
        }
    }
    
    cout<<dp[1][1];
    
    return  0;
}

Measured memory_bytes: 9088
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  h,w=LI()

  l=[]
  for i in range(h):
    l.append(S())

  a=[[0,-1],[-1,0],[1,0],[0,1]]

  for i in range(h):
    for j in range(w):
      b=l[i][j]
      f=True
      if b=='#':
        for k in a:
          _i=i
          _j=j
          _i+=k[0]
          _j+=k[1]
          if _i>=0 and _i<=h-1 and _j>=0 and _j<=w-1:
            if l[_i][_j]=='#':
              f=False
        if f:
          return 'No'
          exit()
  return 'Yes'


print(main())


Measured memory_bytes: 6688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int k,n;cin>>k>>n;
  vector<int> a(n+1);
  rep(i,n)cin>>a[i];
  a[n]=a[0]+k;
  int cnt=0;
  rep(i,n){
    int ans=a[i+1]-a[i];
    cnt=max(cnt,ans);
  }
  cout<<k-cnt<<endl;
}

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


 
int main() {


    int n,m;
    cin>>n>>m;


    multimap<int,int> relation;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;

 //       bool flg=true;
 //       auto p = relation.equal_range(a);
 //       for (auto it = p.first; it != p.second; ++it) {
 //           if(it->second==b){
 //               flg=false;
 //               break;
 //           }
 //       }
 //       if(flg){
        relation.emplace(a,b);
        relation.emplace(b,a);
 //       }
    }


    //探索する。
    vector<int> visit(n+1,-1);

    int max_count=1;
    for(int i=1;i<=n;i++){
        int cnt_wk=0;
        auto p=relation.count(i);
//        cout<<"======"<<endl;
//        cout<<endl;
//        cout<<"i="<<i<<endl;
//        cout<<"p="<<p<<endl;
//        cout<<"visit="<<visit.at(i)<<endl;
        if(p!=0 && visit.at(i)==-1){//空では無く未訪問の場合
//            cout<<"--"<<endl;
            queue<int> que;
            que.push(i); //iからスタート

            //BFS開始（キューが空になるまで探索を行う）
            while(!que.empty()){
                int v=que.front();
//                cout<<"v="<<v<<endl;
                que.pop();
                visit.at(v)=0;//訪問済みにする。
                cnt_wk++;
                //vからたどれるところを調べる。
                auto p = relation.equal_range(v);
                for(auto it=p.first; it != p.second; ++it){
                    if( visit[it->second] != -1) continue;

                    visit[it->second]=0;
                    que.push(it->second);
                }
            }
            max_count = max(max_count,cnt_wk);
        }
    }

    cout<<max_count<<endl;

 	return 0;
}


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

using namespace std;

int main()
{
   long long int n,d,c=0;
   cin>>n>>d;
   while(n--) {
    long long int x,y;
    cin>>x>>y;
    long long int a=x*x;
    long long int b=y*y;
    long long int f=a+b;
    if(f<=(d*d)) c++;
   }
   cout<<c;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
const ll mxN=1e9;
const ll mod = 1e9+7;

ll pow(ll a,ll b){

    ll r =1;

    while(b){
        if(b%2!=0) r=(r*a);
        a=(a*a);
        b/=2;
    }

    return r;
}

const int sz = 5e5+20;
ll fact[sz], inv[sz];
void pre(){
	fact[0] = 1;
	inv[0] = pow(fact[0], mod-2);
	for(int i=1;i<sz;i++){
		fact[i] = (fact[i-1]*i)%mod;
	}
}

int allmask;
int dp[1<<21][21];
int n;
vector<vector<int>> v(22);

int count(int a,int j){
    
    if(a==allmask) return 1;
    if(j>=n) return 0;

    if(dp[a][j]!=-1) return dp[a][j];
    
    int ways = 0;
    for(int i=0;i<v[j].size();i++){
        if(!(a&(1<<v[j][i]))) ways=(count(a|(1<<v[j][i]),j+1)+ways)%mod;
    }

    dp[a][j]=ways;
    return ways;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int a;
            cin>>a;
            if(a) v[i].push_back(j);
        }
    }

    memset(dp,-1,sizeof(dp));
    allmask = (1<<n)-1;

    cout<<count(0,0);
}

Measured memory_bytes: 175692
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    sort(a+1,a+n+1);
    int s=0;
    for(int i=n,j=1;i>=1,j<=k;i--,j++)
    s+=a[i];
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<vector>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

int main(){
     ll n,p=1;
    cin>>n;

    for(int i=1; i<=n; i++){
        p *= i;
        p %= 1000000007;
    }
    cout<<p<<endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = acos(-1.0); //

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())

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

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int color[h][w];
    pii now = MP(0, 0);

    rep2(i, n) {
        int a;
        cin >> a;

        rep(k, a) {
            color[now.first][now.second] = i;

            if (now.first % 2 == 0) {
                if (now.second == w - 1) now.first++;
                else now.second++;
            } else {
                if (now.second == 0) now.first++;
                else now.second--;
            }
        }
    }

    rep(i, h) {

        rep(j, w) {
            cout << color[i][j] << ((j == w - 1) ? "\n" : " ");
        }
    }

    return 0;
}



Measured memory_bytes: 384
N, K = [int(_) for _ in input().split()]
R, S, P = [int(_) for _ in input().split()]
T = input()
h = []
s = 0
for i, t in enumerate(T):
    if t == 'r':
        if i + 1 > K and h[i - K] == 'p':
            h.append('a')
            continue
        s += P
        h.append('p')
    elif t == 's':
        if i + 1 > K and h[i - K] == 'r':
            h.append('a')
            continue
        s += R
        h.append('r')
    elif t == 'p':
        if i + 1 > K and h[i - K] == 's':
            h.append('a')
            continue
        s += S
        h.append('s')
print(s)


Measured memory_bytes: 4212
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

ll cnt[2005] = {};

int main(void){
	ll n, x, y;
	cin >> n >> x >> y;
	x--, y--;
	rep(i, n - 1){
		REP(j, i + 1, n){
			ll dist = j - i;
			if(i <= x && y <= j) chmin(dist, j - y + x - i + 1);
			else if(i <= x) chmin(dist, y - j + x - i + 1);
			else if(y <= j) chmin(dist, j - y + i - x + 1);
			else chmin(dist, y - j + i - x + 1);
			cnt[dist]++;
		}
	}

	repn(i, n - 1) co(cnt[i]);

	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

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

	vector<int>v(3);
	for (int i = 0; i < 3; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	if ((v[2] - v[1]) % 2 && (v[2] - v[0]) % 2) {
		cout << (v[2] * 2 - v[0] - v[1]) / 2 << endl;
		return 0;
	}
	if ((v[2] - v[1]) % 2 == 0 && (v[2] - v[0]) % 2 == 0) {
		cout << (v[2] * 2 - v[0] - v[1]) / 2 << endl;
		return 0;
	}
	cout << ((v[2] + 1) * 3 - v[0] - v[1] - v[2]) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger;

 
class Main implements Runnable {
  // static Scanner in;
  static FastReader in;
  static PrintWriter out;
  static int[][] dirs8 = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {-1, -1}, {-1, 1}, {1, -1}};
  static int[][] dirs = {{0, -1}, {1, 0}, {0, +1}, {-1, 0}};
 
  static int[][] E;
  // static List<int[]>[] adj;
  static List<Integer>[] adj;
  static int[] vis;
 
  static long INFL = (long) 1e15 + 7;
  static int INF = (int) 1e9 + 7;
  static int mod = 998244353;
  
  static int T, n, m, k, count, cur, w;
  static boolean flag;
  static int[] a, b;
  static int[][] map;

  static int[] par;
  static long[] dp;

  static void solve() throws Exception {
    n = in.nextInt();
    w = in.nextInt();
    dp = new long[w + 1];
    for (int i = 0; i < n; i++) {
      int ww = in.nextInt();
      int vv = in.nextInt();

      for (int j = w - ww; j >= 0; j--) {
        dp[j + ww] = Math.max(dp[j + ww], dp[j] + vv);
      }
    }

    out.println(dp[w]);

  }

 

  public static void main(String[] args) throws Exception {
 
    // in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    in = new FastReader();
    out = new PrintWriter(System.out);
 
    // int numOfTests = in.nextInt();
    // for (int caseNum = 1; caseNum <= numOfTests; caseNum++) {
    //   // Thread t = new Thread(null, new Main(), "Main", 1 << 28);
    //   // t.start();
    //   // t.join();
    //   solve();
    // }
 
    // // Thread t = new Thread(null, new Main(), "Main", 1 << 28);
    // // t.start();
    // // t.join();
    solve();
 
    out.flush();
    out.close();
  }
 
  @Override
  public void run() {
    try {
      solve();
    } catch (Exception e) {
      e.printStackTrace(); 
    }
  }
 
  static class FastReader {
    public BufferedReader br; 
    StringTokenizer st; 
    public FastReader() {br = new BufferedReader(new InputStreamReader(System.in));} 
    String next() { 
      while (st == null || !st.hasMoreElements()) { 
          try {st = new StringTokenizer(br.readLine());} 
          catch (IOException e) {e.printStackTrace();} 
      } 
      return st.nextToken(); 
    } 
    int nextInt() {return Integer.parseInt(next());} 
    long nextLong() {return Long.parseLong(next());} 
    double nextDouble() {return Double.parseDouble(next());} 
    String nextLine() {
      String str = ""; 
        try {str = br.readLine();} 
        catch (IOException e) {e.printStackTrace();} 
        return str; 
    }
  }

  static void as(boolean result) throws Exception {
    if (!result) {
      throw new Exception();
    }
  }

  static int modInverse(int a, int m) { 
    int m0 = m; 
    int y = 0, x = 1; 
    if (m == 1) {return 0;} 
    while (a > 1) { 
      // q is quotient 
      int q = a / m; 
      int t = m; 
      // m is remainder now, process 
      // same as Euclid's algo 
      m = a % m; 
      a = t; 
      t = y; 
      // Update x and y 
      y = x - q * y; 
      x = t; 
    } 
    // Make x positive 
    if (x < 0) 
      x += m0; 
    return x; 
  } 
} 

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

int main(void){
    int n, k;
    cin >> n >> k;
    
    int h[100000];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    
    sort(h, h + n);
    
    int min = h[n - 1] - h[0];
    for(int i = 0; i < n - k + 1; i++){
        if(h[k + i - 1] - h[i] < min){
            min = h[k + i - 1] - h[i];
        }
    }
    
    cout << min << endl;
    
    return 0;
}


Measured memory_bytes: 640
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());

        List<LinkedList<Integer[]>> graph = new ArrayList<>();
        int s,t;
        int[] color = new int[n];
        int[] edge = new int[n-1];
        for(int i=0;i<n;i++){
            graph.add(new LinkedList<>());
        }
        for(int i=0;i<n-1;i++){
            s = Integer.parseInt(sc.next())-1;
            t = Integer.parseInt(sc.next())-1;
            graph.get(s).add(new Integer[]{t,i});
            graph.get(t).add(new Integer[]{s,i});
        }
        sc.close();
        Queue<Integer> queue = new ArrayDeque<>();
        int K = 0;
        queue.add(0);
        while(queue.size() > 0){
            int v = queue.poll();
            int now = 0;
            for(Integer[] i : graph.get(v)){
                if(edge[i[1]]==0){
                    now++;
                    if(now == color[v])now++;
                    color[i[0]] = edge[i[1]] = now;
                    queue.add(i[0]);
                }
            }
            K = Math.max(K,now);
        }
        
        PrintWriter out = new PrintWriter(System.out);
        out.println(K);
        for(int i=0;i<n-1;i++){
            out.println(edge[i]);
        }
        out.flush();

    }
    
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n , a , b ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>a>>b ;
	if(b/n > (a-1)/n)
		cout<<"OK" ;
	else
		cout<<"NG" ;
	cout<<"\n" ;
	return 0 ;
}		

Measured memory_bytes: 3636
# ABC075c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]


def root(x):
    if(tree[x] == x):
        return x
    tree[x] = root(tree[x])
    return tree[x]  # 経路圧縮


def same(x, y):  # xとyが同じ木に属するか
    return root(x) == root(y)


def unite(x, y):
    x = root(x)
    y = root(y)
    if(x == y):
        return
    tree[x] = y


ans = 0
for i in range(m):
    # print('init')
    tree = []
    for k in range(n+1):
        tree.append(k)
    for j in range(m):
        if (i == j):
            continue
        # print(a[j])
        unite(a[j][0], a[j][1])
    flag = True
    for j in range(1, n+1):
        for k in range(j + 1, n+1):
            if (not same(j, k)):
                flag = False
    if (not flag):
        ans += 1
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
#include<stdlib.h>
int fun(char *);
int fun(char *s)
{
    int p=1,ans=0;
    int i;
    if(s[0]=='g')
    {
        ans=0;
    }
    if(s[0]=='p')
    {
        ans=-1;
    }
    for(i=1;s[i]!='\0';i++)
    {
        if(s[i]=='g')
        {
            if(p>0)
            {
                ans++;
                p--;
            }
            else
            {
                p++;
            }
        }
        if(s[i]=='p')
        {
            if(p>0)
            {
                p--;
            }
            else
            {
                ans--;
                p++;
            }
        }
    }
    return ans;
}
int main()
{
    char a[100010];
    scanf("%s",a);
    printf("%d\n",fun(a));
    return 0;
}

Measured memory_bytes: 256
// ALDS1_4_B: Binary Search

fn scan<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n = s.trim().parse().ok().unwrap();
    n
}

fn scan_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let a = s.split_whitespace().map(|n| n.parse().ok().unwrap()).collect();
    a
}

fn main() {
    let n: usize = scan();
    let a: Vec<i64> = scan_vec();
    let m: usize = scan();
    let b: Vec<i64> = scan_vec();

    let mut ans: usize = 0;

    for b in &b {
        if a.binary_search(b).is_ok() {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 6964
#include <iostream>
#include <list>
#include <cstdio>
using namespace std;

int main()
{
	int n;
	list<int> lst;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		char com[12];
		int x;
		scanf("%s", com);
		if (com[0] == 'i') {
			scanf("%d", &x);
			lst.push_front(x);
		}
		else if (com[6] == 'F')
		{
			lst.pop_front();
		}
		else if (com[6] == 'L')
		{
			lst.pop_back();
		}
		else
		{
			scanf("%d", &x);
			for (list<int>::iterator it = lst.begin(); it != lst.end(); it++) {
				if (*it == x) {
					lst.erase(it);
					break;
				}
			}
		}
	}

	int i = 0, siz = lst.size();
	for (list<int>::iterator it = lst.begin(); it != lst.end(); it++) {
		printf("%d", *it);
		if (++i != siz)
			printf(" ");
	}
	printf("\n");

	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  ll ret    = 0;
  int right = 0;
  int sum   = 0;
  for (int left = 0; left < N; left++) {
    while (right < N && (sum ^ A[right]) == (sum + A[right])) {
      sum += A[right++];
    }
    ret += right - left;
    if (left == right)
      right++;
    else
      sum -= A[left];
  }
  cout << ret << '\n';
  return 0;
}


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

using namespace std;

int main() {
  
  int N, K, ans;
  cin >> N >> K;
  
  for (int i = 0 ; i < N ; i++){
    
    int x;
    cin >> x;
    
    if ( x < K / 2.0 ){
      ans += abs(x) * 2;
    }
    
    else {
      ans += abs(K - x) *2 ;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
 
 
int main(){
 
    double a,b;
    scanf("%lf %lf",&a,&b);
 
    printf("%.6lf\n",(a*b)/3.305785);
 
    return 0;
}


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


int main() {
  int A, B, K;
  int i;
  scanf ("%d %d", &A, &B);
  
  
  if ((A+B)%2==0)  printf("%d", abs((A+B)/2));
  else             printf("IMPOSSIBLE");
  return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define x first
#define y second
#define loop(i, start, end) for(int i=start; i<=end; ++i)
#define loopr(i, end, start) for(int i=end; i>=start; --i)
#define MOD 1000000007
using namespace std;

int readInt () {
	bool minus = false;
	int result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

template <typename T>
void cloneArray(T *a, T *b, int start, int end) {
    loop(i, start, end) {
        *(b+i)=*(a+i);
    }
}

template <typename T>
void inputArray(T *a, int start, int end) {
    loop(i, start, end) cin >> a[i];
}

template <typename T>
void printArray(T *a, int start, int end) {
    loop(i, start, end) cout << *(a+i) << ' ';
}

void ruffleSort(int *a, int n) {
    unsigned seed=0;
    shuffle(a, a+n, default_random_engine(seed));
    sort(a, a+n);
}

int main()
{   
    IOS;
	string s, t;
	cin >> s >> t;
	int n=t.length();
	int ans=INT_MAX;
	loop(i, 0, s.length()-n) {
		int sum=0;
		string r=s.substr(i, n);
		loop(j, 0, n) if(r[j]!=t[j]) ++sum;
		ans=min(ans, sum);
	}
	cout << ans;
    //cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
    return 0;
}

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

using namespace std;

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

const ll INF=1e9+7;
int n,g=1,p=1;
int a[100001];
bool f[100001];
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	while(a[p]!=2){
		if(f[a[p]]==1){
			cout<<-1;
			return 0;
		}
		f[p]=1;
		p=a[p];
		g++;
	}
	cout<<g;
	return 0;
}

Measured memory_bytes: 768
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            String a = S.substring(0, 2);
            String b = S.substring(2);
            boolean yymm = isYY(a) && isMM(b);
            boolean mmyy = isMM(a) && isYY(b);
            if (yymm && mmyy) {
                out.println("AMBIGUOUS");
            } else if (!yymm && mmyy) {
                out.println("MMYY");
            } else if (yymm && !mmyy) {
                out.println("YYMM");
            } else {
                out.println("NA");
            }
        }

        private boolean isMM(String a) {
            try {
                int n = Integer.parseInt(a);
                return 0 < n && n < 13;
            } catch (NumberFormatException e) {
                return false;
            }
        }

        private boolean isYY(String a) {
            try {
                Integer.parseInt(a);
                return true;
            } catch (NumberFormatException e) {
                return false;
            }
        }

    }
}



Measured memory_bytes: 21844
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val n = readInteger()
    val wList = Array(n) { readLine()!! }
    val distinct = wList.distinct()
    if (wList.size != distinct.size) {
        println("No")
        return
    }

    var pre = wList[0]
    for (i in 1 until n) {
        if (pre.last() != wList[i].first()) {
            println("No")
            return
        }

        pre = wList[i]
    }
    println("Yes")
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 35916
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
        //cout << A[i] << endl;
    }
    int n = 1;
    int c = 0;
    int i = 0;
    
    while(i<N){
        if(A[i] == n){
            n++;
        }
        else{
            A[i] = 0;
            c++;
        }
        i++;
        //cout << "i" << i << "c" << c << "n" << n << endl;
    }
    
    if(N == c){
        cout << -1 << endl;
    }
    else{
        cout << c << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,k;
    int ans=0;
    cin >> n >> k;
    map<int,int>syurui;
    rep(i,n){
        int k;
        cin >> k;
        syurui[k]++;
    }
    vector<int>kazu;
    for(auto c : syurui){
        kazu.push_back(c.second);
    }
    sort(kazu.begin(),kazu.end());
    
    if(kazu.size() <= k){
        cout << 0 << endl;
        return 0;
    }
    else{
        int a = kazu.size() - k;
        rep(i,a){
            ans += kazu[i];
        }
        cout <<ans <<endl;
    }
    
}

Measured memory_bytes: 10748
var
	h,w,i,j,x,y,tx,ty,l,r,dir,cnt:Longint;
	qx,qy:array[1..2500]of Longint;
	dx:array[1..4]of Longint=(0,1,0,-1);
	dy:array[1..4]of Longint=(1,0,-1,0);
	s:array[1..50]of String[50];
	d:array[1..50,1..50]of Longint;
begin
	readln(h,w);
	for i:=1 to h do begin
		readln(s[i]);
		for j:=1 to w do if s[i,j]='.'then inc(cnt);
	end;
	d[1,1]:=1;
	qx[1]:=1;
	qy[1]:=1;
	l:=1;
	r:=2;
	while r>l do begin
		x:=qx[l];
		y:=qy[l];
		inc(l);
		for dir:=1 to 4 do begin
			tx:=x+dx[dir];
			ty:=y+dy[dir];
			if(tx<1)or(ty<1)or(tx>h)or(ty>w)or(s[tx,ty]='#')or(d[tx,ty]<>0)then continue;
			qx[r]:=tx;
			qy[r]:=ty;
			d[tx,ty]:=d[x,y]+1;
			inc(r);
		end;
	end;
	if d[h,w]=0 then writeln('-1')
	else writeln(cnt-d[h,w]);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int b=700;
  char a;
  cin>>a;
  if(a=='o')b+=100;
    cin>>a;
  if(a=='o')b+=100;
    cin>>a;
  if(a=='o')b+=100;
  cout<<b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pp;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<pp> C(N);
    for(int i=0; i<N; ++i) {
        cin >> A[i] >> B[i];
        C[i] = pp(A[i] + B[i], i);
    }
    sort(C.begin(), C.end(), greater<pp>());

    long long ans = 0;
    for(int i=0; i<N; ++i) {
        if(i % 2 == 0) ans += A[C[i].second];
        else ans -= B[C[i].second];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.ArrayList;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[] a=new long[n];
		ArrayList<Long> list=new ArrayList<>();
		ArrayList<Long> re = new ArrayList<>();
		for(int i = 0; i<n; i++){
			a[i]=sc.nextLong();
		}
		for(int i =0; i<n; i++){
			long sum=0;
			for(int j=i; j<n; j++){
				sum+=a[j];
				list.add(sum);
			}
		}
		long ans=0;
		for(int i =40; i>=0; i--){
			re=new ArrayList<>();
			for(long j:list){
				if(((j>>i)&1)==1){
					re.add(j);
				}
			}
			if(re.size()>=k){
				ans+=1L<<i;
				list=re;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 52172
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll get_num(vll tmp){
  ll a = tmp[0]*1000000000+tmp[1]*1000000+tmp[2]*1000+tmp[3];
  ll b = tmp[1]*1000000000+tmp[2]*1000000+tmp[3]*1000+tmp[0];
  ll c = tmp[2]*1000000000+tmp[3]*1000000+tmp[0]*1000+tmp[1];
  ll d = tmp[3]*1000000000+tmp[0]*1000000+tmp[1]*1000+tmp[2];
  return min({a, b, c, d});
}

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vvl v = VV(n, 4, 0, ll);
  map<ll, ll> mp;

  for(int i=0;i<n;i++){
    scanf("%lld %lld %lld %lld", &v[i][0], &v[i][1], &v[i][2], &v[i][3]);
    ll num = get_num(v[i]);
    auto itr = mp.find(num);
    if(itr==mp.end()) mp.emplace(num, 1);
    else (*itr).second++;
  }

  ll ans = 0;
  for(int i=0;i<n;i++){
    ll I = get_num(v[i]);
    for(int j=i+1;j<n;j++){
      ll J = get_num(v[j]);
      for(int k=0;k<4;k++){
        map<ll, ll> z;
        for(int t=0;t<4;t++){
          //t, t+1, t+k+1, t+k
          ll num = get_num(vll{v[i][(t+1)%4], v[i][t], v[j][(-t+k+1+4)%4], v[j][(-t+k+4)%4]});
          auto itr = z.find(num);
          if(itr==z.end()) z.emplace(num, 1);
          else (*itr).second++;
        }
        ll tmp = 1;

        for(auto to:z){
          //if(i==1&&j==3&&k==2) std::cout << to.first << '\n';
          ll num = to.first;
          auto itr = mp.find(num);
          if(itr==mp.end()){
            tmp = 0;
            break;
          }
          ll max_num = (*itr).second;
          if(num==I) max_num--;
          if(num==J) max_num--;
          if(max_num<to.second){
            tmp = 0;
            break;
          }
          ll a = num/1000000000;
          ll b = (num-a*1000000000)/1000000;
          ll c = (num - a*1000000000 - b*1000000)/1000;
          ll d = num%1000;
          for(int p=0;p<to.second;p++) {
            tmp *= (max_num - p);
            if(a==b && b==c&&c==d) tmp *= 4;
            else if(a==c&&b==d) tmp *= 2;
          }
        }
        ans += tmp;
      }
    }
  }
  std::cout << ans/3 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc159/tasks/abc159_b>
 問題文============================================================
 B - String Palindrome
 =================================================================
 解説=============================================================

 全体・前半・後半の3部分について回文判定を行えばいい。


 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string S; cin >> S;
    int N = (int)S.length();
    auto check = [&](int l,int r){
        while(l < r){
            if(S[l] != S[r]) return false;
            l++; r--;
        }
        return true;
    };
    if(check(0,N-1) &&
       check(0,(N-1)/2-1) &&
       check((N-1)/2+1,N-1)) return "Yes";
    else return "No";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


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

int main(void) {
    int N;cin>>N;
    vector<bool> flg;
    if (N == 0) {
        cout << 0 << endl;
        return 0;
    }
    while (N != 1) {
        if (N < 0 && N % 2 != 0) {
            N = N / (-2) + 1;
            flg.push_back(true);
        } else {
            if (N % 2 == 0) flg.push_back(false);
            else flg.push_back(true);
            N /= -2;
        }
    }
    flg.push_back(true);
    reverse(flg.begin(), flg.end());
    for (int i = 0; i < flg.size(); i++) {
        if (flg.at(i)) cout << 1;
        else cout << 0;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 504
s = gets.chomp.split("").sort
t = gets.chomp.split("").sort.reverse
slen = s.length
tlen = t.length
i = 0
ispossible = false
while i < slen && i < tlen
  if s[i] < t[i]
    ispossible = true
    break
  elsif s[i] == t[i]
    i += 1
  else
    break
  end
end
if ispossible
  puts "Yes"
else
  if (i == slen || i == tlen) && slen < tlen
  puts "Yes"
  else
  puts "No"
  end
end

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

signed main(){
int s[100005];
int a;
scanf("%lld",&a);
fill(s,s+a+3,LONG_MAX);
int b;
for(int c=0;c<a;c++){
	scanf("%lld",&b);
	auto x=lower_bound(s,s+a+1,b);
	*x=b;
}
for(int q=0;q<a+3;q++){
if(s[q]==LONG_MAX){printf("%lld\n",q);break;}
}

}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<string> s(N);
	for (int i = 0; i < N; ++i) { cin >> s[i]; }

	map<string, Int> mp;
	for (int i = 0; i < N; ++i) {
		sort(s[i].begin(), s[i].end());
		mp[s[i]] += 1;
	}

	Int ans = 0;
	for (auto it = mp.begin(); it != mp.end(); ++it) {
		Int v = it->second;
		ans += v * (v - 1) / 2;
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main() {
	int a[100];
	int minv = 10000000;

	int sum = 0;
	bool flag = 0;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		if (a[i] % 10 == 0) {
			sum += a[i];
		}
		else {
			flag = 1;
			int num = 10 - (a[i] % 10);
			sum += (num + a[i]);
			minv = min(minv, a[i] % 10);
		}
	}

	if (flag == 0) {
		cout << sum << endl;
	}
	else {
		cout << sum - (10 - minv) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  int flag=0;
  for(int i=0;i<n-1;i++){
    if(a.at(i)==a.at(i+1)){
      flag=1;
    }
  }
  if(flag==0){
    cout<<"YES";
  }else{
    cout<<"NO";
  }
}

Measured memory_bytes: 3968
// Starting with the name of Allah

#include <bits/stdc++.h>
#define ll long long
#define nl endl
#define Nayon ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b


using namespace std;



int main()
{
	Nayon;
	int a,b,i,n;
	cin>>n;
	for(i=1;i<10;i++){
		if(n%i==0){
			a=i;
		}
	}
	b=n/a;
	if(b>9){
		cout<<"No"<<nl;
	}
	else{
		cout<<"Yes"<<nl;
	}
	return 0;
}

//Happy Coding........

Measured memory_bytes: 3632
import math
def isPrime(s,t):
    cnt=0
    tmp=-1
    s.sort()
    t.sort()
    for i in s:
        if i!=tmp:
            for j in t:
                if i==j:
                    cnt=cnt+1
                    break;
        tmp=i
    return cnt
n=int(input())
s=list(map(int,input().split()))
q=int(input())
t=list(map(int,input().split()))
print(isPrime(s,t))



Measured memory_bytes: 6568
#include<bits/stdc++.h>
using namespace std;
main(){
  while(1){
    int n,m;
    int tomodati[505][505]={0};
    int check[505]={0};
    cin>>n>>m;
    if(n==0&&m==0)break;
    int a,b;
    for(int i=0;i<m;i++){
      cin>>a>>b;
      tomodati[a][b]=1;
      tomodati[b][a]=1;
    }
    queue<int> que;
    int cnt=0;
    for(int i=2;i<=n;i++){
      if(tomodati[1][i]==1){
	cnt++;
	check[i]=1;
	que.push(i);
      }
    }
    int size=que.size();
    for(int i=0;i<size;i++){
      for(int j=2;j<=n;j++){
	if(tomodati[que.front()][j]==1&&check[j]!=1){
	  cnt++;
	  check[j]=1;
	}
      }
      que.pop();
    }
    cout<<cnt<<endl;
  }
}

Measured memory_bytes: 2204
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a+b > c+d) cout << "Left" << endl;
  else if (a+b < c+d) cout << "Right" << endl;
  else cout << "Balanced" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    int l[n];
    int sum = 0;
    for(int i = 0;i < n;i++)
    {
        cin >> l[i];
        sum += l[i];
    }
    sort(l,l + n);
    for(int i = 0;i < n - k;i++)
    {
        sum -= l[i];
    }
    cout << sum;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
int main(){
    int n;
    int ans=0;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    
    for(int i=1; i<n-1; i++){
        if(a[i-1]<a[i] && a[i]<a[i+1] || a[i-1]>a[i] && a[i]>a[i+1])ans++;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 	3.14159265358979323846

int main(){
	ll H,W;
	while(1){
		bool turn=true;
		cin >> H >> W;
		if(H==0&&W==0){break;}
		REP(i,H){
			if(turn){turn = false;}else{turn = true;}
			REP(j,W){
				if(turn){
					if(j%2==1){
						printf("#");
					}else{
						printf(".");
					}
				}else{
					if(j%2==0){
						printf("#");
					}else{
						printf(".");
					}
				}
			}
			printf("\n");
		}
	printf("\n");
	}
  return 0;
}


Measured memory_bytes: 3024
main(s,t,T){double x,y;
	for(t=90;scanf("%d,%d",&s,&T),s||T;t-=T)x+=s*cos(t*3.141/180),y+=s*sin(t*3.141/180);
	printf("%d\n%d\n",(int)x,(int)y);
	exit(0);
}

Measured memory_bytes: 604