akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#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 in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
//const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);


int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	vll dp(n + 1, vl(n + 1));
	dp[0][0] = 1;
	rep(i, n) {
		rep(j, n) {
			if (j == 0) {
				(dp[i + 1][j] += dp[i][j]) %= MOD;
				(dp[i + 1][j + 1] += dp[i][j]) %= MOD;
			}
			else {
				(dp[i + 1][j - 1] += 2 * dp[i][j]) %= MOD;
				(dp[i + 1][j + 1] += dp[i][j]) %= MOD;
			}
		}
	}
	cout << dp[n][s.size()] << endl;
}

Measured memory_bytes: 195840
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pctll(ll x) { return __builtin_popcountll(x); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }

struct DSU {
    int n, comps;
    vector<int> par, siz;

    DSU(int _n) {
        n = _n;
        comps = n;
        par = vector<int>(n);
        iota(par.begin(), par.end(), 0);
        siz = vector<int>(n, 1);
    }

    int find(int x) { // Path compression
        return x == par[x] ? x : par[x] = find(par[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int fsz(int x) {
        return siz[find(x)];
    }

    bool connected() {
        return comps == 1;
    }

    void unify(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        --comps;
        if (siz[x] < siz[y]) swap(x, y); // Small-to-Large
        par[y] = x;
        siz[x] += siz[y];
    }
};

void solve(int tcn) {
	int n, m;
	cin >> n >> m;
	DSU d(n);
	while (m--) {
		int x, y;
		cin >> x >> y;
		d.unify(x-1,y-1);
	}
	cout << d.comps - 1 << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		//cout << "Case #" << i << ": ";
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
const long long LINF=1e18;
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}

signed main(){
  int n,a,b;cin>>n>>a>>b;
  a--;b--;
  if(a>b)swap(a,b);
  if((b-a)%2==0)fin((b-a)/2);
  int ans=LINF;
  int A=a,B=b;
  int tmp=0;
  B-=A;A=0;tmp=a;
  B--;tmp++;
  tmp+=(B-A)/2;
  ans=tmp;
  tmp=0;


  b=n-1-b;a=n-a;
  A=b;B=a;a=A;
  B-=A;A=0;tmp=a;
  B--;tmp++;
  tmp+=(B-A)/2;
  chmin(ans,tmp);
  cout<<ans<<endl;
}


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

using namespace std;

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

    int k;
    cin >> k;

    int a = A[0];

    if (A[4] - A[0] <= k) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int  min, med, max;
         if( a > b ){
            if( a > c ){
                max = a;
                if( b > c ){
                med = b;
                min = c;
           }else{
                med = c;
                min = b;
            }
           }else{
                med = a;
            if( b > c ){
                max = b;
                min = c;
           }else{
                max = c;
                min = b;
           }
           }
           }else{
            if( b > c ){
                max = b;
            if( a > c ){
                med = a;
                min = c;
           }else{
                med = c;
                min = a;
           }
           }else{
                med = b;
                max = c;
                min = a;
           }
           }
          System.out.println(min + " " + med + " " + max);
}
}


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

typedef long long LL;
#define MP make_pair
#define N 100010

int a[N];

int main()
{
	/*srand(time(NULL));
	int n;
	n = 8;
	for (int i = 1; i <= n; ++i)
		a[i] = rand() % 20;
	sort(a + 1, a + n + 1);
	
	int p[20];
	for (int i = 1; i <= n; ++i)
		p[i] = i;
	
	int mx = 0, best[200];
	do
	{
		int s = 0;
		for (int i = 2; i <= n; ++i)
			s += abs(a[p[i]] - a[p[i - 1]]);
		if (s > mx) 
		{	
			mx = s;
			for (int i = 1; i <= n; ++i) best[i] = p[i];
		}
		//cout << s << " " << mx << endl;
	}while (next_permutation(p + 1, p + n + 1));
	for (int i = 1; i <= n; ++i) p[i] = i;
	do
	{
		int s = 0;
		for (int i = 2; i <= n; ++i)
			s += abs(a[p[i]] - a[p[i - 1]]);
		if (s == mx) 
		{	
			for (int i = 1; i <= n; ++i) cout << p[i] << " ";
			cout << endl;
		}
		//cout << s << " " << mx << endl;
	}while (next_permutation(p + 1, p + n + 1));
	//for (int i = 1; i <= n; ++i) cout << best[i] << " ";*/
	
	int n;
	LL now = 0, ans = 0;
	scanf("%d", &n); 
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	if (n & 1)
	{
		int x = (n + 1) / 2, R = n, L = 1;
		now = 0;
		for (int i = 1; i < n; ++i)
		{
			if (i & 1) now += abs(a[R] - a[x]), x = R--;
			else now += abs(a[L] - a[x]), x = L++;
		}
		ans = now;
		
		now = 0;
		x = (n + 1) / 2;
		L = 1, R = n;
		for (int i = 1; i < n; ++i)
		{
			if (i % 2 == 0) now += abs(a[R] - a[x]), x = R--;
			else now += abs(a[L] - a[x]), x = L++;
		}
		ans = max(ans, now);	 
	}
	else
	{
	    int x = n / 2, R = n, L = 1;
		now = 0;
		for (int i = 1; i < n; ++i)
		{
			if (i & 1) now += abs(a[R] - a[x]), x = R--;
			else now += abs(a[L] - a[x]), x = L++;
		}
		ans = now;
		
		now = 0;
		x = n / 2 + 1;
		L = 1, R = n;
		for (int i = 1; i < n; ++i)
		{
			if (i % 2 == 0) now += abs(a[R] - a[x]), x = R--;
			else now += abs(a[L] - a[x]), x = L++;
		}
		ans = max(ans, now);
	}
	
	cout << ans << endl;
	return 0;
}

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

#define ll long long

int main()
{
    int K, N;
    ll sum=0;

    std::cin >> N;
    std::cin >> K;

    std::vector<int> data(N, 0);

    for(int i=0; i < N; i++) {
        std::cin >> data[i];
    }

    for(int i=1; i < N; i++) {
        for(int j=i; j > 0; j--) {
            if (data[j] < data[j-1]) {
                int tmp = data[j];
                data[j] = data[j-1];
                data[j-1] = tmp;
            }
        }
    }
    for(int i=0; i < K; i++) {
        sum += data[i];
    }
    std::cout << sum << std::endl;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define N 1000005
using namespace std;

void solve(){
	int n,k;
	cin >> n >> k ;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int dp[k + 1] = {};
	for(int i = 0; i <= k; i++){
		for(auto val : a){
			if(i - val >= 0 && dp[i - val] == 0)
				dp[i] = 1;
		}
	}
	cout << (dp[k] == 1 ? "First" : "Second");
}
int32_t main()
{
	FLASH
	int t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 4404
import java.util.*;


class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int result = 0;
        //a>=13を満たす時bを返す,満たさないときで、a>=6を満たすb/2,満たさないなら0
        System.out.println(result = (a >= 13) ? b : (a >= 6) ? b / 2 : 0);
    }
}

Measured memory_bytes: 21204
#include <iostream>
int main()
{
    int S, h, m, s;
    std::cin >> S;
    s = S;
    m = s / 60;
    s = s % 60;
    h = m / 60;
    m = m % 60;
    std::cout << h << ":" << m << ":" << s << std::endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;
#define push_back pb
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;

int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int power(int a, int b){
	if(b < 0)return 0;
	int re = 1;
	while(b){
		if(b&1){
			re = mul(re, a);
		}
		a = mul(a, a);
		b >>= 1;
	}
	return re;
}
int const N = 100000 + 5;
int fact[N], inverse[N];
void FAC(){
 	fact[0] = 1;
	for(int x = 1; x< N; x++){
		fact[x] = mul(fact[x-1], x);
	}
	inverse[N-1] = power(fact[N-1], mod -2);
	for(int x = N-2; x>= 0; x--){
		inverse[x] = mul(x + 1, inverse[x+1]);
	}

 }

int ncr(int a, int b){
	if(a < b)return 0;
	return mul(fact[a], mul(inverse[a-b], inverse[b]));
}

/******************************************************/
void solve(){
	int n;
	cin >> n;
	vector<int> vec(n), a(n), b(n);
	for(int x = 0; x<n; x++)vec[x] = x+1;
	map<vector<int>, int> ma;
	int a1 = 0;
	do{
		ma[vec] = a1++;
	}while(next_permutation(ALL(vec)));
	for(auto &a1 : a)cin >> a1;
	for(auto &a1 : b)cin >> a1;
	cout << abs(ma[a] - ma[b]);
}


/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}

}

Measured memory_bytes: 5248
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int x[50];
ll dp[51][51][2501];
int main() {
	int N, A;
	cin >> N >> A;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	dp[0][0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= i; j++) {
			for (int k = 0; k <= j * 50; 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;
	for (int i = 1; i <= N; i++) {
		ans += dp[N][i][A*i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 48640
#include <cstdio>
#include <numeric>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
#include <deque>

using namespace std;

#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); i++)
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define fill(x,y) memset(x,y,sizeof(x))
#define prev PREV
#define next NEXT
                         
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef double D;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> inline T sqr (T x) { re x * x; }

#define filename ""

const int mod = 1000*1000*1000+7;

int n;
int m;
int x[100010];
int y[100010];

int main () {
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) scanf ("%d", &x[i]);
	for (int i = 1; i <= n; i++) scanf ("%d", &y[i]);
	x[0] = 0;
	y[n + 1] = 0;
	int ans = 1;
	for (int i = 1; i <= n; i++) {
		if (x[i] != x[i - 1] && y[i] < x[i]) ans = 0;
		if (y[i] != y[i + 1] && x[i] < y[i]) ans = 0;
		if (x[i] == x[i - 1] && y[i] == y[i + 1])
			ans = ((ll)ans * min (x[i], y[i])) % mod;
	}
	printf ("%d\n", ans);
	return 0;
}

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

int main(void){
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	vector<int> b(m);
	vector<int> ans_and;
	vector<int> ans_or;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	for(int i = 0; i < m; ++i){
		cin >> b[i];
	}
	int num_a = 0, num_o = 0;
	int i = 0, j = 0;
	while(true){
		if(a[i] == b[j]){
			ans_and.push_back(a[i]);
			ans_or.push_back(a[i]);
			i++; j++;
		}else if(a[i] > b[j]){
			ans_or.push_back(b[j]);
			j++;
		}else{
			ans_or.push_back(a[i]);
			i++;
		}
		if(i == n || j == m) {break;}
	}
	while(i != n){ ans_or.push_back(a[i]); i++;}
	while(j != m){ ans_or.push_back(b[j]); j++;}
	cout << ans_and.size() << " " << ans_or.size() << endl;
	for(auto x : ans_and) cout << x << endl;
	for(auto x : ans_or) cout << x << endl;
	return 0;
}


Measured memory_bytes: 4948
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const long long INF = 1LL << 60;

int s,w;

int main()
{
  cin >> s >> w;
  if(w >= s) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}

Measured memory_bytes: 3628
n = int(input())
A = list(map(int, input().split()))
now = 1
brok = 0
for i in range (n):
    if(A[i] != now):
        brok += 1
    else:
        now += 1
if(now == 1):
    print(-1)
else:
    print(brok)
        

Measured memory_bytes: 24744
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
};

/** Problem1306 : Ballon Collecting **/
vector<int> T, P;
int N;
int NG;
int dp[41][4];

int solve(int i, int s)
{
	if (i == N) return P[N-1];
	
	if (dp[i][s]>-1) return dp[i][s];
	
	int res=INF;
	
	int cT, cP;
	if (i==0) cT=0, cP=0;
	else	  cT=T[i-1], cP=P[i-1];
	
	bool ok=false;
	if (s+1<=3 && cT+(s+1)*abs(cP-P[i]) <= T[i]) {
		res = min(res, abs(cP-P[i])+solve(i+1, s+1));
		ok = true;
	}
	
	// 一度帰る
	if (cT+(s+1)*cP+P[i] <= T[i]) {
		res = min(res, cP+P[i]+solve(i+1, 1));
		ok = true;
	}
	
	if (!ok) NG = max(NG, i+1);
	
	return dp[i][s] = res;
}

int main()
{
	while (cin>>N, N) {
		T.resize(N), P.resize(N);
		NG = -1;
		memset(dp, -1, sizeof(dp));
		
		rep(i, N) {
			cin>>P[i]>>T[i];
		}
		int ans = solve(0, 0);
		
		if (ans < INF)
			cout << "OK " << ans << endl;
		else
			cout << "NG " << NG << endl;
	}
}

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

int main() {
  int n;
  cin >> n;
  
  int x,y,z,w;
  x = n % 10;
  y = ((n-x)/10)%10;
  z = ((n-x-y*10)/100)%10;
  w = ((n-x-y*10-z*100)/1000)%10;
  
  if((x==y && x==z)||(y==z && z==w)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  
  
  //test出力
  /*
  cout << "x:" << x << endl;
  cout << "y:" << y << endl;
  cout << "z:" << z << endl;
  cout << "w:" << w << endl;
*/
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))


def f(x):
    if x == 0:
        return 0
    else:
        return x // abs(x)


a1 = [0] * n

if a[0] != 0:
    a1[0] = a[0]
    ans = 0
else:
    a1[0] = 1
    ans = 1

b = a1[0]

for i in range(1, n):
    if b * (b + a[i]) >= 0:
        if a[i] != 0:
            a1[i] = -f(a1[i - 1]) - b
        else:
            if b > 0:
                a1[i] = -1
            else:
                a1[i] = 0
        if b + a1[i] == 0:
            a1[i] += f(a1[i])
        ans += abs(a1[i] - a[i])
    else:
        a1[i] = a[i]

    b += a1[i]

a2 = [0] * n

if a[0] != 0:
    a2[0] = -f(a[0])
    ans1 = abs(a2[0] - a[0])
else:
    a2[0] = -1
    ans1 = 1

b1 = a2[0]

for i in range(1, n):
    if b1 * (b1 + a[i]) > 0:
        if a[i] != 0:
            a2[i] = -f(a2[i - 1]) - b1
        else:
            if b1 > 0:
                a2[i] = -1
            else:
                a2[i] = 0
        if b1 + a2[i] == 0:
            a2[i] += f(a2[i])
        ans1 += abs(a2[i] - a[i])
    else:
        a2[i] = a[i]

    b1 += a2[i]

print(min(ans1, ans))

Measured memory_bytes: 14332
/* https://atcoder.jp/contests/dp/tasks/dp_h */

#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const int MAX = 1010;
const ll mod = 1e9 + 7;

char g[MAX][MAX];
ll dp[MAX][MAX];
int main() {
	ll H, W;
	cin>>H>>W;
	ll x, y;
	for (int i = 0;i < H;++i) {
		string s;
		cin>>s;
		for (int j = 0;j < W;++j) {
			g[i][j] = s[j];
		}
	}

	dp[0][0] = 1;

	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			if (i == 0 && j == 0) {
				continue;
			}

			if (i == 0) {
				if (g[i][j] == '.') {
					dp[i][j] = dp[i][j-1];
				}
			}
			else if (j == 0) {
				if (g[i][j] == '.') {	
					dp[i][j] = dp[i-1][j];
				}
			}
			else if (g[i][j] == '.') {
				dp[i][j] = dp[i-1][j] + dp[i][j-1] % mod;
			}
		}
	}

	cout<<dp[H-1][W-1]%mod<<endl;
	return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

int main(){
    
    string S;cin>>S;
    vector<string> T1={"KIHBR"},T2={"AKIHBR","KIHABR","KIHBAR","KIHBRA"},T3={"AKIHABR","AKIHBAR","AKIHBRA","KIHABAR","KIHABRA","KIHBARA"},T4={"AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA"},T5={"AKIHABARA"};
    int N=S.size();
    if(N==5){
        bool check=true;
        for(int i=0;i<N;i++){
            if(S[i]!=T1[0][i]) check=false;
        }
        if(check) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }else if(N==6){
        bool check;
        for(int j=0;j<4;j++){
            check=true;
        for(int i=0;i<N;i++){
            if(S[i]!=T2[j][i]) check=false;
        }
            if(check) break;
        }
        if(check) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }else if(N==7){
        bool check;
        for(int j=0;j<6;j++){
            check=true;
            for(int i=0;i<N;i++){
                if(S[i]!=T3[j][i]) check=false;
            }
            if(check) break;
        }
        if(check) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }else if(N==8){
        bool check;
        for(int j=0;j<4;j++){
            check=true;
            for(int i=0;i<N;i++){
                if(S[i]!=T4[j][i]) check=false;
            }
            if(check) break;
        }
        if(check) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }else if(N==9){
        bool check=true;
            for(int i=0;i<N;i++){
                if(S[i]!=T5[0][i]) check=false;
            }
        if(check) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }else cout<<"NO"<<endl;
}


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

#define ll long long

using namespace std;

int a[100500];

int dp[100500];

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if(a[i] <= a[i - 1])
        {
            dp[i] = dp[i - 1] + 1;
        } else
            {
                dp[i] = 0;
            }
    }
    int res = -1;
    for(int i = 1; i <= n; i++)
    {
        res = max(res, dp[i]);
    }
    cout << res;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
public class Main {
	Scanner sc;
	PrintWriter pw;
	public static void main(String... args) {
		Main m = new Main();
		m.solve();
		m.close();
	}
	public Main() {
		sc = new Scanner(System.in);
		pw = new PrintWriter(System.out);
	}
	private void close() {
		pw.flush();
		pw.close();
	}
	private void solve() {
		StringBuilder buf = new StringBuilder();
		char[] cr = sc.nextLine().toCharArray();
		for(int i = cr.length - 1; i > -1; i--)
			buf.append(cr[i]);
		pw.println(buf.toString());
	}
}

Measured memory_bytes: 12000
#include <stdio.h>

int isprime(int n){
	for(int i=2;i*i<=n;i++){
		if(n%i==0) return 0;
	}
	return 1;
}

int main(){
	int n,i;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=n;i>=5;i--){
			if(isprime(i)==1&&isprime(i-2)==1){
				printf("%d %d\n",i-2,i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1028
#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 MAX_N = 10;
double x[MAX_N],y[MAX_N];

double dist(int j, int i)
{
	double ans;
	ans = sqrt((x[j]-x[i]) * (x[j]-x[i]) + (y[j]-y[i]) * (y[j]-y[i]));
	return ans;
}

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		cin >> x[i] >> y[i];
	}

	int k = 1;
	for (int i = 1; i <= N-1; ++i)
	{
		k *= i;
	}
	k *= 2;
	//cout << k << endl;

	double ans = 0;

	rep(j,N)
	{
		for (int i = j+1; i < N; ++i)
		{
			//cout << x[j] << " " << y[j] << " " << x[i] << " " << y[i] << endl;
			//cout << j << " " << i << " " << dist(j,i) << endl;
			ans += dist(j,i) * k;
		}
	}

	int l = k / 2 * N;

	cout << setprecision(10) << ans / l << endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int o = n % 1000;
  if(o == 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << 1000 - o << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long LL;

const int N = 8100, M = 210, p = 998244353, G = 3, invG = (p + 1) / 3;

int A[N << 2], B[N << 2], fac[N], inv[N], rev[N << 2], f[N][M], n, m;

int add(int x, int y) { return x + y >= p ? x + y - p : x + y; }
int sub(int x, int y) { return x - y < 0 ? x - y + p : x - y; }
int inc(int &x, int y) { return x = add(x, y); }
int del(int &x, int y) { return x = sub(x, y); }
int mul(int x, int y) { return 1LL * x * y % p; }

int ksm(int x, int y) {
	int res = 1;
	for (; y; y >>= 1, x = mul(x, x)) if (y & 1) res = mul(res, x);
	return res;
}

void init(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; ++ i) fac[i] = mul(fac[i - 1], i);
	inv[n] = ksm(fac[n], p - 2);
	for (int i = n - 1; ~i; -- i) inv[i] = mul(inv[i + 1], i + 1); 
}

int C(int n, int m) { return m > n ? 0 : mul(fac[n], mul(inv[m], inv[n - m])); }

void reverse(int *A, int limit) {
	for (int i = 1; i < limit; ++ i) rev[i] = (rev[i >> 1] >> 1) | (i & 1 ? limit >> 1 : 0);
	for (int i = 1; i < limit; ++ i) if (i < rev[i]) std::swap(A[i], A[rev[i]]);
}

void NTT(int *A, int limit, int opt) {
	reverse(A, limit);
	for (int mid = 1; mid < limit; mid <<= 1) {
		int len = mid << 1;
		int w = ksm(opt == 1 ? G : invG, (p - 1) / len);
		for (int i = 0; i < limit; i += len) {
			int W = 1;
			for (int j = i; j < i + mid; ++ j, W = (LL)W * (LL)w % p) {
				int x = A[j], y = (LL)A[j + mid] * (LL)W % p;
				A[j] = add(x, y); A[j + mid] = sub(x, y);
			}
		}
	}
	if (opt == 1) return;
	int inv = ksm(limit, p - 2);
	for (int i = 0; i < limit; ++ i) A[i] = ((LL)A[i] * (LL)inv) % p;
}

void MUL(int *a, int n, int *b, int m) {
	int len = n + m, limit = 1;
	while (limit <= len) limit <<= 1;
	NTT(a, limit, 1), NTT(b, limit, 1);
	for (int i = 0; i < limit; ++ i) a[i] = ((LL)a[i] * (LL)b[i]) % p;
	NTT(a, limit, -1);
}

void Get(int j) {
	memset(A, 0, sizeof(A)), memset(B, 0, sizeof(B));
	for (int i = 1; i <= n; ++ i) A[i] = inv[i + 2];
	for (int i = 0; i <= n; ++ i) B[i] = mul(inv[i], f[i][j - 1]);
	for (int i = 0; i <= n; ++ i) inc(f[i][j], mul(f[i][j - 1], add(i + 1, C(i, 2))));
	MUL(A, n + 1, B, n + 1);
	for (int i = 1; i <= n; ++ i) inc(f[i][j], mul(A[i], fac[i + 2]));
}

signed main() {
	std::cin >> n >> m;
	init(N - 1), f[0][0] = 1;
	for (int i = 1; i <= m; ++ i) Get(i);
	int ans = 0;
	for (int i = 0; i <= n; ++ i) inc(ans, mul(C(n, i), f[i][m]));
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 7168
# coding=utf-8
import sys

n, q = map(int, sys.stdin.readline().split())
queue = []
total_time = 0
finished_loop = 0

for i in range(n):
    name, time = input().split()
    queue.append([name, int(time)])

while queue:
    n -= finished_loop
    finished_loop = 0
    for i in range(n):
        poped = queue.pop(0)
        name = poped[0]
        time = poped[1]
        if time > q:
            queue.append([name, time - q])
            total_time += q
        else:
            total_time += time
            print(name, total_time)
            finished_loop += 1

Measured memory_bytes: 15780
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int N ;
  cin >> N ;
  if(N % 111 == 0)
    cout << N << endl;
  else
    cout << N - N%111 +111 << endl;
}

Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

const LL MX = 1000000000000000000ll;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    LL n;
    cin >> n;
    if( n % 2 == 1 ) cout << 0 << endl;
    else {
        LL tm = 10;
        LL cnt = 0;
        while( tm <= n && tm != MX ) {
            cnt += n / tm;
            tm *= 5;

        }
        cout << cnt + (n / tm) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder_C
{
    class Program
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Select(c => c == '1').ToArray();
            int cnt = 0;
            for (int i = 0; i < input.Length - 1; i++)
            {
                if (input[i] == input[i + 1])
                {
                    input[i + 1] = !input[i + 1];
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13388
C = [list(map(int,input().split())) for i in range(3)]

a = [1,0,0]
b = [0,0,0]
b[0] = C[0][0] - 1
b[1] = C[0][1] - 1
b[2] = C[0][2] - 1
a[1] = C[1][0] - b[0]
a[2] = C[2][0] - b[0]

D = [[0,0,0] for i in range(3)]
for i in range(3):
    for j in range(3):
        D[i][j] = a[i]+b[j]

        
if C == D:
    print("Yes")
else:
    print("No")




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

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


	ll n, a, b;
	cin >> n >> a >> b;
	ll max = b * (n-1) + a;
	ll min = a * (n-1) + b;
	if(max - min + 1 > 0) cout << max - min + 1 << "\n";
	else if(max - min + 1 == 0) cout << "1" << "\n";
	else cout << "0" << "\n";
	
	return 0; 
}

Measured memory_bytes: 256
n = list(input())
n.insert(0, '0')

ans = 0
for i in range(len(n)-1, -1, -1):
    if n[i] == '0':
        pass
    elif int(n[i]) <= 4:
        ans += int(n[i])
    elif int(n[i]) == 5 and int(n[i-1]) <= 4:
        ans += int(n[i])
    else:
        ans += 10 - int(n[i])
        n[i-1] = str(int(n[i-1]) + 1)

print(ans)



Measured memory_bytes: 66412
#include "bits/stdc++.h"
using namespace std;
#define int long long
#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--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 123450
#endif

int N,M,Q;
int A[SIZE];
multiset<int> S;

void solve() {
    cin>>N;
    REP(i,N)cin>>A[i];
    
    RREP(i,N) {
        int j = A[i];
        auto it = S.upper_bound(j);
        if (it != S.end()) {
            S.erase(it);
        }
        S.insert(j);
    }
    
    cout << S.size() << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define cbrt cbrtl
using namespace std;

int main()
{
	double a,b,t;
	cin>>a>>b>>t;
	t+=0.5;
	ll x=t/a;
	cout<<x*b;
	return 0;
}

Measured memory_bytes: 384
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
let xk=readInts()
let k=xk[0]
let x=xk[1]
for i in (x-k+1)...(x+k-1){
  print(i,terminator:" ")
}

Measured memory_bytes: 8228
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;




int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A,A+N);
    int ans=0;
    

    int temp_num=1;
    
    for(int i=1; i<=N; i++){
        if(i==N || A[i]!=A[i-1]){
            ans+=temp_num%2;
            temp_num=1;
        }else{
            temp_num++;
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 640
import sys 
input = sys.stdin.readline
N, Q = list(map(int,input().split()))

from collections import defaultdict
tree = defaultdict(set)

for n in range(N-1):
  a,b = list(map(int,input().split()))
  tree[a] |= {b}
  tree[b] |= {a}

weight = defaultdict(int)
for q in range(Q):
  p,x = list(map(int,input().split()))
  weight[p] += x

score = dict()


Q = [1 for i in range(N)]
determined = set()
next_ptr = 1
for i in range(N):
  q = Q[i]
  for node in tree[q]:
    if node not in determined: 
      Q[next_ptr] = node
      weight[node] += weight[q]
      next_ptr += 1
  determined |= {q}
for i in range(1,N+1):
  print(weight[i],end=" ")
    


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

int main(){
  
  string S, T;
  cin >> S >> T;
  int i, j, Ns = S.size(), Nt = T.size();
  
  for(i = Ns - Nt; i >= 0; i--){
    
    bool flag = true;
    for(j = 0; j < Nt; j++){
      if(S[i + j] != T[j] && S[i + j] != '?'){
        flag = false;
        break;
      }
    }
    
    if(flag){
      for(j = 0; j < Nt; j++){
        S[i + j] = T[j];
      }

      for(j = 0; j < Ns; j++){
        if(S[j] == '?'){
          cout << 'a';
        }else{
          cout << S[j];
        }
      }
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main(){

   long n,a,b;
   cin >> n >> a >> b;
   long s=n/(a+b);
   long t=n%(a+b);

   if(t>=a){
      cout << a*s+a << endl;
   }

   if(t<a){
      cout << a*s+t << endl;
   }

}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int x, a, b;
    cin >> x >> a >> b;
    cout << (x - a) % b << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
   class Program
    {
        static void Main(string[] args)
        {
            String[] arr = new string[2];

            String str = Console.ReadLine();
            arr = str.Split(' ');
            int a = int.Parse(arr[0]);
            int b = int.Parse(arr[1]);


            if(a > b)
            {
                Console.WriteLine("a > b");
            }
            else if(a < b)
            {
                Console.WriteLine("a < b");

            }
            else
            {
                Console.WriteLine("a == b");
            }
        }   // end main 
    }   // end class


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

struct UF{
   vector<int> par;
   vector<int> sz;
   UF(){}
   UF(int n){
       par.resize(n);
       sz.resize(n, 1);
       rep(i, 0, n) par[i] = i;
   }
   int find(int x){
       if(x == par[x]) return x;
       return par[x] = find(par[x]);
   }
   void unite(int x, int y){
       x = find(x); y = find(y);
       if(x == y) return;
       if(sz[x] < sz[y]) swap(x, y);
       sz[x] += sz[y];
       par[y] = x;
   }
   bool same(int x, int y){
       return find(x) == find(y);
   }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    UF uf(m);
    vector<int> d(m);
    rep(i, 0, n){
        int k;
        cin >> k;
        vector<int> l(k);
        rep(j, 0, k){
            cin >> l[j]; l[j]--;
            d[l[j]]++;
        }
        rep(j, 1, k){
            uf.unite(l[j - 1], l[j]);
        }
    }
    bool f = true;
    int root = -1;
    rep(i, 0, m){
        // cout << uf.find(i) << endl;
        if(root == -1){
            if(d[i] != 0) root = uf.find(i);
        }else{
            if(d[i] != 0 && uf.same(root, i) == false) f = false;
        }
    }
    cout << (f ? "YES" : "NO") << endl;
}

Measured memory_bytes: 2560
//   PIGMEISTER™   //

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

#define ll long long
#define ull unsigned long long
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (ll)1000000007
//#define mod (ll)998244353
#define MAX 100005

int main()
{
    jaldi;
    
    long double r;
    cin >> r;
    long double pi = 3.141592653589793;
    cout << fixed << setprecision(10) << (long double)2*pi*r;
    
    return 0;
}


Measured memory_bytes: 3800
#include <stdio.h>

int main(){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if(op == '?')break;
        if(op == '+')printf("%d\n", a + b);
        else if(op == '-')printf("%d\n", a - b);
        else if(op == '*')printf("%d\n", a * b);
        else if(op == '/')printf("%d\n", a / b);
    }
}


Measured memory_bytes: 2052
'use strict'

function main(s) {

  const str1 = s.split('\n')[0].split('').sort().join('');
  const str2 = s.split('\n')[1].split('').sort().reverse().join('');

  const ans = (str1 < str2) ? 'Yes' : 'No';
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include<stdio.h>

int main(void)
{
	int height[15];
	int i=0,j=0,temp;

	for(i=0;i<15;i++){
		height[i]=0;
	}
	
	for(i=0;i<10;i++){
			scanf("%d",&height[i]);
	}

	for(i=0;i<10;i++){
		for(j=0;j<10;j++){				//ツ選ツ妥ーツ古ーツ環キツ法
			if(height[j]<height[j+1]){
				temp=height[j];
				height[j]=height[j+1];
				height[j+1]=temp;
			}
		}
	}
	
	for(i=0;i<3;i++){
		printf("%d\n",height[i]);
	}
	
	return 0;
}

Measured memory_bytes: 0
from collections import deque

N = int(input())

INF = 100001
G = [[] for i in range(N)]
dist1, dist2 = [INF for j in range(N)], [INF for k in range(N)]


def bfs(s, d):
    check, q = [0 for i in range(N)], deque()
    check[s], d[s] = 1, 0
    q.append(s)

    while len(q) != 0:
        u = q.popleft()
        for i in G[u]:
            if check[i] == 0:
                check[i], d[i] = 1, d[u] + 1
                q.append(i)
        check[u] = 2


def main():
    for i in range(N-1):
        a, b = map(int, input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)

    bfs(0, dist1)
    bfs(N-1, dist2)

    cnt_f = 0
    for i in range(N):
        if dist1[i] <= dist2[i]:
            cnt_f += 1

    if N // 2 < cnt_f:
        print("Fennec")
    else:
        print("Snuke")


if __name__ == '__main__':
    main()


Measured memory_bytes: 30124
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    string s;
    cin >> s;
    vi rl, ans(s.size());
    //rl.push_back(0);
    rep(i, 0, s.size() - 1)
    {
        if (s[i] == 'R' && s[i + 1] == 'L')
            rl.push_back(i);
    }
    rl.push_back(s.size());
    int sp = 0;
    rep(i, 0, s.size())
    {
        if (s[i] == 'R')
        {
            ans[(rl[sp] - i) % 2 + rl[sp]]++;
        }
        else
        {
            ans[(i - rl[sp - 1]) % 2 + rl[sp - 1]]++;
        }
        if (i == rl[sp])
            sp++;
    }
    rep(i, 0, s.size())
    {
        (i != s.size() - 1) ? (cout << ans[i] << " ") : (cout << ans[i] << endl);
    }
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std; 
using ll=long long;
#define endl "\n"
#define F(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define f first
#define s second
#define pll pair<ll,ll>
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()

void solve(){
 
    ll a,b;
    cin>>a>>b;
    if((a+b)%2){
        cout<<"IMPOSSIBLE";
    }
    else{
        cout<<(a+b)/2;
    }

    
    

}
signed main(){
    fast;
     
    solve();
 
    return 0;
}


Measured memory_bytes: 256
n=int(input())
listb = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    if i == 0:
        ans += listb[0]
    elif i == n-1:
        ans += listb[-1]
    else:
        ans += min(listb[i],listb[i-1])
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,b,x;
	int i,j;
	
	cin>>a>>b>>x;
	
	int mn=10000007;
	for(i=0;i<=x/1000+1;i++){
		for(j=0;j<=x/500+1;j++){
			if(1000*i+500*j>=x && mn>a*i+b*j){
				mn=a*i+b*j;
			}
		}
	}

	cout<<mn<<endl;
	return 0;
	
}	




Measured memory_bytes: 3088
def f():
    return [0,0]

from collections import defaultdict
import math
mod=1000000007
n=int(input())
dic=defaultdict(f)
x=[]
zerozero,azero,bzero=0,0,0
two=[1]

for i in range(n):
    two.append(two[-1]*2%mod)

for _ in range(n):
        
    a,b=map(int,input().split())
    if a==0 and b==0: zerozero+=1
    elif a==0: azero+=1
    elif b==0: bzero+=1
    else:
        k=math.gcd(a,b)
        a//=k;b//=k
        if a<0: a*=-1;b*=-1
        if a*b>0: dic[(a,b)][0]+=1
        else: dic[(-b,a)][1]+=1

for (a,b) in dic:
    x.append(dic[(a,b)])
x.append([azero,bzero])
ans=1
for [p,q] in x:
    ans*=(two[p]+two[q]-1)
    ans%=mod

print((ans-1+zerozero)%mod)

Measured memory_bytes: 145076
use std::io;
use std::str::FromStr;

fn input_int_tuple() -> (i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (a, b) = input_int_tuple();
    if a <= 9 && b <= 9 {
        println!("{}", a * b);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

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
import sys
input = sys.stdin.readline

# A - Table Tennis Training
def move_left():
	return A + (B-A-1)//2


def move_right():
	return  N - B + 1 + (B-A-1)//2	


N, A, B = map(int, input().split())

if (B-A) % 2 == 0:
	print(int((B-A)//2))
else:
	l = move_left()
	r = move_right()
	print(min(l, r))

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
char s[4];

  scanf("%s",s);
  for(int i=0;i<3;i++){
	for(int j=i+1;j<4;j++){
      
	if(j==i+1){
      //printf("%d %d\n",i,j);
			if(s[i]==s[j]){printf("Bad");
                   return 0;
                  }
    }
    }
  }
printf("Good");
  return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]

xy.sort()

xy2 = [(x-y,x+y) for x,y in xy]

xd, yd = zip(*xy2)

dx = max(xd) - min(xd)
dy = max(yd) - min(yd)
print(max(dx,dy))





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

int main(){
    int N;
    int count = 0;
    string S, sub;
    cin >> N;
    cin >> S;
    for(int i=0; i<N-2; i++){
        sub = S.substr(i, 3);
        if(sub == "ABC"){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <math.h>
using namespace std;

int main() {
	int n, P[200000], ans = 0, a1, a2 = 1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> P[i];
	}
	a2 = P[0];

	for (int i = 0; i < n; i++) {
		if (P[i] <= a2) {
			a2 = P[i];
			ans++;
		}
	
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1024