akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

    int n;
    string s;
    cin >> n >> s;

    int res = -1;
    
    rep(i, s.length()-1){
        string l = s.substr(0, i+1);
        string r = s.substr(i+1, s.length());

        int l_bucket[26] = {0};
        int r_bucket[26] = {0};

        rep(j, l.length()) ++l_bucket[l[j] - 'a'];
        rep(j, r.length()) ++r_bucket[r[j] - 'a'];
        
        int cnt = 0;
        rep(j, 26){
            if(l_bucket[j]>0 && r_bucket[j]>0) ++cnt;
        }
        res = max(res, cnt);
    }
    cout << res << endl;

}

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

int flag[maxn],prime[maxn],kk=1,t=0,ans[maxn],a[8]={0};

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

inline void writ(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) writ(x/10);
	putchar(x%10+'0');
}
inline void write(int x){writ(x);putchar('\n');}

int main()
{
	prime[1]=2;flag[2]=1;
	int n=read();int pd=0;
	for (int i=3;i<=55555;++i)
	{
		flag[i]=1;
		for (int j=1;j<=kk;++j)
		{
			if (prime[j]>sqrt(i)) break;
			if (i%prime[j]==0) {flag[i]=0;break;}
		}
		if (flag[i]) prime[++kk]=i;
	}
	for (int i=1;i<=55555;++i)
		if (prime[i]%5==1) ans[++t]=prime[i];
	for (int i=1;i<n;++i) printf("%d ",ans[i]);
	printf("%d\n",ans[n]);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int len = s.length();
	for(int i = 0; i < len; i += 2){
		if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
			printf("No\n");
			return 0;
		}
	}
	for(int i = 1; i < len; i += 2){
		if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=1e6+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=998244353;
const double eps=1e-8;
const double pi=acos(-1);
LL n,m;
int f[N];
int dp[N];
int w[N],v[N];
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    r(m); r(n);
    FOR(i,1,n){
        r(v[i]);
        r(w[i]);
    }
    FOR(i,1,m+1e4) dp[i]=2e9;
    dp[0]=0;
    FOR(i,1,n){
        for(int j=v[i];j<=m+1e4;j++){
//            cout<<i<<' '<<j<<' '<<dp[j-v[i]]+w[i]<<endl;
            dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
        }
    }
    int ans=2e9;
    FOR(i,m,m+1e4){
        ans=min(dp[i],ans);
    }
    cout<<ans<<endl;
    return 0;
}



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

using namespace std;

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

    set<int> numbers;
    auto ans = "YES";
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (numbers.find(a) != numbers.end())
        {
            ans = "NO";
        }
        numbers.insert(a);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10240
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        string s=cin.next();
        string ans="Rainy";
        if(s=="Rainy")ans="Sunny";
        else if(s=="Sunny")ans="Cloudy";
      Console.WriteLine(ans);
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}


Measured memory_bytes: 11092
import copy
n = int(input())
w = list(map(int, input().split()))

ans = sum(w)
for i in range(n-1):
    ans_base = abs(ans)
    ans_base = copy.deepcopy(ans)
    ans -= w[i]*2
    if abs(ans) >= ans_base:
        break

print(min(abs(ans), abs(ans_base)))

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
const double EPS = 1e-8;
#define Scan(a) int a;scanf("%d", &a);
#define ScanS(a) char a[500];scanf("%s", a);
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1LL)
#define bitset(a,b)      ( a |= (1LL << b))
#define bitunset(a,b)    (a &= ~(1LL << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
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 gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
pii Dir[8] = {
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};


pii operator+(pii obj, pii obj2) {
	return MP(obj.first + obj2.first, obj.second + obj2.second);
}
pii operator-(pii obj, pii obj2) {
	return MP(obj.first - obj2.first, obj.second - obj2.second);
}

int main() {
	int n;
	cin >> n;
	int ans = 1;
	
	REP(i, n) {
		ans *= 3;
	}
	int min = 1;
	REP(i, n) {
		int c;
		cin >> c;
		if (c % 2 == 0) min *= 2;
	}

	cout << ans - min;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
signed main()
{
	int H = gi(), A = gi(), sum = 0, x ;
	rep( i, 1, A ) {
		x = gi(), sum += x ; 
	}
	if( sum >= H ) puts("Yes") ;
	else puts("No") ;
	return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	register int x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')	ch=getchar();
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x;
}
const int N=1e3+5;
const int M=2e5+5;
struct each{
	int x,y;
}a[M];
vector<int>b[N];
int n,m,cnt[N],suf[N][N],pre[N][N],vis[N],vi[N][N];
void dfs(int x){
	int si=b[x].size(); vis[x]=1;
	for(int i=0;i<si;i++)
		if(!vis[b[x][i]])	dfs(b[x][i]);
}
void dfs(int x,int k,int ty){
	int si=b[x].size();	vis[x]=1;
	if(ty){
		for(int i=si-1;~i;i--){
			int v=b[x][i];
			if(!vis[v]) pre[k][v]=x,dfs(v,k,ty);
		}
	}
	else{
		for(int i=0;i<si;i++){
			int v=b[x][i];
			if(!vis[v]) suf[k][v]=x,dfs(v,k,ty);
		}
	}
}
bool check(int x){
	int v=b[x][cnt[x]++];
	if(pre[x][v]==suf[x][v]&&pre[x][v]==x&&suf[x][v]==x)	return false;
	else	return true;
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		a[i].x=read(),a[i].y=read();
		b[a[i].x].push_back(a[i].y);
	}
	for(int i=1;i<=n;i++){
		dfs(i);
		for(int j=1;j<=n;j++)
			vi[i][j]=vis[j],vis[j]=0;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)	vis[j]=0;
		dfs(i,i,0);
		for(int j=1;j<=n;j++)	vis[j]=0;
		dfs(i,i,1);
	}
	for(int i=1;i<=m;i++){
		if(vi[a[i].y][a[i].x]^check(a[i].x))	puts("diff");
		else	puts("same");
	}
	return 0;
}


Measured memory_bytes: 16256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
void solve()
{
   ll n;
   cin>>n;
   
   vector<ll> arr(n);
   
   for(ll i=0;i<n;i++)
   cin>>arr[i];
   
   vector<ll> ans(n);
   
   for(ll i=0;i<n;i++)
   ans[arr[i]-1]=i+1;
   
   for(ll i=0;i<n;i++)
   cout<<ans[i]<<" ";
   
  
   return;
}

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

Measured memory_bytes: 2432
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
z = -1
res = float("inf")
for r in range(N):
  if a[r] < 0:
    z = r
    continue
  if r < K - 1: continue
  x = r - z
  y = a[z - (K - x) + 1]
  if K == x: y = 0
  t = min(abs(a[r]), abs(y))
  if r - z >= K: t = 0
  res = min(res, abs(a[r]) + abs(y) + t)
for l in range(N):
  if z - l + 1 == K:
    res = min(res, abs(a[l]))
    break
print(res)

Measured memory_bytes: 58608
inf = float("inf") # 正の無限大

def chmin(dp, n, a):
	b = (dp[n]>a)
	if b: dp[n]=a
	return b

def chmax(dp, n, a):
	b = (dp[n]<a)
	if b: dp[n]=a
	return b


N=int(input())
H=[0]+list(map(int, input().split()))
#print(N,H)

dp=[inf]*(N+1)
dp[1]=0
dp[2]=abs(H[2]-H[1])

for i in range(3,N+1):
  a = dp[i-2]+abs(H[i]-H[i-2])
  b = dp[i-1]+abs(H[i]-H[i-1])
  #dp[i]= a if (a<=b) else b
  chmin(dp, i, a)
  chmin(dp, i, b)

print( dp[N] )



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


void solve(long long N, std::vector<std::string> S){
    map<string, int> mp;
    for(auto s : S){
        mp[s] += 1;
    }
    int maxval = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        //cout << itr->first << " " << itr->second << endl;
        maxval = max(maxval, itr->second);
    }
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        if(itr->second == maxval) cout << itr->first << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


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

int main() {
	
	int n;
	cin >> n;
	std::vector<int> arr(n) ;
	std::vector<int> dp(n) ;
	
	for(int i = 0; i < n; ++i)
	cin >> arr[i];
	    
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for(int i = 2; i < n; ++i)
	{
	    dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2]+ abs(arr[i] - arr[i-2]));
	}
	cout << dp[n-1];
	
	return 0;
}


Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
using pp=pair<ll,pair<ll,ll>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  int D,T,S;
  cin>>D>>T>>S;
  if(D<=T*S){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;

int main(){
   string s;
   cin >> s;
   string ans = "";
   for(int i = 0; i< s.size(); i++){
        if(s[i] !=  'B'){
            ans += s[i];
        }
        else{
            ans = ans.substr(0, ans.size() - 1);
        }
   }
   cout << ans <<endl;
}

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

using ll = long long;

constexpr int MAX_N = 2000;
int A[MAX_N];

#define USE_MOD
#ifdef USE_MOD
constexpr int MOD = 1e9 + 7;
#endif

template<typename T>
inline T mod(T a) {
#ifdef USE_MOD
  a %= MOD;
#endif
  return a;
}

int main() {
  ll N, K;
  cin >> N >> K;
  K %= MOD;
  for (int i{}; i < N; ++i)
    cin >> A[i];

  ll ans0{};
  for (int i{}; i < N - 1; ++i) {
    for (int j{i + 1}; j < N; ++j) {
      if (A[i] > A[j % N]) {
        ++ans0;
      }
    }
  }
  ans0 %= MOD;

  ll ans1{};
  for (int i{}; i < N; ++i) {
    for (int j{}; j < N; ++j) {
      if (A[i] > A[j]) {
        ++ans1;
      }
    }
  }
  ans1 %= MOD;

  cout << (ans0 * K + ans1 * mod(K * (K - 1) / 2)) % MOD << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for(int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  p.at(N - 1) /= 2;
  int S = 0;
  for(int i = 0; i < N; i++) {
    S += p.at(i);
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}}; ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}

/*!* [intutil] *!*/
/*+* 整数演算いろいろ *+*/
i64 divceil(i64 a, i64 b) {
    return a / b + (a > 0 && a % b ? 1 : 0);
}
i64 logceil(i64 a, i64 b) {
    for(i64 i = 0, x = 1; a >= 2; x *= a, i++) if(x <= b) return i; return 0;
}
i64 gcd(i64 a, i64 b) {
    for (i64 c; a;) c = a, a = b % a, b = c; return b;
}
i64 lcm(i64 a, i64 b) {
    return (a / gcd(a, b) * b);
}
i64 pmod(i64 x, i64 m) {
    return (x % m + m) % m;
}
i64 sign(i64 x) {
    return x > 0 ? 1 : x < 0 ? -1 : 0;
}

int main() {
    const int INF = 1e8;
    int N;
    cin >> N;
    vector<i64> A(N);
    for(int i = 0; i < N; i++) {
        int p;
        cin >> p;
        A[p - 1] = i;
    }
    int S = 1, ans = N - 1;
    for(int i = 0; i < N - 1; i++) {
        if(sign(A[i + 1] - A[i]) > 0) S++;
        else {
            ans = min(ans, N - S);
            S = 1;
        }
    }
    ans = min(ans, N - S);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4844
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n, k;
    cin >> n >> k;
    ll a[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a+n, greater<ll>());
    ll sum = 0;
    for(ll i = 0; i < k; i++)
        sum += a[i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  n <- readLn
  as <- map readInt . BC.words <$> BC.getLine
  print $ solve n as

solve :: Int -> [Int] -> Int
solve n as = sum $ map count as

count :: Int -> Int
count a = length . takeWhile (\x -> x `mod` 2 == 0) $ iterate (\x -> x `div` 2) a

readInt :: BC.ByteString -> Int
readInt = fst . fromJust . BC.readInt


Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define vi vector<int>
#define vpii vector<pii>
#define vp3i vector<p3i>
#define vpll vector<pll>
#define vp3l vector<p3l>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() ((rand() << 14)+rand())
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

int n, a[200005], b[200005];
ll c, ans, lo=(1LL<<60);
int main(){
    cin >> n;
    fox(l, n){
        scanf("%i%i", a+l, b+l);
        if (a[l]<b[l]){
            c+=b[l]-a[l];
        } else if (a[l]>b[l]){
            lo=min(lo, 1LL*b[l]);
        }
            ans+=a[l];
    }
    if (c==0){
        cout << 0;
        return 0;
    }
    cout << ans-lo;
    return 0;
}


Measured memory_bytes: 384
#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,k;
  cin >> n >> k;
  vector<int>d(n);
  rep(i,k) {
    int m;
    cin >> m;
    rep(j,m){
      int a;
      cin >> a;
      d[a-1] = 1;
    }  
  }
  int ans = 0;
  rep(i,n) if (d[i]==0) ans++;
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
	int n,nn,sn=0;
	cin >> n;
	nn=n;

	while(1){
		sn=sn+nn%10;
		if(nn/10==0){break;}
		nn=nn/10;
	}
	
	if(n%sn==0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;
use std::collections::BinaryHeap;

const INF: usize = 1e9 as usize;

#[derive(Copy, Clone, Eq, PartialEq)]
struct State {
    v: usize,
    cost: usize,
}

impl Ord for State {
    fn cmp(&self, other: &State) -> std::cmp::Ordering {
        other.cost.cmp(&self.cost)
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &State) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}

fn main() {
    input!(k: usize);

    let mut dist = vec![INF; k];
    let mut heap = BinaryHeap::new();
    for i in 1..10 {
        let remain = i % k;
        if dist[remain] > i {
            dist[remain] = i;
            heap.push(State { v: remain, cost: i });
        }
    }

    while let Some(State { v, cost }) = heap.pop() {
        if v == 0 {
            println!("{}", cost);
            return;
        }
        for i in 0..10 {
            let remain = (v * 10 + i) % k;
            if dist[remain] > dist[v] + i {
                dist[remain] = dist[v] + i;
                heap.push(State {
                    v: remain,
                    cost: dist[remain],
                });
            }
        }
    }
}


Measured memory_bytes: 10996
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            while(sc.hasNext()) {
                int w = sc.nextInt();
                List<Integer> list = new ArrayList<Integer>();
                for(int i=0; i<10; i++) {
                    if((w & 1<<i) != 0) list.add(1<<i);
                }
                boolean jud = true;
                for(int i:list) {
                    if(!jud) System.out.print(" ");
                    jud = false;
                    System.out.print(i);
                }
                System.out.println();
            }
        }
    }
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	ll n;
	cin >> n;
	cout << n * (n - 1) / 2;
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

int main(){
    using namespace std;
    constexpr unsigned long C = 26;
    unsigned long D;
    cin >> D;
    vector<unsigned long> c(C);
    for(auto&& i : c)cin >> i;
    vector v(D, vector<unsigned long>(C));
    for(auto&& i : v)for(auto&& j : i)cin >> j;

    vector last(C, vector<unsigned long>{0});
    vector<unsigned long> ans(D);

    for(unsigned long i{0}; i < D; ++i){
        unsigned long mx{0}, mxi{0};
        for(unsigned long j{0}; j < C; ++j){
            unsigned long tmp{v[i][j] + c[j] * (i + 1 - last[j].back())};
            if(tmp > mx){
                mx = tmp;
                mxi = j;
            }
        }
        ans[i] = mxi;
        last[mxi].push_back(i + 1);
    }
    for(auto&& i : last)i.push_back(D + 1);

    mt19937_64 mt{random_device{}()};
    uniform_int_distribution<unsigned long> uid(1, D);

    auto start = chrono::system_clock::now();

    do for(unsigned long iter{0}; iter < 131072; ++iter){
        unsigned long d{uid(mt)};
        auto f = ans[d - 1];
        unsigned long tmp{c[f] * (*upper_bound(begin(last[f]), end(last[f]), d) - d) * (d - *prev(lower_bound(begin(last[f]), end(last[f]), d))) + v[d - 1][f]};
        unsigned long mx{tmp}, mxi{0};
        for(unsigned long i{0}; i < C; ++i){
            unsigned long temp{c[i] * (*upper_bound(begin(last[i]), end(last[i]), d) - d) * (d - *prev(lower_bound(begin(last[i]), end(last[i]), d))) + v[d - 1][i]};
            if(temp > mx){
                mx = temp;
                mxi = i;
            }
        }
        if(mx > tmp){
            last[f].erase(lower_bound(begin(last[f]), end(last[f]), d));
            last[mxi].insert(upper_bound(begin(last[mxi]), end(last[mxi]), d), d);
            ans[d - 1] = mxi;
        }
    } while(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count() < 1800);

    for(const auto& i : ans)cout << i + 1 << endl;

    return 0;
}

Measured memory_bytes: 3740
#include<iostream>
#include<string>
#include<cmath>
//#include<array>
#include<algorithm>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>

using namespace std;
using LLI = long long int;
LLI N;

//vector<int>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//vector<int>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//vector<int>dir_x2 = { 0,0,1,-1 };
//vector<int>dir_y2 = { 1,-1,0,0 };
//vector<char>alp = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI tmp, r;
//	if (x < y) {
//		tmp = x;
//		x = y;
//		y = tmp;
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x,LLI y) {
//	return x / gcd(x,y) * y;
//}

//long nCr(int n,int r) {
//	long ans = 1;
//	for (int i = n; i > n - r;i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1;i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

int main(void) {
	vector<int>vec;
	int a,k;
	for (int i = 0; i < 5;i++) {
		cin >> a;
		vec.push_back(a);
	}
	cin >> k;
	sort(vec.begin(), vec.end());
	if (vec[4] - vec[0] > k) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;
int H, W;
vector<string> field;
int main() {
	cin >> H >> W;
	cin.ignore();
	for (int i = 0; i < H; ++i) {
		string str; getline(cin, str);
		field.push_back(str);
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (field[i][j] == '.') {
				int cnt = 0;
				for (int n = -1; n <= 1; ++n) {
					for (int m = -1; m <= 1; ++m) {
						if (i + n < H&&i + n >= 0 && j + m < W&&j + m >= 0 && field[i + n][j + m] == '#') cnt++;
					}
				}
				cout << cnt;
			}
			else {
				cout << field[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		if(n == 1)
		{
			Console.WriteLine("Hello World");
			return;
		}
		var a = Console.ReadLine().ToInt();
		var b = Console.ReadLine().ToInt();
		Console.WriteLine(a+b);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


Measured memory_bytes: 13140
// D - Islands War
#include <bits/stdc++.h>
using namespace std;

int V[100000+1];

int main(){
	int N,M; cin>>N>>M;
	while(M--){
		int l,r; cin>>l>>r;
		V[r] = max(V[r], l);
	}

	// for(int r=0; r<=N; ++r){ cout<<r<<" "<<V[r]<<"\n";}///

	int ans = 0, R = 0;
	for(int r=1; r<=N; ++r){
		if(V[r]<1) continue;
		// cout<<V[r]<<"\n";//
		if(V[r] >= R){ R = r; ans++; }
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n=4;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9){
        cout<<"YES"<<endl;
        
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int M,D;
    cin >> M >> D;
    int cnt = 0;
    rep(i,1,M+1)rep(j,10,D+1){
        int a = j / 10, b = j % 10;
        if(a < 2 || b < 2)continue;
        if(a * b == i){
            cnt++;
            //cout << i << " " << j << endl;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  long long int max=0,dp[100001],ddp[1000001],n,w,i,j,yen,kg;
  for(i=0;i<=100000;i++){dp[i]=0;ddp[i]=0;}
  cin>>n>>w;
  for(i=0;i<n;i++)
  {
    cin>>kg>>yen;
    for(j=0;j<=w-kg;j++){if(dp[j]+yen>dp[j+kg]){ddp[j+kg]=dp[j]+yen;}}
    for(j=0;j<=w;j++){dp[j]=ddp[j];}
  }
  for(i=0;i<=w;i++){if(dp[i]>max){max=dp[i];}}
  cout<<max;
}

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

int main() {
    string str, ans = "";
    cin >> str;
    rep(i, str.length()) {
        if(str.at(i) == 'B' && ans.length() != 0) ans.pop_back();
        else if(str.at(i) == '0' || str.at(i) == '1') ans += str.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = gets.to_i
n.times do
 x = gets.chomp
 y = x.split("")
 z = y.map{|a| a.to_i}
 maxstr = z.sort.reverse
 minstr = z.sort
 max = maxstr.join.to_i
 min = minstr.join.to_i
 ans = (max - min) 
 puts ans
end


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

int main(){
  ll N,M;
  cin >>N>>M;
  ll a=pow(10,9)+7;
  vector<ll> dp(N+1,0);
  dp[1]=1;
  for(int i=0;i<=M;i++){
    int a;
    cin >>a;
    dp[a]=-1;
  }
  dp[0]=1;
  for(int i=2;i<=N;i++){
    if(dp[i]==-1){
      continue;
    }
    if(dp[i-1]!=-1){
      dp[i]+=dp[i-1];
    }
    if(dp[i-2]!=-1){
      dp[i]+=dp[i-2];
    }
    if(dp[i]>=a){
      dp[i]%=a;
    }
  }
  cout << dp[N] <<endl;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  for (int i = 0; i < (int)S.size(); i++) {
    cout << 'x';
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main()
{
   int n;
   cin >> n;
   vector<ll> a(3*n);
   rep(i,3*n) cin >> a[i];

   priority_queue<ll, vector<ll>,greater<ll>> left;
   priority_queue<ll> right;

   ll sum =0;
   rep(i,n) 
   {
      left.push(a[i]);
      sum += a[i];
   }
   vector<ll> x(n+1,0);
   for(int i = n;  i< 2*n ; i++)
   {
      x[i-n] = sum; 
      sum += a[i];
      left.push(a[i]);
      sum = sum - left.top(); left.pop();
   }
   x[n] = sum;
   sum = 0;
   for(int i = 3*n-1; i >= 2*n; i--)
   {
      right.push(a[i]);
      sum += a[i];
   }
   vector<ll> y(n+1,0);
   for(int i = 2*n-1; i >= n ; i--)
   {
      y[i+1-n] = sum; 
      sum += a[i];
      right.push(a[i]);
      sum = sum - right.top(); right.pop();
   }
   y[0] = sum;
   ll ans = -LINF;
   // rep(i,x.size()) cout << x[i] << " ";
   // cout << endl;
   // rep(i,y.size()) cout << y[i] << " ";
   // cout << endl;
    rep(i,n+1) ans = max(ans,x[i]-y[i]);
   cout << ans << endl;
}

Measured memory_bytes: 5876
#include <stdio.h>
#define FOR(i,L,R) for (int i = L; i < R; i++)
#define READ(n) int (n); scanf("%d",&(n))
#define getInt(a) scanf("%d", &a)

int main(){
    int cnt = 0;
    READ(n);
    int arr[n + 1];
    for (int i = 1; i <= n; i++)
        getInt(arr[i]);
    
    for (int i = 1; i <= n; i++){
        if (i != arr[i])
            cnt++;
    }
    if (cnt > 2)
        printf("NO\n");
    else printf("YES\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int a[200005];

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

  sort(a,a+n);
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      cout<<"NO"<<endl;
      return 0;
    }
  }

  cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 1024
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, k, s] <- getIntList
    let as | s < 10^9 = (replicate k s) ++ (replicate (n-k) (s+1))
           | s == 10^9 = (replicate k s) ++ (replicate (n-k) 1)
    putStrLn . unwords $ map show as

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

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

int main(){
  ll K;
  cin >> K;
  vector<ll> ans(50, 0);
  for(int i=0;i<50;i++)
    ans[i] = 49 - i;
  for(ll i = 0; i<50;i++){
    ans[i] += K/50;
    ans[i] += (K%50) > i;
  }
  cout << 50 << endl;
  for(int i=0;i<50;i++){
    cout << ans[i];
    if(i == 49)
      cout << endl;
    else
      cout << " ";
  }
  return 0;
}
/*
 49 48 47 ... 0 = 0
 50 48 47  .. 0 = 1
 50 49 48 0 .... 0 = 3
 50 49 48 47 ... 1 = 50
 51 49 48 47 ... 1 = 51
 51 50 48 47 ... 1 = 52
 51 50 49 47 ... 1
 */


Measured memory_bytes: 256
def solve():
    A,B,C=map(int,input().split())
    K=int(input())
    flag=False
    for i in range(0,K+1):
        for j in range(0,K-i+1):
            for k in range(0,K-i-j+1):
                if 2**i*A<2**j*B<2**k*C:
                    flag=True
                    break
    if flag:
        print("Yes")
    else:
        print("No")
if __name__=="__main__":
    solve()

Measured memory_bytes: 61832
// -*- coding:utf-8-unix -*-

use std::cmp::*;
use std::collections::*;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::vec;

const INF: i64 = 1223372036854775807;
const MEM_SIZE: usize = 202020;
const MOD: i64 = 1000000007;
use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn readii() -> (i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuu() -> (usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn solve() {
    let n: usize = read();
    let mut vv: Vec<Vec<u8>> = vec![vec![0; (2 * n) as usize]; (2 * n) as usize];
    for i in 0..n {
        let s: String = read();
        let mut v = s.as_bytes().to_vec();
        for j in 0..n {
            vv[i][j] = v[j];
            vv[i + n][j] = v[j];
            vv[i][j + n] = v[j];
            vv[i + n][j + n] = v[j];
        }
    }

    let mut cnt: usize = 0;
    for ix in 0..n {
        let mut flg = true;
        for i in 0..n {
            for j in 0..n {
                if (vv[i][ix + j] != vv[j][ix + i]) {
                    flg = false;
                }
            }
        }
        if flg {
            cnt += n;
        }
    }
    println!("{:?}", cnt);

    
    return;
}
fn main() {
    solve()
}


Measured memory_bytes: 2528
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define SET(A,VAL) memset(A, VAL, sizeof(A))
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int MAX = 1e6+8;
const int sz = 1e5+5;
void f_io(){
    IOS;
}
int32_t main(){
    f_io();
    int t = 1;
    //cin>>t;
    while(t--){
        int c; cin>>c;
        cout<<(c<1200?"ABC":"ARC");

    }
}

Measured memory_bytes: 256
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define all(a)      (a).begin(),(a).end()
#define si(x)       (int)((x).size())
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
#define se second 
#define endl        '\n'
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mem(a,x)          memset(a,x,sizeof(a))

// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"[";
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===


// const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846
void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}
void inp_mat(ll *arr,ll n,ll m)
{
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
        {
          ll x;cin>>x;
          *((arr+i*m) + j)=x;
        }
}
// syntax for inp_mat inp_mat((ll *)arr,n,m);
// int x2[]={+1,-1,+0,+0};
// int y2[]={+0,+0,+1,-1};
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGEc
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
    int t=1;
    // cin>>t;
    while(t--)
    {
      ll n;cin>>n;ll a[n],b[n],c[n];
      f(i,0,n)
      {
        cin>>a[i]>>b[i]>>c[i];
      }
      ll dp[n][3];
      dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];
      f(i,1,n)
      {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
      }
      cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
    }    
} 

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

using namespace std;

int main()
{
	// 入力
	int A, B;
	cin >> A >> B;
	
	// floatに一度変換
	float f = (B - 1) / float(A - 1);
	// 切り上げを行い、電源タップの個数を算出
	int answer = ceil(f);
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())

arr = list(map(int, input().split()))
ar2 = [0] * n

for i in range(n):
    x = i-arr[i]
    if x >= 0:
        ar2[x] += 1

total = 0
for i in range(n):
    x = i+arr[i]
    if x < n:
        total += ar2[x]

print(total)


Measured memory_bytes: 92876
h, w = map(int, input().split())

ls = []

ls += [['.']*(w+2)]
for _ in range(h):
    ls += [['.'] + list(input()) + ['.']]
ls += [['.']*(w+2)]

for i in range(1, h+1):
    for j in range(1, w+1):
        if ls[i][j] != '#':
            continue
        if ls[i][j-1] != '#' and ls[i-1][j] != '#' and ls[i+1][j] != '#' and ls[i][j+1] != '#':
            print('No')
            exit()

print('Yes')


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int main()
{
	int n, x, cnt = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		if (x % 2 == 1)
		{
			cnt++;
		}
	}

	if (cnt % 2 == 0 || cnt == 1 && n == 1)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int N, flag = 0;
    scanf("%d", &N);

    for(int i = 0; i * 4 <= N; i++){
        if((N - i * 4) % 7 == 0){
            flag = 1;
            break;
        }
    }

    printf(flag == 1 ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

int main(){
    ll a,b,c,k; cin >> a >> b >> c >> k;
    if(k<=a){
        cout << k << endl;
    }else if(a<k && k<=(a+b)){
        cout << a << endl;
    }else{
        cout << a-(k-(a+b)) << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a - 1, b - 1)
print(uf.group_count() - 1)

Measured memory_bytes: 75324
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		while (true) {
			String inputData = scn.next();
			if (inputData.equals("-")) {
				break;
			}
			//char[] inputDatas = inputData.toCharArray();
			int count = scn.nextInt();
			int shuffleCount;
			for (int i = 0; i < count; i++) {
				shuffleCount = scn.nextInt();
				inputData = inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount);
			}
			System.out.println(inputData);
			//String ChangedData = new String(inputDatas);
			//System.out.println(ChangedData);
		}
	}
}



Measured memory_bytes: 26308
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;



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

	string S;
	int N, K;

	cin >> N >> S >> K;

	REP(i, S.length())
	{
		if (S[i] != S[K - 1])
		{
			S[i] = '*';
		}
	}

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256