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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int N, M; 
	string s[1000], t[1000];

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

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

	int ans = 0;

	for (int i = 0;i < N;i++){
		int cnt = 0;
		for (int j = 0;j < N;j++){
			if(s[i] == s[j]) cnt++;
		}
		for (int j = 0;j < M;j++){
			if(s[i] == t[j]) cnt--;
		}

		ans = max(ans, cnt);
	}

	cout << ans << endl;

	return 0;

}


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

int main() {
  string s;
  cin >> s;
  int count = 0;
  if(s[0] == '1') ++count;
  if(s[1] == '1') ++count;
  if(s[2] == '1') ++count;
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
applyBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
applyBin op f g x = op (f x) $ g x
applyUni :: (a -> b -> c) -> (a -> b) -> a -> c
applyUni op f x = op x $ f x
applyTuple :: (a -> b, a -> c) -> a -> (b, c)
applyTuple (f,g) a = (f a, g a)
-- end of templete

rotate n = applyBin (++) (drop n) (take n)

list = [4,1,4,1,2,1,2,1]

f s = minimumBy (\x y -> comparing remain x y <> compare x y) $ flip map [0..7] $ \i -> rotate i list
  where
    remain = sum . zipWith ((max 0 .)  . (-)) s


main = map (unwords . map show . f . map read . words) . lines <$> getContents >>= mapM_ putStrLn

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

using namespace std;
const int MAX = 2000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    long long X,Y;
    cin>>X>>Y;
    if((X+Y)%3!=0){
        cout<<0<<endl;
    }else{
        COMinit();
        long long Z=X+Y;
        Z/=3;
        if(min(X,Y)==Z){
            cout<<1<<endl;
        }else{
            long long ZZ=Z*2;
            cout<<COM(Z,min(X,Y)-Z)<<endl;

        }

    }




}

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

using namespace std;

int main() {
  int N, K, ans = 0;
  cin >> N >> K;
  vector<int> V(N, 0);
  for (int i = 0; i < K; ++i) {
    int d;
    cin >> d;
    for (int j = 0; j < d; ++j) {
      int tmp;
      cin >> tmp;
      ++V[tmp - 1];
    }
  }
  for (int i: V) {
    if (i == 0) ++ans;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;


#define MAXN 810
typedef pair<int, int> pii;
int h, w, k;
char a[MAXN][MAXN];
int d[MAXN][MAXN];
int dx[4] = {1,  0, -1,  0};
int dy[4] = {0, -1,  0,  1};

int intceil(int a, int b) {
  return a/b + (a%b>0);
}

void bfs(int i, int j) {
  priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>> > pq;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      d[i][j] = 1e9;
    }
  }
  pq.push({0, {i, j}});
  d[i][j] = 0;
  while(!pq.empty()) {
    auto u = pq.top();
    int cost = u.first;
    i = u.second.first;
    j = u.second.second;
    pq.pop();
    for (int di = 0; di < 4; ++di) {
      int ni = i+dy[di];
      int nj = j+dx[di];
      if (ni<0 || ni>h-1 || nj<0 || nj>w-1) continue;
      if (a[ni][nj]=='#') continue;
      int nc = cost + 1;
      if (d[ni][nj] > nc) {
        d[ni][nj] = nc;
        pq.push({nc, {ni, nj}});
      }
    }
  }
}


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int I, J, ans=MAXN;
  cin >> h >> w >> k;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> a[i][j];
      if (a[i][j]=='S') {
        I = i;
        J = j;
      }
    }
  }
  bfs(I, J);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      //cout << d[i][j] << " ";
      if (d[i][j]<=k) ans = min(ans, intceil(min(min(i, h-1-i), min(j, w-1-j)), k)+1);
    }
    //cout << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll ans=1;
  REP(i,1,n+1) ans=(ans*i)%MAX;
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T = lint>
struct Edge {
	int to;
	T cost;
	Edge() {}
	Edge(int to, T cost = 1) : to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T>
vector<T> Dijkstra(vector<vector<Edge<T>>> &edges, int st) {

	int V = (int)edges.size();
	const T INF = numeric_limits<T>::max();
	vector<T> cost(V, INF);
	cost[st] = 0;

	priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> p_que;
	p_que.emplace(st, cost[st]);

	while (!p_que.empty()) {

		Edge<T> now(p_que.top().to, p_que.top().cost);
		p_que.pop();

		if (cost[now.to] < now.cost) continue;
		for (const Edge<T> &e : edges[now.to]) {
			T tmp_cost = now.cost + e.cost;
			if (cost[e.to] > tmp_cost) {
				cost[e.to] = tmp_cost;
				p_que.emplace(e.to, cost[e.to]);
			}
		}
	}

	return cost; // min cost to vertex idx from st
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	int u, v, len;
	vector<vector<Edge<int>>> edges(N);
	for (int i = 0; i < N - 1; i++) {
		cin >> u >> v >> len;
		u--, v--;
		edges[u].emplace_back(v, len);
		edges[v].emplace_back(u, len);
	}

	auto d = Dijkstra(edges, 0);
	for (const auto &e : d) cout << (e & 1) << "\n";

	return 0;
}

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

using namespace std;

int main(void){
    int n,m,lb,rb;
    vector<int> l,r;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> lb >> rb;
        l.push_back(lb);
        r.push_back(rb);
    }
    sort(l.begin(),l.end());
    sort(r.begin(),r.end());
    if(r[0] - l[m-1] < 0){
        cout << 0 << endl;
    }else{
        cout << r[0] - l[m-1] + 1 << endl;
    }
}

Measured memory_bytes: 1276
N, W = map(int, input().split())

IN = list(list(map(int, input().split())) for _ in range(N))
sumw = 0
sumv = 0
for w, v in IN:
    sumw += w
    sumv += v

DP = dict()
DP[sumv] = sumw

def minv(i, v):
    if not DP.get(i):
        DP[i] = v
    else:
        if v < DP[i]:
            DP[i] = v

if sumw <= W:
    ans = sumv
else:
    ans = 0
    for w, v in IN:
        DPpre = DP.copy()
        for i in DPpre:
            answ = i - v
            minv(answ, DPpre[i]-w)
            if answ > ans:
                if DP[answ] <= W:
                    ans = answ
                    continue

print(ans)


Measured memory_bytes: 100352
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    string S;
    cin >> S;

    bool yes = false;
    for (int i = 0; i < S.size() - 1; i++) {
        if (S[i] != S[i + 1]) {
            yes = true;
            break;
        }
    }
    if (yes)
        cout << "Yes" << endl;
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int NMAX=2000;
int n,w,z,cartes[NMAX];

int abs(int x){
	return max(x,-x);
}

int main(){
		
	cin >> n >> z >> w;
	for(int i=0;i<n;i++) cin >> cartes[i];
	
	if(n==1){
		cout << abs(cartes[n-1]-w) << '\n';
	}
	else{
		cout << max(abs(cartes[n-1]-w),abs(cartes[n-1]-cartes[n-2])) << '\n';
	}
	
}


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

int n;
string s;

int main()
{
  cin >>n >>s;
  if(n & 1)
  {
    cout <<"No";
  }
  else 
  {
    int cnt = 0;
    for(int i = 0; i < n / 2; i++)
    {
      if(s[i] != s[i + n / 2]) cnt++;
    }
    
    if(cnt) 
      cout <<"No";
    else 
      cout <<"Yes";
  }
  return 0;
}

Measured memory_bytes: 256
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
R = [0] * N
if S[-1] == 'R':
    R[-1] = W - 1
else:
    R[-1] = W
for i in range(N - 2, -1, -1):
    if S[i] == 'R':
        if T[i] == 'L':
            R[i] = min(R[i + 1], W - 1)
        else:
            R[i] = max(0, R[i + 1] - 1)
    else:
        if T[i] == 'L':
            R[i] = min(W, R[i + 1] + 1)
        else:
            R[i] = R[i + 1]
L = [0] * N
if S[-1] == 'L':
    L[-1] = 2
else:
    L[-1] = 1
for i in range(N - 2, -1, -1):
    if S[i] == 'L':
        if T[i] == 'R':
            L[i] = max(L[i + 1], 2)
        else:
            L[i] = min(W + 1, L[i + 1] + 1)
    else:
        if T[i] == 'R':
            L[i] = max(1, L[i + 1] - 1)
        else:
            L[i] = L[i + 1]
D = [0] * N
if S[-1] == 'D':
    D[-1] = H - 1
else:
    D[-1] = H
for i in range(N - 2, -1, -1):
    if S[i] == 'D':
        if T[i] == 'U':
            D[i] = min(D[i + 1], H - 1)
        else:
            D[i] = max(0, D[i + 1] - 1)
    else:
        if T[i] == 'U':
            D[i] = min(H, D[i + 1] + 1)
        else:
            D[i] = D[i + 1]
U = [0] * N
if S[-1] == 'U':
    U[-1] = 2
else:
    U[-1] = 1
for i in range(N - 2, -1, -1):
    if S[i] == 'U':
        if T[i] == 'D':
            U[i] = max(U[i + 1], 2)
        else:
            U[i] = min(H + 1, U[i + 1] + 1)
    else:
        if T[i] == 'D':
            U[i] = max(1, U[i + 1] - 1)
        else:
            U[i] = U[i + 1]
ans = "YES"
if sc < L[0] or sc > R[0] or sr < U[0] or sr > D[0]:
    ans = "NO"
for i in range(N):
    if R[i] < L[i] or D[i] < U[i]:
        ans = "NO"
print(ans)

Measured memory_bytes: 16520
#include <bits/stdc++.h>
#include <numeric>
#define M 1000000007
#define inf 1e18+1
#define pb push_back
// #define mp make_pair
#define forz(i,s,n) for(lli i=s;i<n;i++)
#define fore(i,n,s) for(lli i=n;i>=s;i--)
#define binod ios_base ::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

typedef long long int lli;
//typedef pair<long long int, long long int> pll;
typedef unsigned long long int ull;
using namespace std;

lli recpow(lli x, lli n, lli mod)
{
    if (n == 0)
        return 1;
    else if (n % 2 == 0) //n is even
        return recpow((x * x) % mod, n / 2, mod);
    else //n is odd
        return (x * recpow((x * x) % mod, (n - 1) / 2, mod)) % mod;
}

const int nax=1e5+4;
int n,k, mini;
int dp[nax]; 
int a[102];

bool func(lli x)
{
    //cout<<x<<" ";
    if(x<0)
    return 1;
    if(x<mini)
    return dp[x]=0;
    if(dp[x]!=-1)
    return dp[x];

    forz(i,0,n)
    if(func(x-a[i])==0)
    return dp[x]=1;

    return dp[x]=0;
}

//code begins here
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    binod
            //sieve();
            //cout  << "hgfjhg";
    forz(i,0,nax) dp[i]=-1;
    cin>>n>>k;
    forz(i,0,n) cin>>a[i];

    mini=*min_element(a,a+n);

    // forz(i,0,mini)
    // dp[i]=0;
    // forz(i,0,n)
    // forz(j,a[i],k+1)
    // {
    //     if(dp[j-a[i]]==0)
    //     dp[j]=1;
    //     else  
    //     dp[j]=0;
    // }
    
    if(func(k))
    cout<<"First";
    else  cout<<"Second";

    return 0;
}

Measured memory_bytes: 8720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x % 2 == 0 && x != 2)
			x++;
		while(true) {
			boolean flag = true;
			for(int i = 3; i < Math.sqrt(x); i = i + 2) {
				if(x % i == 0) {
					flag = false;
					break;
				}
			}
			if(flag) {
				break;
			}
			x += 2;
		}
		System.out.println(x);
	}

}


Measured memory_bytes: 21844
import sys
#input = sys.stdin.readline

def inpl(): return list(map(int, input().split()))
Q = int(input())
 
MOD = 10**6 + 3
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
size = MOD + 1
g1, g2, inverse = [0]*size, [0]*size, [0]*size
 
g1[:2] = [1, 1] # 元テーブル
g2[:2] = [1, 1] #逆元テーブル
inverse[:2] = [0, 1] #逆元テーブル計算用テーブル

for i in range(2, size):
    g1[i] =  ( g1[i-1] * i ) % MOD 
    inverse[i] = (-inverse[MOD % i] * (MOD//i) ) % MOD 
    g2[i] =  (g2[i-1] * inverse[i]) % MOD

for _ in range(Q):
    x, d, n = inpl()
    xd = x*inverse[d]%MOD
    if d != 0:
        if n < ((MOD-x)*inverse[d] + 1)%MOD:
            n = n%MOD
            print((g1[(xd + n - 1)%MOD] * g2[(xd-1)%MOD] * pow(d, n, MOD))%MOD)
        else:
            print(0)
    else:
        print(pow(x, n, MOD))

Measured memory_bytes: 77584
#!/usr/bin/env python3
import sys


def solve(N: int):
    cur = N
    ret = []
    i = 0
    if N == 0:
        ret = ['0']
    while abs(cur) > 0:
        if i % 2 == 0:
            elm = (2 ** i)
        else:
            elm = -(2 ** i)
        tmp =  2 ** (i + 1)
        #print(cur, elm, tmp)
        if abs(cur - elm) % tmp == 0:
            ret.append('1')
            cur -= elm
        else:
            ret.append('0')
        i += 1
    ret.reverse()
    print(''.join(ret))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


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

    V<P<ll, ll> > pa(m);
    for(int i = 0; i < m; i++){
        ll b, c; cin >> b >> c;
        pa[i] = make_pair(c, b);
    }

    sort(ALL(a));
    sort(ALL(pa), greater<P<ll, ll>>());

    int p = 0;
    for(int i = 0; i < m; i++){
        if(n < p) break;
        ll b = pa[i].second;
        ll c = pa[i].first;
        if(a[p] <= c){
            for(int j = p; j < min(p + b, n); j++){
                if(a[j] <= c) a[j] = c;
            }
            p += b;
        }
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
ll mod_pow(ll a, ll n, T mod) {
    mod = (ll)mod;
    ll res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}

bool check(const vector<char>& zoo, const string& s) {
    const int N = s.size();
    rep(i, N) {
        int before = ((i - 1) < 0 ? (i - 1) % N + N : (i - 1) % N),
            after = (i + 1) % N;
        if (zoo[i] == 'S') {
            if (zoo[before] == zoo[after]) {
                if (s[i] != 'o') return false;
            } else {
                if (s[i] != 'x') return false;
            }
        } else {
            if (zoo[before] == zoo[after]) {
                if (s[i] != 'x') return false;
            } else {
                if (s[i] != 'o') return false;
            }
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string s;
    cin >> s;
    vector<string> cand = {"SS", "SW", "WS", "WW"};
    rep(j, 4) {
        vector<char> zoo = {cand[j][0], cand[j][1]};
        for (int i = 1; i < N - 1; i++) {
            if (zoo[i] == 'S') {
                if (s[i] == 'o')
                    zoo.push_back(zoo[i - 1]);
                else {
                    if (zoo[i - 1] == 'S')
                        zoo.push_back('W');
                    else
                        zoo.push_back('S');
                }
            } else {
                if (s[i] == 'x')
                    zoo.push_back(zoo[i - 1]);
                else {
                    if (zoo[i - 1] == 'S')
                        zoo.push_back('W');
                    else
                        zoo.push_back('S');
                }
            }
        }
        assert((int)zoo.size() == N);
        if (check(zoo, s)) {
            rep(i, N) cout << zoo[i];
            // cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 668
import sys
def rotate(arr,i):
    if i=='W':
        arr=[arr[k-1] for k in [3,2,6,1,5,4]]
    if i=='E':
        arr=[arr[k-1] for k in [4,2,1,6,5,3]]
    if i=='N':
        arr=[arr[k-1] for k in [2,6,3,4,1,5]]
    if i=='S':
        arr=[arr[k-1] for k in [5,1,3,4,6,2]]
    return arr
def isIdentical(arr,arr2):
    deck=[]
    for i in 'W'*4:
        arr=rotate(arr,i)
        for k in 'NNNN':
            arr=rotate(arr,k)
            deck.append(arr)
    arr=rotate(arr,'N')
    arr=rotate(arr,'W')
    for k in 'NNNN':
        arr=rotate(arr,k)
        deck.append(arr)
    arr=rotate(arr,'W')
    arr=rotate(arr,'W')
    for k in 'NNNN':
        arr=rotate(arr,k)
        deck.append(arr)
    if arr2 in deck:
        return True
    else:
        return False
n=int(input())
allarr=[]
for i in range(n):
    allarr.append(input().split())
for i1,v1 in enumerate(allarr):
    for v2 in allarr[i1+1:]:
        if isIdentical(v1,v2):
            print('No')
            sys.exit()
print('Yes')


Measured memory_bytes: 5616
import collections
N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a = prime_factorize(N)
c = collections.Counter(a)

ind = []
ans = 0
for x in range(1,10):
    ans += x
    ind.append(ans)

cnt = 0
for y in c.values():
    for j,x in enumerate(ind):
        if y < x:
            cnt += j
            break

print(cnt)

Measured memory_bytes: 9468
S = input()
N = len(S)
a = [0] * (N + 1)
for i in range(N):
    if S[i] == '<':
        a[i + 1] = a[i] + 1
for i in range(N - 1, -1, -1):
    if S[i] == '>' and a[i] <= a[i+1]:
        a[i] = a[i+1] + 1
print(sum(a))


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

int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m,p;
	int act = 0;
	int wat = 0;
	string ver;
	cin>>n>>m;
	vector<bool> ac(n + 1, false);
	vector<int> waCount(n + 1, 0);
	for (int i = 0; i < m; i++) {
		cin>>p>>ver;
		if (!ac[p]) {
			if (ver == "AC") {
				ac[p] = true;
				act++;
			}else{
				waCount[p]++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		if (ac[i]) {
			wat += waCount[i];
		}
	}
	cout<<act<<' '<<wat<<'\n';
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

ll n, x, z[51], m[51];

ll num(ll a, ll b)
{
    if (a == 0)
        return 1;

    if (b == 0)
        return 0;

    if (b < z[a - 1])
        return num(a - 1, b - 1);

    ll r = 0;

    if (b >= z[a - 1])
    {
        if (m[a - 1] == 0)
        {
            r = num(a - 1, z[a - 1] - 1);
            m[a - 1] = r;
        }
        else
        {
            r = m[a - 1];
        }
    }

    if (b == z[a - 1])
        return r;

    if (b == z[a - 1] + 1)
        return r + 1;

    if (b >= z[a] - 2)
        return r * 2 + 1;

    return r + 1 + num(a - 1, b - (z[a - 1] + 2));
}

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

    fill(m, m + 51, 0);

    cin >> n >> x;

    z[0] = 1;

    for (int i = 1; i <= 50; i++)
    {
        z[i] = (z[i - 1] * 2) + 3;
    }

    ll res = num(n, x - 1);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
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")
    };
}


fn solve(s: Vec<char>) -> &'static str {
    let len = s.len();
    let f = s[0];
    let l = s[len - 1];
    if f == l {
        if len % 2 == 0 {
            "First"
        } else {
            "Second"
        }
    } else {
        if len % 2 == 0 {
            "Second"
        } else {
            "First"
        }
    }
}

fn main() {
    input!{
        s: chars
    }

    println!("{}", solve(s));
}




Measured memory_bytes: 4352
n=int(input())
ass = 0

if n >= 135:
    ass += 1
if n >= 189:
    ass += 1

if n >= 3*5*7:
    ass += 1
if n >= 3*5*11:
    ass += 1
if n >= 3*5*13:
    ass += 1

print(ass)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    double concnow=0.0;
    ll ans=0,sugar=0;
    rep(i,31){
        // if(100*a*i>f) continue;
        rep(j,31){
            // if(100*a*i+100*b*j>f) continue;
            if(i==0&&j==0) continue;
            rep(k,3001){
                // if(100*a*i+100*b*j+c*k>f) continue;
                rep(l,3001){
                    ll sum=i*a*100+j*b*100+k*c+l*d;
                    double conc=(double)((double)((k*c+l*d)*100)/(double)(sum));
                    if((double)((double)(k*c+l*d)/(double)(i*a*100+j*b*100))*100>(double)((double)e+eps)) break;
                    if(sum>f) break;
                    if(concnow<conc){
                        ans=sum;
                        sugar=k*c+l*d;
                        concnow=conc;
                    }
                }
            }
        }
    }
    if(ans==0) cout<<100*a<<" "<<0<<endl;
    else cout<<ans<<" "<<sugar<<endl;
    return 0;
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N, P;
	vector<int> A;
	int zo[2] = {};

	cin >> N >> P;
	A.resize(N);
	for(int i = 0; i < N; i++){
		cin >> A[i];
		zo[A[i]%2]++;
	}

	llong ans = 1;
	for(int i = 0; i < N-1; i++)
		ans *= 2;

	if(P == 0){
		if(zo[1] == 0)
			ans *= 2;
	}else{
		if(zo[1] == 0)
			ans = 0;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
data Queue a = Queue [a] [a]
enqueue::a->Queue a->Queue a
enqueue x (Queue xs ys) = Queue (x:xs) ys
dequeue::Queue a->(a, Queue a)
dequeue (Queue xs []) = dequeue (Queue [] (reverse xs))
dequeue (Queue xs (y:ys)) = (y, Queue xs ys)
toInt::String->Int
toInt = read
sub::[String]->(String, Int)
sub (x:y:_) = (x, toInt y)
solve::Int->Int->Queue (String, Int)->String
solve _ _ (Queue [] []) = ""
solve t q queue
  | x2 > q = solve (t+q) q (enqueue (x1, x2-q) queue')
  | otherwise = x1 ++ " " ++ show (t+x2) ++ "\n" ++ solve (t+x2) q queue'
    where
      ((x1, x2), queue') = dequeue queue
main::IO ()
main = do
  a <- getLine
  let _:q:_ = words a
  getContents >>=
    putStr.(solve 0 (toInt q)).(foldl (flip enqueue) (Queue [] [])).(map (sub.words)).lines


Measured memory_bytes: 34760
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//(*'ω'*)ACcept me...
int main(){
    int n;cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++)cin>>vec[i];
    int ans=0;
    for(int i=0;i<n-1;i++){
        if(i+1==vec[i]){
            swap(vec[i],vec[i+1]);
            ans++;
        }
    }
    if(vec[n-1]==n)ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int k,n=s.size();
	cin>>k;
	vector<string> cnt;
	rep(i,n){
		FOR(j,1,k+1) cnt.push_back(s.substr(i,j));
	}
	sort(begin(cnt),end(cnt));
	cnt.erase(unique(begin(cnt),end(cnt)),end(cnt));
	cout<<cnt[k-1]<<endl;
}

Measured memory_bytes: 1660
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, l;
    cin >> n >> l;

    int s = 0; // りんごの味の総和
    int m = 1e9; // 絶対値が最も小さい、りんごの味
    int t;
    for (int i = 0; i < n; i++)
    {
        t = l + i; // りんご(i+1)の味
        if(abs(t) < abs(m)) m = t;
        s += t;
    }
    int ans = s - m;
    cout << ans << endl;
}

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

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

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;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;

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

  int ans = 10000000;
  for(int i=1; i<=100; i++) {
    int dist = 0;
    for(int j=0; j<n; j++) {
      dist += pow(x[j] - i, 2);
    }
    if(dist < ans) {
      ans = dist;
    }
  }
  cout << ans << endl;
}

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

int main()
{
    string s;
    cin >> s;
    int digit_sum = 0;
    int l = s.length();
    for(int i = 0; i < l; ++i) {
        digit_sum += (s[i] - '0');
    }
    cout << (digit_sum%9?"No":"Yes");
}

Measured memory_bytes: 3704
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    vector<int> v(60*60+1,0);
    for(int i = 0; i*(a+b) < 60*60; i++){
        v[i*(a+b)]++;
        v[min(60*60-1, i*(a+b)+a)+1]--;
    }
    for(int i = 0; i < 60*60; i++) v[i+1] += v[i];
    for(int i = 0; i < 60; i++){
        if(v[i*60+c]){
            cout << i*60+c << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}



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

using namespace std;
int main() {
  string S,T;
  cin >> S >> T;
  
  int N = S.size();
  int M = T.size();
  
  int ans = M;
  for(int i=0; i<N-M+1; i++){
    int count = 0;
    for(int j=0; j<M; j++){
      if( T[j] == S[i+j] ) count ++;
    }
    if( M-count < ans) ans = M-count;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3628
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// cout.presicion(20);

int main() {
    string O, E;
    cin >> O >> E;
    for(int i = 0; i < E.length(); i++) {
        cout << O[i];
        cout << E[i];
    }
    if(E.length() != O.length()) {
        cout << O[O.length() - 1];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int main(){int a,b,c,d,p;scanf("%d%d%d%d%d",&a,&b,&c,&d,&p);printf("%d\n",a*p<b+(p-c)*(c<p?d:0)?a*p:b+(p-c)*(c<p?d:0));}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	buf := make([]byte, 200001)
	scanner.Buffer(buf, 200001)

	rs := []rune(getString())

	idxA := -1
	idxZ := -1
	for i, r := range rs {
		if r == 'A' && idxA == -1 {
			idxA = i
		}

		if r == 'Z' {
			idxZ = i
		}
	}

	fmt.Println(idxZ - idxA + 1)
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
int main()	{
	int n;
	scanf("%d",&n);
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ll cnt=n/i;
		ans+=cnt*(i*2+(cnt-1)*i)/2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3828
n,k = [int(x) for x in input().strip().split()]
H = [int(x) for x in input().strip().split()]

inf = int(10e9 + 7)
dp = [inf] * n
dp[0] = 0
for i in range(n):
    for j in range(i+1,min(n,i+k+1)):
        dp[j] = min (dp[j], dp[i] + abs(H[i] - H[j]))
print (dp[-1])

Measured memory_bytes: 52448
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>

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

    int P = (int)std::round(std::accumulate(X.begin(), X.end(), 0) / (double)N);

    int cost = 0;
    for (int i = 0; i < N; ++i) {
        cost += std::pow(X[i] - P, 2);
    }

    std::cout << cost << std::endl;

    return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin >> n >> k;
    int count=1;
    while(n){
        if(n/k>0) count++;
        n/=k;
    }
    cout << count ENDL;
    
    return 0;
}

Measured memory_bytes: 3540
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main (){
    int a,b;
    cin >> a>> b;
    string s;
    cin >> s;
    if(s.find('-') == a){
        s.replace(a,1,"1");
        if(s.find('-') == string::npos){
            if(s.length() == a+b+1)
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 A,B;
	cin >> A >> B;
	cout << ((A*B)%2==0 ? "No" : "Yes") << endl;
	return 0;
}


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

int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<int> B(N), W(N);
    for (int i = 0; i < N; i++) {
        if (S[i] == '#') B[i]++;
        if (S[i] == '.') W[i]++;
    }
    for (int i = 1; i < N; i++) {
        B[i] += B[i - 1];
        W[i] += W[i - 1];
    }

    int res = 1000000000;
    for (int i = 0; i < N; i++) {
        int w = B[i - 1];
        int b = W[N - 1] - W[i];

        res = min(res , w + b);
    }
    res = min(res, B[N - 1]);
    res = min(res, W[N - 1]);
    cout << res << endl;
}

Measured memory_bytes: 2180
import itertools
import math

def calc_dist(pos1, pos2):
    x1,y1=pos1
    x2,y2=pos2
    return math.sqrt(pow(x1-x2, 2)+pow(y1-y2, 2))

N=int(input())

distance_mat = [[-1000 for _ in range(N)] for _ in range(N)]
pos = []
for _ in range(N):
    pos.append(list(map(int, input().split())))

perms = itertools.permutations(list(range(N)), N)

result=[]
for perm in perms:
    dist_sum = 0
    for i in range(1, N):
        source = perm[i-1]
        sink = perm[i]
        if distance_mat[source][sink]==-1000:
            dist = calc_dist(pos[source], pos[sink])
            distance_mat[source][sink] = dist
            distance_mat[sink][source] = dist
        else:
            dist = distance_mat[source][sink]
        dist_sum+=dist
    result.append(dist_sum)

import numpy as np
print(np.average(result))


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

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


Measured memory_bytes: 3608
#include <iostream>
#include <string>

using namespace std;

int gcd(int m, int n) {
  int t;
  while (m%n != 0) {
    t = n;
    n = m%n;
    m = t;
  }

  return n;
}

long long int lcm(int m, int n) {
  return (long long int)m*n/gcd(m,n);
}

int main() {
  int n, m;
  string s, t;

  cin >> n >> m >> s >> t;

  bool result = true;
  int g = gcd(n, m);

  for (int i = 0; i<g; i++) {
    if (s[i*n/g] != t[i*m/g]) {
      result = false;
      break;
    }
  }

  if (result) {
    cout << lcm(n, m) << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


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

d = {}
for i in range(m):
    d[i+1] = 0

for i in a:
    for j in i[1:]:
        d[j] += 1
ans = 0
for i in d.values():
    if i == n:
        ans += 1
print(ans)

Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

int main() {
    int K, S;
    cin>>K>>S;
    int count=0;
    rep(i, K+1){
        rep(j, K+1){
            if(i+j>S||S-K>i+j){
                continue;
            }
            else{
                count++;
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;


struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int N;
vector<edge> G[2020];

void dijkstra(int s, vector<int>& d) {
    priority_queue<P, vector<P>, greater<P> > que;
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i = 0; i < G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + 1) {
                d[e.to] = d[v] + 1;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    cin >> N;
    for (int i = 1; i < N; ++i) {
        edge e = { i+1 , 1 };
        G[i].push_back(e);
         e = { i , 1 };
        G[i+1].push_back(e);
    }

    int a, b;
    cin >> a >> b;
    edge e = { b,1 };
    G[a].push_back(e);
     e = { a,1 };
    G[b].push_back(e);

    vector<int> ans(2020, 0);

    for (int i = 1; i <= N; i++) {
        vector<int> d(2020, INF);
        dijkstra(i,d);
        for (int j = 1; j <= N; j++) {
            if (d[j] != INF)ans[d[j]]++;
           // else  ans[d[j]]++;
        }
    }
    for (int i = 1; i <= N - 1; ++i) {
        cout << ans[i]/2 << endl;
    }
}

Measured memory_bytes: 384