akhauriyash/Code-Regression huggingface dataset:
n=int(input())
s=[""]*n
dic={}
for i in range(n):
  a=input()
  if (a in dic):
    dic[a]+=1
  else:
    dic[a]=1
#dic=sorted(dic.items(), key=lambda x:x[1], reverse=True)
v_max=max(dic.values())
keys=[k for k,v in dic.items() if v==v_max ]
keys=sorted(keys)
for i in range(len(keys)):
  print(keys[i])



Measured memory_bytes: 97496
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a, b, i, k, n = 1;
    cin >> a >> b >> k;
    for(i=min(a,b); i>0; i--){
        if(a%i == 0 && b%i == 0){
            if(n == k){
                cout << i;
            }
            n++;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    int N,K;
    cin >> N >> K;
    vector<int> fruits(N);

    // output
    for(int i=0; i<N; i++) cin >> fruits[i];
    sort(fruits.begin(),fruits.end());
    int ans=0;
    for(int i=0; i<K; i++) ans+=fruits[i];
    cout <<ans << endl;

    return 0;
}


Measured memory_bytes: 3572
N = int(input())
A = list(map(int, input().split()))
A.sort()
M = A[-1]
b = [True] * (M + 1)

count = 0
for i, a in enumerate(A):
  if not b[a]:
    continue
  for j in range(a, M+1, a):
    b[j] = False
  if i < N-1 and A[i+1] == a:
    continue
  count += 1

print(count)


Measured memory_bytes: 32356
N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z=N-x-y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z==Y:
            print(x,y,z)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
b1,b2,dic,ans = [],[],{},0
for i, j in enumerate(a):
    b1.append(j-i)
    b2.append(-j-i)
for i, j in zip(b1, b2):
    if i in dic:
        ans += dic[i]
    if j in dic:
        dic[j] += 1
    else:
        dic[j] = 1
print(ans)

Measured memory_bytes: 50856
# include <stdio.h>
int main ()
{
	int a,b,c,p=1,d=1;
	scanf ("%d%d%d",&a,&b,&c);
	int i=0;
     if (a%2!=0||b%2!=0||c%2!=0)
        printf ("%d\n",0);
    else
    {
        for (i=1;i<=100;++i)
	    {
	     int d=0,e=0,f=0;
	  	 d=a/2;
	  	 e=b/2;
	  	 f=c/2;
	  	 a=e+f;
	  	 b=d+f;
	  	 c=d+e;
	  	 if (a%2!=0||b%2!=0||c%2!=0)
	  	    {
	  	    	p=0;
	  	    	break;
		    }
	    }
	  if (p==0)
	  printf ("%d\n",i);
	else
	  printf ("%d\n",-1);	
	}
    	  
}

Measured memory_bytes: 128
p = input().split()
q = input().split()
r = input().split()

list_a = p + q + r
list_b = list(map(int, list_a))
#print(list_b)
list_b.sort()


if list_b.count(1)>=3:
    print("NO")
elif list_b.count(2)>=3:
    print("NO")
elif list_b.count(3)>=3:
    print("NO")
elif list_b.count(4)>=3:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3064
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        if(b % n == 0) ans = n + b;
        else ans = b - n;
        System.out.println(ans);
    }
}
 

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll a, b;

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
































Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		int[] abc = {111,222,333,444,555,666,777,888,999};
		
		for(int i : abc) {
			if(n <= i) {
				System.out.println(i);
				return;
			}
		}
		
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = 998244353;
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    ll ret = 1 % mod;
    a %= mod;
    while(b) {
        if(b & 1LL) ret = ret * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}

vector<ll> inv, FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    inv.resize(MAX + 1);
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

int main(){
    ll n;
    cin >> n;
    ll ans = 0,a = 10;
    while (n >= a) {
        ans += n / a;
        a *= 5;
    }
    pf(n % 2 == 1? 0:ans);
    return 0;
}


Measured memory_bytes: 256
'''
・基本的には素直なシミュレーションを行う
・ループ分のシミュレーションを省略することでTLEを回避
・Kは「残りのワープ数」と考える

K回のワープ中にループが含まれる場合、
1. 素直なシミュレーションを行う。このとき、Kを減算していく。
2. ループを検出したら、Kからループ長をできるだけ多く引くことで、計算を省略する。
3. 残りのステップ数、再度シミュレーションを行う
という手順で答えを求められる。
なお、ループが含まれない場合も1のみで答えを求められる。
'''

def main():
    N, K = map(int, input().split())
    A = [a-1 for a in map(int, input().split())]    # 0-indexed に変換
    B = [None]*N    # 何ステップ目に到達したかを記録。Noneなら未到達を表す
    now = 0         # 現在地
    step = 0        # ステップ数
    B[now] = 0      # 開始地点は、0ステップ目に到達済みとする
    while K:
        now = A[now]    # 現在地を更新 
        step += 1
        K -= 1
        if B[now] is not None:  # ループを検出したら...
            K %= (step - B[now])      # Kからループ長さを引けるだけ引く
        else:
            B[now] = step  # 到達したステップ数を記録
    print(now+1)    # 1-indexed に再変換

main()



Measured memory_bytes: 32324
#include <iostream>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <string>
#define ll long double
#include <vector>
using std::vector;

using namespace std;


int main()
{
    int n, p;
    cin >> n;
    int a = 0;

    for(int i = 1; i <=n ; i++){
        cin >> p;
        if(p != i){
            a++;
        }
    }
    if(a==0 || a == 2){
        cout << "YES" << endl;
    }else
        cout << "NO" << endl;
    return 0;
}


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

int main() {
    long long x, i, ans=1;
    long long div=pow(10, 9)+7;
    cin >> x;
    for (i=1; i <= x; i++) {
        ans =i*ans%div;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int n, m;
int a[102];
int cnt = 0;
int sum = 0;

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] * 4 * m >= sum) {
      cnt++;
    }
  }
  printf("%s\n", cnt >= m ? "Yes" : "No");
}


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

int main () {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    printf("%lf\n", sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)));
    return 0;
}

Measured memory_bytes: 1232
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n
# a, b
# s = input()

N = int(input())
X = list(map(int, input().split()))

ans = int(1e18)
for i in range(1, 101):
    now = 0
    for x in X:
        now += (x-i)*(x-i)
    ans = min(ans, now)
print(ans)


Measured memory_bytes: 38768
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    public static int d;
    public static int[] last;
    public static long[] c;
    public static long[][] s;

    static void solve(InputReader in, PrintWriter out){
        int d = in.ni();
        c = in.nl(26);
        last = new int[26];
        s = new long[d][26];
        for (int i = 0; i < d; i++) s[i] = in.nl(26);

        int[] answer  = in.ni(d);
        long score = 0;
        for (int i = 0; i < d; i++) {
            score = score(score, answer[i], i+1);
            out.println(score);
        }

    }
    static long score(long score, int t, int day){  // 1-indexedで受け取る
        last[t-1] = day;
        score += s[day-1][t-1];
        for (int i = 0; i < 26; i++) {
            score -= c[i]*(day-last[i]);
        }
        return  score;
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 34616
#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> ;
const int INF = 1e9;
const int MOD = 1000000007;

int main(){
    int a,b,c,d;
    cin >> a >>b >> c >> d;
    if((a+d-1)/d >= (c+b-1)/b) cout << "Yes" <<endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int MaxN = 100000 + 5;

int N, K;
int A[MaxN];
int dp[MaxN];

void init() {
  scanf("%d %d", &N, &K);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
}

inline int myAbs(int x) {
  if (x < 0) return -x;
  else return x;
}

void solve() {
  memset(dp, 0x7F, sizeof dp);
  dp[1] = 0;
  for (int i = 2; i <= N; ++i) {
    for (int j = max(1, i - K); j < i; ++j)
      dp[i] = min(dp[i], dp[j] + myAbs(A[j] - A[i]));
  }
  cout << dp[N] << endl;
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll cnt[5], ok;
int h[MAXN];
bool mark[MAXN];
vector<pii> G[MAXN];

void dfs(int node){
	mark[node]=1;
	cnt[h[node]]++;
	cnt[3]++;
	cnt[4]+=G[node].size();
	for (pii p:G[node]){
		if (!mark[p.first]){
			h[p.first]=(h[node] + p.second)%3;
			dfs(p.first);
		}
		else if ((h[node]-h[p.first]+p.second)%3) ok=0;
	}
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m;
	while (m--){
		cin>>u>>v;
		G[u].pb({v, 1});
		G[v].pb({u, 2});
	}
	for (int i=1; i<=n; i++) if (!mark[i]){
		ok=1;
		memset(cnt, 0, sizeof(cnt));
		dfs(i);
		if (!ok){
			ans+=cnt[3]*cnt[3];
			continue ;
		}
		if (!(cnt[0]*cnt[1]*cnt[2])) ans+=cnt[4]/2;
		else ans+=cnt[0]*cnt[1] + cnt[1]*cnt[2] + cnt[2]*cnt[0];
	}
	cout<<ans<<'\n';
	
	return 0;
}
/*
2 2
1 1
1 2

*/

Measured memory_bytes: 12416
#include<iostream>
#include<cmath>

using namespace std;

int main(){
    long long n;
    cin>>n;
    string ans;
    long long m=0,t=1;
    int cnt;

    for(float i=1.0;i<=11.0;i++){
        t*=26;
        if(m+t>=n){
            cnt=i;
            t/=26;
            break;
        }else{
            m+=t;
        }
    }
    n-=m+1;
    for(int i=0;i<cnt;i++){
        if(n==0){
            ans+='a';
            continue;
        }
        ans+=(char)((n/t)+97);
        n=n%t;
        t/=26;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3612
N, M = gets.split.map(&:to_i)
a = []
M.times do |i|
  a << gets.to_i
  if a.size > 1
    if a[i] - a[i - 1] == 1
      p 0
      exit
    end
  end
end

dp = Array.new(N + 2, 0)
mod = 10 ** 9 + 7

dp[0] = 1
j = 0
N.times do |i|
  j += 1 if j < M && a[j] <= i
  unless j < M && a[j] == i + 1
    dp[i + 1] += dp[i]
    dp[i + 1] %= mod
  end
  unless j < M && a[j] == i + 2
    dp[i + 2] += dp[i]
    dp[i + 2] %= mod
  end
end

p dp[N]

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

int main() {
    int k, a, b; cin >> k >> a >> b;
    for(int i=a; i<=b; i++) {
        if(i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,k,n) for(int i = k; i < n; i++)  
#define repp(i,k,n) for(int i = k; i <= n; i++) 
#define per(i,k,n) for(int i = k; i >= n; i--)

#define int long long
#define all(a) a.begin(),a.end()       

#define pb push_back
typedef long long ll; 
typedef pair<int, int> ii;
typedef pair<int,ii > iii; 
typedef vector<ii> vii;
typedef vector<char> vchar;
typedef vector<int> vi;
#define ff first
#define ss second

#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));

#define INF 1000000000
//#define mod 998244353
#define mod 1000000007
#define endl "\n"


   //=\/=\/=\/=\/=\/=\/=\/=\/=\/=\        Jai Hind Dosto        /=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\
  //=\/=\/=\/=\                    ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿                             /=\/=\/=\/=\\
 //=\/=\/=\/=\                                                                               /=\/=\/=\/=\\
//=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\



int modPow(int a, int b);           

                
void solve(){
    int n ;
    cin >> n ;
    int a[n];
    int sum =0;
    map<int, int> xx;
    rep(i,0,n)cin >> a[i], sum^=a[i];
    rep(i,0,n){
        int temp = sum;
        temp^=a[i];
        cout << temp << " ";
    }
}






signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed;
    //cout <<setprecision(6);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
 //   int test=1; cin >> test; while(test--)
    solve();
}

int modPow(int a, int b){
    if(b==0)return 1;
    if(b%2==0){
        int x = a*a;
        x%=mod;
        return modPow(x,b/2);
    }
    return (a*modPow(a,b-1))%mod;
}




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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(long long N, long long M, std::vector<long long> A) {
  ll tot = 0;
  rep(i,N) tot += A[i];
  sort(all(A), [](ll x, ll y){ return x>y; });
  rep(i,M){
    if(4*M*A[i]<tot) { cout << "No" << endl; return; }
  }
  cout << "Yes" << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  long long M;
  std::cin >> M;
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
  }
  solve(N, M, std::move(A));
  return 0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

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

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

void Main()
{
  ll m, n;
  cin >> n >> m;
  if (m >= n)
    fin("unsafe");
  else
    fin("safe");
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 3672
n = input()
aaa = list(map(int, input().split(' ')))
ans = 0
hoge = 0
old = aaa[0]
for i in range(1, int(n)):
    if aaa[i] <= old:
        hoge += 1
    else:
        hoge = 0
    ans = max(ans, hoge)
    old = aaa[i]

print(ans)

Measured memory_bytes: 63708
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
#include <map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

using namespace std;
 
class DisjointSet {
    public:
        vector<int> rank, p;
        DisjointSet() {}
        DisjointSet(int n){
            rank.resize(n, 0);
            p.resize(n, 0);
            for(int i = 0; i < n; i++){
                makeSet(i);
            }
        }
        
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }
        
        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }
        
        int findSet(int x){
            if(x != p[x]){
                p[x] = findSet(p[x]);
            }
            
            return p[x];
        }
        
        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }
        
        void link(int x, int y){
            if(rank[x] > rank[y]){
                p[y] = x;
            } else {
                p[x] = y;
                if(rank[x] == rank[y]){
                    rank[y]++;
                }
            }
        }
};
 
int main(void){
    // Your code here!
    int N, K, L, p, q, r, s;
    cin >> N >> K >> L;
    
    DisjointSet ds1 = DisjointSet(N);
    DisjointSet ds2 = DisjointSet(N);
    
    for(int i = 0; i < K; i++){
        cin >> p >> q;
        p--;
        q--;
        if(!ds1.same(p, q)) ds1.unite(p, q);
    }
    
    for(int i = 0; i < L; i++){
        cin >> r >> s;
        r--;
        s--;
        if(!ds2.same(r, s)) ds2.unite(r, s);
    }
    
    vector<pair<int, int> > com(N);
    map<pair<int, int>, int> S;
    for(int i = 0; i < N; i++){
        com[i].first = ds1.findSet(i);
        com[i].second = ds2.findSet(i);
        S[com[i]] += 1;
    }
    
    for(int i = 0; i < N; i++){
        cout << S[com[i]] << " ";
    }
    cout << endl;
    
    return 0;
    
    
}

Measured memory_bytes: 16640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n;cin>>n;
	vector<int> a(n),b(n),c(n);
	rep(i,0,n-1)cin>>a[i];
	rep(i,0,n-1)cin>>b[i];
	rep(i,0,n-1)cin>>c[i];
	sort(all(a));
	sort(all(b));
	sort(all(c));
	ll ans = 0;
	rep(i,0,n-1){
		ans += (lower_bound(all(a), b[i]) - a.begin()) * (c.end() - upper_bound(all(c), b[i]));
	}
	cout<<ans<<endl;
}


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

int main()
{
    int a;
    cin >> a;
    int i=3;
    while (i<=a){
        string s;
        ostringstream oss;
        oss << i << flush;
        s= oss.str();
        if (i%3 ==0){
            cout << " "<< i;
        }else if(s.find("3") !=string::npos){
            cout << " " << i;
        }
        i++;
    }cout << endl;
    
    return 0;
}


Measured memory_bytes: 3172
import java.io.*;
import java.util.*;

public class Main {
  static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
  static final int N = 100001;
  static int[] prefix;
  
	public static void main (String[] args) throws IOException {    
    boolean[] isPrime = new boolean[N]; // or use bitset for space
    isPrime[2] = true;
    for (int i = 3; i < N; i += 2) isPrime[i] = true;
    for (int i = 3; i < N; i += 2) {
      if (isPrime[i]) {
        if ((long) (i) * i >= N) continue;
        for (int j=i*i; j<N; j+=i) isPrime[j] = false;
      }
    }
    
    prefix = new int[N];
    int count = 0;
    
    for(int i = 1; i < N; i++) {
      int M = (i+1)/2;
      if(isPrime[i] && isPrime[M]) {
        count++;
      }
      prefix[i] = count;
    }
    
    int Q = Integer.parseInt(br.readLine());
    
    for(int i = 0; i < Q; i++) {
      String[] line = br.readLine().split(" ");
      int L = Integer.parseInt(line[0]);
      int R = Integer.parseInt(line[1]);
      
      int ans = prefix[R] - prefix[L-1];
      bw.write(ans + "\n");
    }
    
    bw.close();
	}
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
ll x;

void print(ll x){
  if(x>26)print((x-1)/26);
  putchar((x-1)%26+'a');
}

void solve() {
  cin>>x;
  print(x);
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

Measured memory_bytes: 3636
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();
        sc.close();
        int d = c;
        c = b;
        b = a;
        a = d;
        System.out.println(a + " " + b + " " + c);
    }
}

Measured memory_bytes: 39232
abc = list(map(int, input().split(" ")))

count = 0
while True:
	abc.sort()

	if abc[0] == abc[1] == abc[2]:
		break
	elif abc[0] == abc[1]:
		abc[0] += 1
		abc[1] += 1	
		count += 1
	else:
		abc[0] += 2
		count += 1

print(count)

Measured memory_bytes: 3064
N = int(input())
t,a = map(int,input().split())
h_s = list(map(int,input().split()))
h = 100000000
ans = 0
for i in range(N):
    if abs(a-(t - (h_s[i]*0.006))) < h:
        h = abs(a-(t - (h_s[i]*0.006)))
        ans = i
print(ans + 1)

Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

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

    int A[] = new int[N];
    int B[] = new int[N];
    ArrayList<sumList> List = new ArrayList<sumList>();

    for (int i = 0; i < N; i++) {
      A[i] = Integer.parseInt(sc.next());
      B[i] = Integer.parseInt(sc.next());
      List.add(new sumList(i, A[i] + B[i]));
    }

    List.sort((a, b) -> b.sum - a.sum);

    long ans = 0;
    for (int i = 0; i < N; i++) {
      if (i % 2 == 0) {
        ans += A[List.get(i).index];
      } else {
        ans -= B[List.get(i).index];
      }
    }

    System.out.println(ans);
  }

}

class sumList {
  int index;
  int sum;

  public sumList(int i, int s) {
    index = i;
    sum = s;
  }

}

Measured memory_bytes: 64696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 30
int b[N], a[N];
int main(){
	int n, m, c; scanf("%d%d%d", &n, &m, &c);
	REP(i, m) scanf("%d", b+i);
	int ans = 0;
	REP(i, n){
		REP(j, m) scanf("%d", a+j);
		int sm=c;
		REP(j, m) sm+=a[j]*b[j];
		if(sm>0) ans++;
	}
	printf("%d\n", ans);
}


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

int main(void) {
  string s, t;
  cin >> s >> t;

  string result;
  if (t.substr(0, t.size() - 1) == s) {
    result = "Yes";
  } else {
    result = "No";
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3636
/* Filename: ARC083C.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while(input.hasNext()){
			int A = input.nextInt();
			int B = input.nextInt();
			int C = input.nextInt();
			int D = input.nextInt();
			int E = input.nextInt();
			int F = input.nextInt();
			int maxA = F / (A * 100);
			int maxB = F / (B * 100);
			int maxC = F / C;
			int maxD = F / D;
			
			int sugarWater = 100;
			int sugar = 0;
			double maxDensity = 0;
			for(int a = 0; a <= maxA; ++a){
				for(int b = 0; b <= maxB; ++b){
					for(int c = 0; c <= maxC; ++c){
						for(int d = 0; d <= maxD; ++d){
							int currentWater = (a * A + b * B) * 100;
							int currentSugar = c * C + d * D;
							
							if( currentWater + currentSugar <= F){
								if(currentWater / 100 * E >= currentSugar){
									double currentDensity = currentSugar == 0 ? 0 : currentSugar / (double) (currentSugar + currentWater);
									
									if(currentDensity >= maxDensity){
										sugar = currentSugar;
										sugarWater = sugar + currentWater;
										maxDensity = currentDensity;
									}
								}
							}
						}
					}
				}
			}
			
			System.out.println(sugarWater + " " + sugar);
		}
	}

}


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

int main(){
  int n,m,sum,c;
  double th;
  cin >> n >> m ;

  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  sum=0;
  for(int i=0; i<n; i++) sum +=a[i];
  th = ((double) sum)/ (4*m);

  c=0;
  for(int i=0; i<n; i++){
    if(a[i] >= th) c++;    
  }
  if(c >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
E = [set() for i in range(4)]
for i in range(3):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  E[a].add(b)
  E[b].add(a)
ok = True
for i in range(4):
  if len(E[i]) >= 3:
    ok = False
    break
if ok:
  print("YES")
else:
  print("NO")


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

void solve(){


	int n ;
	cin>>n ;
	set<int> st ;
	rep(i,n){
		int x ;
		cin>>x ;
		if(st.find(x)==st.end()){
			st.insert(x) ;
		}
		else{
			st.erase(x) ;
		}
	}

	cout<<st.size() ;

}


int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 8148
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[100];
    cin>>a;
  if(a[0]=='S')
    cout<<"Cloudy"<<endl;
  else if(a[0]=='C')
    cout<<"Rainy"<<endl;
  else if(a[0]=='R')
    cout<<"Sunny"<<endl;
  return(0);
}

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

int main(){
  string a,b;cin>>a>>b;
  int n=a.size(),m=b.size();
  if(n!=m){
    cout<<(n>m?"GREATER":"LESS");
    return 0;
  }
  for(int i=0;i<n;i++){
    if(a.at(i)==b.at(i)){
      if(i!=n-1) continue;
      else break;
    }
    cout<<(a>b?"GREATER":"LESS");
    return 0;
  }
  cout<<"EQUAL";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int sum=0,a;
char x[1001];

while(1){
for(a=0;a<=1000;a++)x[a]='0';
scanf("%s",x);
if(x[0]=='0')break;
for(a=0;a<=1000;a++)if(x[a]>='0'&&x[a]<='9')sum+=x[a]-'0';
printf("%d\n",sum);
sum=0;
}
return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,m;
int s,g;
int x[500],y[500],d[500],c[500];
int rod[35][35];
int roc[35][35];
double dp[35][35][35];//from,to,speed

struct road{
	int from;
	int to;
	int speed;
	double cost;
	road(int _from,int _to,int _speed,double _cost){
		from=_from;
		to=_to;
		speed=_speed;
		cost=_cost;
	};
	bool operator<(const road& r1)const{
		return cost>r1.cost;
	}
};

int main(){
	while(1){
		priority_queue<road> PP;
		while(PP.size())PP.pop();
		cin>>n>>m;
		if(n==0&&m==0)break;
		cin>>s>>g;
		REP(i,35)
			REP(j,35){
				rod[i][j]=-1;
				roc[i][j]=-1;
			}
		REP(i,35){
			REP(j,35){
				REP(k,35){
					dp[i][j][k]=-1;
				}
			}
		}
		for(int i=0;i<m;i++){
			cin>>x[i]>>y[i]>>d[i]>>c[i];
			rod[x[i]][y[i]]=d[i];
			rod[y[i]][x[i]]=d[i];
			roc[x[i]][y[i]]=c[i];
			roc[y[i]][x[i]]=c[i];
			if(x[i]==s){
				PP.push(road(s,y[i],1,(double)d[i]));
				dp[s][y[i]][1]=d[i];
			}
			if(y[i]==s){
				PP.push(road(s,x[i],1,(double)d[i]));
				dp[s][x[i]][1]=d[i];
			}
		}
		double ret=INF;
		while(PP.size()){
			road r1=PP.top();PP.pop();
			if(r1.to==g&&r1.speed==1){
				ret=min(ret,r1.cost);
				continue;
			}
			for(int i=1;i<=n;i++){
				if(i!=r1.from&&rod[r1.to][i]!=-1){
					for(int j=-1;j<=1;j++){
						int tx=r1.speed+j;
						if(tx>0&&tx<=roc[r1.to][i]){
							double ncost=r1.cost+(double)rod[r1.to][i]/tx;
							if(dp[r1.to][i][tx]==-1||dp[r1.to][i][tx]>ncost){
								dp[r1.to][i][tx]=ncost;
								PP.push(road(r1.to,i,tx,ncost));
							}
						}
					}
				}
			}
		}
		if(ret==INF)printf("unreachable\n");
		else printf("%.10f\n",ret);
	}
	return 0;
}
								


Measured memory_bytes: 3732
#include<stdio.h>

int main(void)
{
	char S[6] = {'\0'};
    
    do{
    	scanf("%s",S);
    }while(S[6]!=0&&S[5]==0);
    
    if(S[2]==S[3] &&S[4]==S[5] )
        	printf("Yes");  
    else
    	printf("No");
    
    return 0;
}

Measured memory_bytes: 1688
n,m=map(int,input().split())
edge=[list(map(int,input().split())) for i in range(m)]
node=[-float('inf') for i in range(n+1)]
node[1]=0
inf=False
for i in range(2*n+1):
  change=False
  for s,e,c in edge:
    if node[e]<node[s]+c:
      node[e]=node[s]+c
      if e==n:
        change=True
  if i>=n and change:
    inf=True
if inf:
  print('inf')
else:
  print(node[-1])

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
template <typename T>void read(T &x){
	x = 0; int f(1); char c = getchar();
	for(;!isdigit(c);c = getchar()) if(c == '-') f = -1;
	for(;isdigit(c);c = getchar()) x = x*10+c-'0';
	x *= f;
}
int n,k,vis[105];
int main(){
	read(n); read(k);
	for(int i(1);i <= k;++i){
		int tmp; read(tmp);
		for(int j(1);j <= tmp;++j){
			int x; read(x);
			vis[x] = 1;
		}
	} int ans = 0;
	for(int i(1);i <= n;++i)
		if(!vis[i])	++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>  
using namespace std;  
const int maxn = 9e4+1000;  
int len;  
char s[maxn];  
int cntA[maxn];  
vector<char> ans;  
struct SAM{  
    int last,cnt,nxt[maxn*2][26],fa[maxn*2],l[maxn*2];  
    int rk[maxn*2],num[maxn*2];  
    void init(){  
        last = cnt=1;  
        memset(nxt[1],0,sizeof nxt[1]);  
        fa[1]=l[1] =0;  
    }  
    void add(int c){  
        int p = last;  
        int np = ++cnt;  
        last = np;  
        l[np] =l[p]+1;  
        while (p&&!nxt[p][c]){  
            nxt[p][c] = np;  
            p = fa[p];  
        }  
        if (!p){  
            fa[np] =1;  
        }else{  
            int q = nxt[p][c];  
            if (l[q]==l[p]+1){  
                fa[np] =q;  
            }else{  
                int nq = ++cnt;  
                memcpy(nxt[nq],nxt[q],sizeof nxt[q]);  
                fa[nq] =fa[q];  
                l[nq] = l[p]+1;  
                fa[np] =fa[q] =nq;  
                while (nxt[p][c]==q){  
                    nxt[p][c]=nq;  
                    p = fa[p];  
                }  
            }  
        }  
    }  
    void build (){  
        for (int i=1;i<=cnt;i++){  
            cntA[l[i]]++;  
        }  
        for (int i=1;i<maxn-5;i++){  
            cntA[i]+=cntA[i-1];  
        }  
        for (int i=1;i<=cnt;i++){  
            rk[cntA[l[i]]--] =i;  
        }  
        for (int i=1;i<=cnt;i++){  
            num[i]=1;  
        }  
        for (int i=cnt;i>=1;i--){  
            int x = rk[i];  
            for (int i=0;i<26;i++){  
                if (nxt[x][i]){  
                    num[x]+=num[nxt[x][i]];  
                }  
            }  
        }  
        num[0]=0;  
    }  
    inline void print(){  
        for (char t:ans){  
            printf("%c",t);  
        }  
        printf("\n");  
    }  
    void query(int K){  
        ans.clear();  
        int now=1;  
        int sum=0;  
        while (true){  
//          cout<<now<<' '<<sum<<endl;   
            if (sum==K){  
                print();  
                return ;  
            }  
            int c=0;  
            int last =0;  
            while (sum<K){  
                sum+=num[nxt[now][c]];  
                c++;  
                assert(c<27);  
            }  
            c--;  
            sum-=num[nxt[now][c]];  
            now = nxt[now][c];  
            ans.push_back('a'+c);  
            sum++;  
        }  
    }  
}sam;  
int main(){  
    int Q=1;  
    scanf("%s",s);  
    sam.init();  
    int le = strlen(s);  
    for (int i=0;i<le;i++){  
        sam.add(s[i]-'a');  
    }  
    sam.build();  
    while (Q--){  
        int x;  
        scanf("%d",&x);  
        sam.query(x);  
    }  
    return 0;  
}  

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int h,w;
    cin >> h >> w;
    vector<vector<char>> s(h,vector<char>(w));
    int a_count =0;
    rep(i,h) {
        rep(j,w) {
        cin >> s.at(i).at(j);
        if (s[i][j] == '#') a_count++;
        }
    }
    int ans =0;
    const vector<int> dx = {1,0,-1,0};
    const vector<int> dy = {0,1,0,-1};
    rep(i,h) {
        rep(j,w) {
            if (s.at(i).at(j) == '.') continue;
            else {
                rep(d,4) {
                    int ni = i + dy[d];
                    int nj = j + dx[d];
                    if ( ni < 0 or ni >= h) continue;
                    if ( nj < 0 or nj >= w) continue;
                    if (s[ni][nj] == '#') {
                        ans++;
                        break;
                    }
                }
            }
        }
    }
   
    if (a_count == ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()

c = 0
for i in range(n):
    if s[i] == 'R' and 0 <= i + 1 < n and s[i+1] == 'R': c += 1
    if s[i] == 'L' and 0 <= i - 1 < n and s[i-1] == 'L': c += 1
ans = min(n - 1, c + 2 * k)
print(ans)

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	unordered_map<string,int>mp;
	while(n--)
	{
		string s;
		cin>>s;
		mp[s]++;
	}
	
	cout<<mp.size();
     
     
	return 0;
}

Measured memory_bytes: 17796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
typedef vector<ll> vll;
typedef pair<ll, ll> Pll;

int main() {
    vector<string> C(2);
    for (int i = 0; i < 2; ++i) {
        cin >> C[i];
    }
    vector<string> D(C);
    reverse(C[1].begin(), C[1].end());
    reverse(C[0].begin(), C[0].end());
    swap(C[0], C[1]);
    if (D[0] == C[0] && D[1] == C[1]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 998244353;
//cout << setprecision(20) << 

#define SEG_LEN (200010) 

ll seg[SEG_LEN * 2] = {0};

// one point
ll get(ll ind){
    ind += SEG_LEN;
    ll sum = 0;
    sum += seg[ind];
    while(true){
        ind /= 2;
        if(ind == 0)break;
        sum += seg[ind];
        sum %= MOD;
    }
    return sum;
}

// range
void add(ll l, ll r, ll x){
    l += SEG_LEN;
    r += SEG_LEN;
    while(l < r){
        if(l % 2 == 1){
            seg[l] %= MOD;
            seg[l] += x;
            seg[l] %= MOD;
            l++;
        }
        l /= 2;
        if(r % 2 == 1){
            seg[r-1] %= MOD;
            seg[r-1] += x;
            seg[r-1] %= MOD;
            r--;
        }
        r /= 2;
    }
}

int main() {
    ll n, k; cin >> n >> k;
    vector<pair<ll, ll>> v(k);
    for (int i = 0; i < k; ++i) {
        ll l, r; cin >> l >> r;
        v[i] = make_pair(l, r);
    }

    add(1, 2, 1);
    for (int i = 1; i < n; ++i) {
        for (auto p: v) {
          ll x = get(i);
          ll l = p.first + i;
          if (l > n) continue;
          ll r = min(n + 1, p.second + i + 1);
          if (r - l <= 0) continue;
          add(l, r, x);
        }
    }
    // for (int i = 1; i <= n; ++i) {
    //   cout << get(i) << " ";
    // }
    // cout << endl;
    cout << get(n) << endl;
}

Measured memory_bytes: 6744
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin>>s;
  int mx = 0;
  FOR (i,1,4) {
    string r(i, 'R');
    if (s.find(r) != string::npos) {
      mx = i;
    }
  }
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 3656
a, b, c = map(int, input().split())

ans = 0
while a % 2 != 1 and b % 2 != 1 and c % 2 != 1:
    if a == (b+c)//2 and b == (a+c)//2 and c == (a+b)//2:
        ans = -1
        break
    a, b, c = (b+c)//2, (a+c)//2, (a+b)//2
    ans += 1

print(ans)

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

int main(){
  int n,count;
  cin>>n;
  count=0;
  vector<int> v;
  vector<int> w;
  for(int i=0; i<n; i++){
    int tmp;
    cin>>tmp;
    v.push_back(tmp);
  }
  w=v;
  sort(w.begin(),w.end());
  for(int i=0; i<n; i++){
    if(v[i]!=w[i]){
      count++;
    }
  }
  if(count==2||count==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256