akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>

const int mod = 1000000007;

using namespace std;

int dp[105][105][105];
int a[105],n;

int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n * 2 - 1; ++ i)
		scanf("%d",&a[i]);
	sort(a + 1,a + n * 2);
	dp[n][1][0] = 1;
	for(int i = n - 1;i >= 1; -- i)
	{
		int ll = a[i] != a[i + 1],rr = a[2 * n - i - 1] != a[2 * n - i];
		for(int j = 0;j <= 2 * n - 1; ++ j)
			for(int k = 0;j + k <= 2 * n - 1; ++ k)
				if(dp[i + 1][j][k])
				{
					for(int t = 1;t <= ll + j; ++ t)
						dp[i][j + ll - t + 1][k + rr + (t != 1)] += dp[i + 1][j][k],dp[i][j + ll - t + 1][k + rr + (t != 1)] %= mod;
					for(int t = 1;t <= rr + k; ++ t)
						dp[i][j + ll + 1][k + rr - t] += dp[i + 1][j][k],dp[i][j + ll + 1][k + rr - t] %= mod;
				}
	}
	int ans = 0;
	for(int i = 0;i <= 2 * n - 1; ++ i)
		for(int j = 0;i + j <= 2 * n - 1; ++ j)
			ans = (ans + dp[1][i][j]) % mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;
template <typename T>
void vecin(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n - 1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}

int main()
{
    int n, k = 0;
    cin >> n;
    int now = 1;
    while(now < n){
        now *= 2;
        ++k;
    }
    vector<vint> a(n, vint(n));
    REP(i, n)
    {
        REP(j,n){
            if (i < j){
                REP(m,k){
                    if ((i & (1 << m)) != (j & (1 << m))){
                        a[i][j] = m + 1;
                    }
                }
            }
        }
    }
    REP(i,n-1){
        FOR(j, i + 1, n - 1){
            cout << a[i][j] << " ";
        }
        cout << a[i][n - 1] << endl;
    }
}

Measured memory_bytes: 1536
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

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

    vector<char> c(m);
    vector<int> s(m);

    rep(i,m) cin >> s[i] >> c[i];

    int num,p;

    if(n==1) {
        num = 10;
        p = 0;
    }
    else if(n==2) {
        num = 100;
        p = 10;
    }
    else {
        num = 1000;
        p = 100;
    }

    bool t = true;

    int ans;

    for(int i = p; i < num; i++){
        string x = to_string(i);
        t = true;
        rep(j,m){
            if(x[s[j]-1] != c[j]) {
                t = false;
                break;
            }
        }
        if(t) {
            ans = i;
            break;
        }
    }

    if(t) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <ctype.h>
#include <stdio.h>
#include <string.h>

char
toswap(char c)
{
	if (islower(c)) return toupper(c);
	if (isupper(c)) return tolower(c);
	return c;
}

int
main()
{
	char s[1200];
	fgets(s, sizeof(s), stdin);

	int i;
	int len = strlen(s);
	for (i = 0; i < len; i++)
	{
		char c = toswap(s[i]);
		putchar(c);
	}

	return 0;
}

Measured memory_bytes: 524
/**
 * File              : D.cpp
 * Author            : JCHRYS <jchrys@me.com>
 * Date              : 26.01.2020
 * Last Modified Date: 26.01.2020
 * Last Modified By  : JCHRYS <jchrys@me.com>
 */

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
unordered_map<ll, ll> mp;

ll dfs(ll h) {
    if (mp.count(h)) {
        return mp[h];
    } else {
        if (h == 1) {
            return 1;
        }
        mp[h] = dfs(h>>1) + dfs(h>>1) + 1;
        return mp[h];

    }
}

int main() {
    ll h;
    cin >> h;
    cout << dfs(h) << endl;

    return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())

F = [0 for i in range(N)]
T = [[]for i in range(N)]

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

X = [0 for i in range(N)]
for i in range(Q):
    p, x = map(int, input().split())
    X[p-1] += x

ans = [X[i] for i in range(N)]
for i in range(N):
    F[i] = 1
    for j in range(len(T[i])):
        if F[T[i][j]] == 1:
            continue
        ans[T[i][j]] += ans[i]

for i in range(N):
    print(ans[i], end =" ")


Measured memory_bytes: 107084
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n;
	cin>>n;
	cout<<2*n/gcm(2,n)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  int N, A[3], L[8];
  cin >> N >> A[0] >> A[1] >> A[2];
  REP(i, N) {
    cin >> L[i];
  }
  cout << endl;
  int mp[3][256];
  int lmax = 1 << N;
  REP(i, 3) {
    mp[i][0] = 9999;
  }
  for(int l = 1; l < lmax; ++l) {
    int len = 0;
    int tmp = -10;
    REP(i, N) {
      if((l & (1 << i)) != 0) {
        len += L[i];
        tmp += 10;
      }
    }
    REP(i, 3) {
      mp[i][l] = tmp + abs(len - A[i]); 
    }
  }
  int mpAB[256], mpABC[256];
  REP(i, lmax) {
    mpAB[i] = 9999;
    mpABC[i] = 9999;
  }
  REP(i, lmax) {
    REP(j, lmax) {
      if((i & j) != 0) continue;
      if(mpAB[i + j] > mp[0][i] + mp[1][j]) {
        mpAB[i + j] = mp[0][i] + mp[1][j];
      }
    }
  }
  REP(i, lmax) {
    REP(j, lmax) {
      if((i & j) != 0) continue;
      if(mpABC[i + j] > mpAB[i] + mp[2][j]) {
        mpABC[i + j] = mpAB[i] + mp[2][j];
      }
    }
  }
  int ret = 9999;
  REP(i, lmax) {
    if(ret > mpABC[i]) {
      ret = mpABC[i];
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
cumulative :: [Int] -> [Int]
--cumulative xs = f xs 0
--  where
--    f [] a = []
--    f (x:xs) a = (x + a):(f xs $ x + a)
cumulative xs = reverse.init $ f xs [0]
  where
    f [] ys = ys
    f (x:xs) (y:ys) = f xs $ (y + x):y:ys

main = do
  _ <- getLine
  s <- getLine
  let en = reverse $ cumulative $ reverse $ map (\c -> if c == 'E' then 1 else 0) s
  let wn = cumulative $ map (\c -> if c == 'W' then 1 else 0) s
  print $ subtract 1 $ minimum $ zipWith (+) en wn


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

using namespace std;
const int N = 2e3 + 5;

int n, m, q;
char S[N][N];

int sum[N][N];
int hor[N][N]; // s3
int ver[N][N]; // s2

signed main() {
    cin >> n >> m >> q;
    for (int i = 1; i <= n; i++)
        cin >> (S[i] + 1);
    
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            sum[i][j] = sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1];
            hor[i][j] = hor[i][j - 1] + hor[i - 1][j] - hor[i - 1][j - 1];
            ver[i][j] = ver[i][j - 1] + ver[i - 1][j] - ver[i - 1][j - 1];

            if (S[i][j] == '1') {
                ++sum[i][j];
                if (S[i][j - 1] == '1') --hor[i][j];
                if (S[i - 1][j] == '1') --ver[i][j];
            }
        }
    
    while (q--) {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;

        cout << (
              (sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1])
            + (hor[x2][y2] - hor[x1 - 1][y2] - hor[x2][y1] + hor[x1 - 1][y1])
            + (ver[x2][y2] - ver[x1][y2] - ver[x2][y1 - 1] + ver[x1][y1 - 1])
        ) << endl;
    }
}

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

const int N = (int)(1e6 + 7);

int n, a[N], p[N];

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		p[a[i]] = i;
	}
	for(int i = 1; i <= n; i++){
		cout << p[i] << " ";
	}
	return 0;
}


Measured memory_bytes: 5248
#if defined(LOCAL)
#define PROBLEM_NAME "a"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define C(x, ...) ;
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

void solve(istream& cin, ostream& cout) {
  l a, b; cin >> a >> b;
  if (b < a) a--;
  cout << a << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 256
//#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const int maxn = 733, mod = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, m, k, mat[maxn][maxn];
vi g[maxn];
int c[2];
int col[maxn];
void dfs(int v, int cc) {
	col[v] = cc+1;
	c[cc]++;
	for(int i : g[v]) {
		if(col[v]==col[i]) cout << -1, exit(0);
		if(col[i]) continue;
		dfs(i, cc^1);
	}
}
bitset<100000> bp;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for(int f, t, i = 0; i < m; i++) {
		cin >> f >> t;
		mat[f][t] = mat[t][f] = 1;
	}
	
	for(int i = 1; i <= n; i++)
		for(int j =  i+1; j <= n; j++) {
			if(mat[i][j]) continue;
			g[i].pb(j), g[j].pb(i);
			++k;
		}
	int a = 0, b = 0;
	bp.set(0);
	for(int i = 1; i <= n; i++) {
		if(col[i]) continue;
		c[0] = c[1] = 0;
		dfs(i, 0);
		bp = (bp<<c[0])|(bp<<c[1]);
	}
	int ans = 1<<30;
	for(int i = 0; i <= n; i++) if(bp.test(i)) ans = min(ans, m - (i*(n-i) - k));//, cout << i << "\n";
	cout << ans;
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

int N,A[1000005];
int cnt[1000005];
bool ng[1000005];
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>N;
	int algc;
	rep(i,N){
		cin>>A[i];
		if(!i)algc=A[i];
		else algc=gcd(algc,A[i]);
		cnt[A[i]]++;
	}
	bool pairwi=true;
	for(int i=2;i<=1e6;i++){
		if(ng[i])continue;
		int sum=0;
		for(int j=1;i*j<=1e6;j++){
			sum+=cnt[i*j];
			ng[i*j]=true;
		}
		if(sum>1)pairwi=false;
	}
	if(pairwi)cout<<"pairwise coprime"<<endl;
	else if(algc==1)cout<<"setwise coprime"<<endl;
	else cout<<"not coprime"<<endl;
}


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

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

int main() {
    int n, d; cin >> n >> d;
    cout << n / (2*d+1) + (n%(2*d+1)==0 ? 0 : 1) << endl;
    return 0;
}


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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  set<int> arr;
  for (int i = a; i < a + k; ++i) {
    if (i <= b) arr.insert(i);
  }
  for (int i = b; i > b - k; --i) {
    if (i >= a) arr.insert(i);
  }
  for (int x : arr) {
    cout << x << endl;
  }
}


Measured memory_bytes: 256
import sys
from collections import defaultdict, deque, Counter
import math
# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def solve(n):
    ans = 0
    while(n > 0):
        tmp = n
        pc = 0
        # print("wait")
        while(tmp > 0):
            if tmp % 2 == 1:
                pc += 1
            tmp //= 2
        n = n % pc
        ans += 1

    return ans



def main():
    n = getN()
    S = getS()
    N = int(S, 2)
    yobi = []

    for i in range(0, 200200):
        ret = solve(i)
        yobi.append(ret)
    # print(yobi)

    tmp = N
    pc = 0
    # print("N", N)
    pc = Counter(S)["1"]

    start1 = N % (pc + 1)
    rui1 = [1 % (pc + 1)]
    for i in range(n + 2):
        rui1.append((rui1[-1] * 2) % (pc + 1))
    if pc > 1:
        start2 = N % (pc - 1)
        rui2 = [1 % (pc - 1)]
        for i in range(n+2):
            rui2.append((rui2[-1] * 2) % (pc - 1))

    # print(start1, start2, pc)
    # print(rui1)
    # print(rui2)
    for i, c in enumerate(S):
        if c == "0":
            nx = (start1 + rui1[n - i - 1]) % (pc + 1)
            print(yobi[nx] + 1)
        if c == "1":
            if pc == 1:
                print(0)
            else:
                nx = (start2 - rui2[n - i - 1]) % (pc - 1)
                print(yobi[nx] + 1)

    # print(int("".join(["1" for i in range(200200)])) % 1)

if __name__ == "__main__":
    main()
    # solve()


Measured memory_bytes: 107732
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    int[] cnt = new int[11];
    cnt[ni()]++;
    cnt[ni()]++;
    cnt[ni()]++;
    System.out.println(cnt[5] == 2 && cnt[7] == 1 ? "YES" : "NO");
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 9680
def main():
    N = int(input())
    ll = [list(map(int, list(input().split()))) for i in range(N)]
    # ll = [[3, 1, 2], [6, 5, 2]]
    for l in ll:
        t = l[0]
        x = l[1]
        y = l[2]
        if t < x + y:
            print('No')
            return
        if (t % 2) != ((x + y) % 2):
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 27352
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, K = input_number_list()
    t = 0
    i = max(A,B)+1
    while t < K:
        i -= 1
        t += 1 if A % i == 0 and B % i == 0 else 0
    print(i)


main()


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    while(--n >= 0){
        int h, m;
        char c;
        cin >> h >> c >> m;

        int a = abs(60 * h - 11 * m);
        if(a < 30*2 || a > 330*2)
            cout << "alert" << endl;
        else if(90*2 <= a && a <= 270*2)
            cout << "safe" << endl;
        else
            cout << "warning" << endl;
    }

    return 0;
}

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

int lpfact[1000005];

void seive() {
    lpfact[0] = lpfact[1] = 1;
    for(int i=2; i<=1000000; i+=2) {
        lpfact[i] = 2;
    }
    for(int i = 3; i<=1000000; i+=2) {
        if(!lpfact[i]) {
            for(int j=1; i*j <= 1000000; j++) {
                if(!lpfact[i*j]) {
                    lpfact[i*j] = i;
                }
            }
        }
    }
   
}

int main() {
    int t = 1;
    seive();
    while(t--) {
        int n;
        cin>>n;
        vector<int> a(n), vis(1000001, 0);
        vector<set<int> > pfs(n);
        bool ispairwise = 1;
        bool coprime = 0;
        for(int i=0; i<n; i++) {
            cin>>a[i];
            int x = a[i];
            if(x == 0)
                coprime = 1;
            while(x > 1) {
                pfs[i].insert(lpfact[x]);
                x/=lpfact[x];
            }
            for(int y: pfs[i]) {
                if(vis[y]) {
                    ispairwise = 0;
                }
                vis[y] = 1;

            }
        }   
        set<int> intersection; 
        
        for(int x : pfs[0]) {
            intersection.insert(x);
        }

        for(int i=1; i<n; i++) {
            set<int> newIntersection;
            for(int x: pfs[i]) {
                if(intersection.find(x) != intersection.end())
                    newIntersection.insert(x);
            }
            intersection = newIntersection;
        
        }    

        if(ispairwise) {
            cout<<"pairwise coprime"<<endl;
        } else {
            if(intersection.size() != 0 && coprime == 0) {
                cout<<"not coprime"<<endl;
            } else {
                cout<<"setwise coprime"<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 298552
import bisect
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
a_ = bisect.bisect_right(p,a)
b_ = bisect.bisect_right(p,b)
print(min(a_,b_-a_,n-b_))

Measured memory_bytes: 3064
N = int(input())
T = [int(input()) for i in range(N)]

def gcd(x, y):
    while(y > 0):
        x, y = y, x % y
    return x

T.sort()
time = T[0]
for i in range(1,N):
    time *= T[i] // gcd(T[i], time)
print(time)


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i,a,n) for(int i = a;i < (int)(n);i++)
using namespace std;
typedef long long ll;

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

    int count = 0;

    irep(i,1,N+1){
        string s = to_string(i);
        if(s.size() % 2 == 1){
            count++;
        }

    }

    cout << count << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin.bytes().map(|c| c.expect("faild") as char).skip_while(|c| c.is_whitespace()).take_while(|c| !c.is_whitespace()).collect();
    token.parse().ok().expect("faild parse")
}
fn main(){
    let a: i16 = read();
    let b: i16 = read();
    let c: i16 = read();
    if a < b && b < c{
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 1044
'use strict';
const main = input => {
  let numbers = input[0].split(' ').map(val => parseInt(val));
  let a = numbers[0], b = numbers[1];
  const gcd = (l, r) => {
    let ans;
    if(l < r) {
      ans = l;
      l = r;
      r = ans;
    }
    while ((ans = l%r) != 0) {
      l = r;
      r = ans;
    }
    return r;
  }
  console.log(a*b/gcd(a,b));
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 7372
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> P;
typedef std::priority_queue<P> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

bool usedb[128];

void solve(void){
    int N;
    cin >> N;
    vector <P> red, blue;
    rep(N, i) {
        int a, b; cin >> a >> b;
        red.push_back(P(a, b));
    }
    rep(N, i) {
        int a, b; cin >> a >> b;
        blue.push_back(P(a, b));
    }
    sort(red.rbegin(), red.rend());
    sort(blue.rbegin(), blue.rend());
    int ans = 0;
    int r = 0;
    memset(usedb, false, sizeof(usedb));
    while(red[r].first >= blue[0].first and r < N) r++;
    while(r < N){
        int minb = -1, miny = INF;
        rep(N, b) {
            if (red[r].second < blue[b].second and miny > blue[b].second and !usedb[b] and (red[r].first < blue[b].first)) {
                miny = blue[b].second;
                minb = b;
            }
        }
        if (minb != -1) {
            ans++;
            usedb[minb] = true;
        }
        r++;
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

const int SIZE=110;
template<typename T> class mystack
{
 private:
    T a[SIZE]; int sz;
 public:
    mystack():sz(0){}
    void push(T val){ a[sz++]=val; }
    void pop(){ sz--; }
    T top(){ return a[sz-1]; }
};

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

    mystack<int> S;
    auto calc=[&](string str)
    {
        int b=S.top(); S.pop();
        int a=S.top(); S.pop();
        if(str=="+") return a+b;
        if(str=="-") return a-b;
        return a*b;
    };
    string str;
    while(cin>>str){
        if(str=="+" or str=="-" or str=="*"){
            S.push(calc(str));
        }else{
            S.push(stoi(str));
        }
    }
    cout<<S.top()<<endl;
    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(n+1,vector<int>(n+1));
    rep(i,n){
        rep(j,n-1) cin >> a.at(i+1).at(j+1);
    }
    vector<int> b(n+1,1),c(n+1);
    rep(i,n) c.at(i+1)=a.at(i+1).at(b.at(i+1));
    queue<pair<int,pair<pp,pp>>> q;
    int ans=0,m=0;
    vector<int> o(n+1,0);
    rep(i,n){
        //cout << c.at(c.at(i+1)) << " " << i+1 << endl;
        if (c.at(c.at(i+1))==i+1 && o.at(i+1)==0){
            q.push(make_pair(1,make_pair(make_pair(i+1,1),make_pair(c.at(i+1),1))));
            o.at(i+1)=1;
            o.at(c.at(i+1))=1;
        }
    }
    while (!q.empty()){
        int f=q.front().first,g=q.front().second.first.first,h=q.front().second.first.second;
        int e=q.front().second.second.first,t=q.front().second.second.second;
        q.pop();
        //cout << f << " " << e << endl;
        m++;
        b.at(g)++;b.at(e)++;
        c.at(g)=a.at(g).at(b.at(g));
        c.at(e)=a.at(e).at(b.at(e));
        ans=f;
        if (c.at(g)!=n+1){
        if (c.at(c.at(g))==g) q.push(make_pair(f+1,make_pair(make_pair(g,b.at(g)),make_pair(c.at(g),b.at(c.at(g))))));}
        if (c.at(e)!=n+1){
        if (c.at(c.at(e))==e) q.push(make_pair(f+1,make_pair(make_pair(e,b.at(e)),make_pair(c.at(e),b.at(c.at(e))))));
    }}
    if (m!=n*(n-1)/2) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,A,B,N,R,M,K,X,Y,Z,C;
  string S,T,U;
  cin >> N >> R;

    if(N >= 10){
      cout << R << endl;
    }else{
      cout << R + (100 *(10-N)) << endl;
    }
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------
const int INF = 1e9+1000;
ll n, a, b;
ll h[111111];

int main() {
   cin >> n >> a >> b;
   rep (i, n) cin >> h[i];

   int c = a - b;
   int left = 0, right = INF;
   while (left+1<right) {
      ll bTimes = (left+right)/2;
      ll aTimes = 0;
      rep (i, n) {
         ll nokori = max(h[i] - b * bTimes, 0LL); // 攻撃Bで削る
         aTimes += (nokori+c-1) / c; // 攻撃Aで削る
      }
      if (aTimes <= bTimes) {
         right = bTimes;
      } else {
         left = bTimes;
      }
   }
   cout << right << endl;

   return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;

namespace ABC152
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] strs = Console.ReadLine().Split(' ');
			char a = Convert.ToChar(strs[0]);
			char b = Convert.ToChar(strs[1]);

			string ab = new string(a, int.Parse(strs[1]));
			string ba = new string(b, int.Parse(strs[0]));
			int comp = ab.CompareTo(ba);
			string result;

			if (comp >= 0)
			{
				result = ba;
			}
			else
			{
				result = ab;
			}

			Console.WriteLine(result);
		}
	}
}


Measured memory_bytes: 11360
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
int a[100000+10],b[100000+10];
int i,j,k,l,t,n,m,cnt;
int main(){
	//freopen("b.in","r",stdin);freopen("b.out","w",stdout);
	scanf("%d%d",&n,&m);
	fo(i,1,m){
		scanf("%d",&a[i]);
		if (a[i]%2==1){
			if (cnt==0) j=i;
			else k=i;
			cnt++;
		}
	}
	if (cnt>2){
		printf("Impossible\n");
		return 0;
	}
	if (cnt) swap(a[1],a[j]);
	if (cnt>1) swap(a[m],a[k]);
	if (m==1){
		if (a[1]==1){
			printf("1\n1\n1\n");
			return 0;
		}
		printf("%d\n",a[1]);
		printf("2\n");
		printf("%d 1\n",a[1]-1);
		return 0;
	}
	fo(i,1,m) printf("%d ",a[i]);
	printf("\n");
	if (a[m]==1) printf("%d\n",m-1);else printf("%d\n",m);
	printf("%d ",a[1]+1);
	fo(i,2,m-1) printf("%d ",a[i]);
	if (a[m]>1) printf("%d\n",a[m]-1);
}

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

int main() {
  int N,M,A=1,Z=0;
  cin>>N>>M;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    v.at(i)=i;
    A*=(i+1);
  }
  A/=N;
  vector<vector<int>> G(N,vector<int>(N));
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G.at(a).at(b)++;
    G.at(b).at(a)++;
  }
  for(int i=0;i<A;i++){
    int B=0;
    for(int j=1;j<N;j++){
      if(G.at(v.at(j)).at(v.at(j-1))==0){
        B++;
        break;
      }
    }
    if(B==0){
      Z++;
    }
    next_permutation(begin(v),end(v));
  }
  cout<<Z<<endl;
}




Measured memory_bytes: 256
s=0;f=0;p=0;n=0
K,N=map(int,input().split())
n=N
A=list(map(int,input().split()))
if K!=A[-1]:
  if A[0]==0:
    A.append(K)
  else:
    A.append(K+A[0])
#print(A)
for i in range(N):
  if abs(A[i+1]-A[i])>s:
    s=abs(A[i+1]-A[i])
    f=i+1
if f==(N):
  f=0
#print("f",f)
if f==0:
  n=n-1
for i in range(f,n):
  p=p+abs(A[i+1]-A[i])
  #print(i,p)
for i in range(f-1):
  p=p+abs(A[i+1]-A[i])
print(p)

Measured memory_bytes: 26444
#include<iostream>
#include<unordered_map>
using namespace std;
int main(){
    int n;
   cin>>n;
   unordered_map<int,int> m;
  for(int i=0;i<n;i++){
   int a;
   cin>>a;
   m[a]++;
  }
  int r=0;
  for(auto p: m){
    if(p.second>=p.first)
      r+=p.second-p.first;
    else
      r+=p.second;
  }
  cout<<r;
  return 0;
}


    

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

vector<vector<int>> g;

int n, ans;

void dfs(int u, int v) {
  v = v | (1 << u);
  if (v+1 == (1 << n)) ++ans;
  for (int to : g[u]) {
    if (v & (1 << to)) continue;
    dfs(to, v);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int m;
  cin >> n >> m;
  g.resize(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(0, 0);
  cout << ans << endl;
}

Measured memory_bytes: 256
def split_sum(n):
    ans = 0
    while n:
        ans += n % 10
        n //= 10
    return ans


N = int(input())
ans = float('inf')
for A in range(1, N):
    B = N - A
    if A > B:
        break
    ans = min(ans, split_sum(A) + split_sum(B))
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e6 + 3)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

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

}
int exp(int a, int b){
    LL res = 1;
    LL sum = a;
    for(int i=0;i<30;++i){
        if(BIT(i)&b){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
    }
    return res;
}
int main(){
    string str;
    cin >> str;
    LL ans = 0;
    LL count = 0;
    REP(i, str.size()-1){
        if(str[i]=='A'){
            ++count;
        }else{
            if(str.substr(i, 2)=="BC"){
                ans += count;
                ++i;
            }else{
                count = 0;
            }
        }   
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int v, e;
  cin >> v >> e;
  vector<vector<ll>> d(v,vector<ll>(v,INF));
  rep(i,e) {
    ll s, t, a;
    cin >> s >> t >> a;
    d[s][t] = a;
  }
  vector<vector<ll>> dp(1<<v,vector<ll>(v,INF));
  dp[0][0] = 0;
  rep(i,1<<v) {
    rep(j,v) {
      rep(k,v) {
        if(!(i&(1<<k))) dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k],dp[i][j]+d[j][k]);
      } 
    }
  }
  cout << (dp[(1<<v)-1][0] == INF? -1 : dp[(1<<v)-1][0]) << endl;
  return 0;
}


Measured memory_bytes: 7640
fun main(args: Array<String>) {
    val x = readLine()!!.toInt()
    val l = listOf(0) + readLine()!!.split(" ").map{it.toInt()} + listOf(0)
    var total = 0
    for(i in 0 until x + 1){
        total += Math.abs(l[i + 1] - l[i])
    }
    for (i in 1 until x + 1) {
        when {
            l[i] in l[i - 1]..l[i + 1] || l[i] in l[i + 1]..l[i - 1] -> println(total)
            l[i] > l[i - 1] && l[i] > l[i + 1] -> println(total - (l[i] - Math.max(l[i - 1], l[i + 1])) * 2)
            l[i] < l[i - 1] && l[i] < l[i + 1] -> println(total + (l[i] - Math.min(l[i - 1], l[i + 1])) * 2)
        }
    }
}

Measured memory_bytes: 58676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int a[12]={1,3,1,2,1,2,1,1,2,1,2,1};
int main(void){
    int x,y; cin>>x>>y;
    if(a[x-1]==a[y-1]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

ll pow_mod(ll a, ll n, ll p)
{
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*a%p;
        a = a*a%p;
        n >>= 1;
    }
    return res;
}

int main()
{
    ll i,j;
    ll h,w,k;
    cin >> h >> w >> k;
    vector<vector<ll>> c(h,vector<ll>(w));
    for(i = 0;i < h;++i){
        string s;
        cin >> s;
        rep(j,w){
            c.at(i).at(j) = s.at(j) - '0';
        }
    }
    ll ans = 0;
    for(i = 0;i < h;++i){
        rep(j,w){
            vector<vector<ll>> cc = c;
            cc.at(i).at(j) = 0;
            ll tmp = 0;
            ll stage = 0;
            while(true){
                ll ii,jj;
                rep(jj,w){
                    vector<ll> notzero;
                    for(ii = h-1;ii >= 0;--ii){
                        if(cc.at(ii).at(jj) != 0) notzero.push_back(cc.at(ii).at(jj));
                    }
                    for(ii = 0;ii < notzero.size();++ii){
                        cc.at(h-1-ii).at(jj) = notzero.at(ii);
                    }
                    for(ii = ii;ii < h;++ii){
                        cc.at(h-1-ii).at(jj) = 0;
                    }
                }
                bool flag = true;
                for(ii = h-1;ii >= 0;--ii){
                    rep(jj,w){
                        if(cc.at(ii).at(jj) == 0) continue;
                        if(jj + k-1 >= w) continue;
                        ll kk;
                        ll tmp_number = cc.at(ii).at(jj);
                        ll conlen = 0;
                        for(kk = jj;kk < w;++kk){
                            if(cc.at(ii).at(kk) == tmp_number){
                                ++conlen;
                            }else{
                                break;
                            }
                        }
                        if(conlen >= k){
                            flag = false;
                            tmp += tmp_number*conlen*pow_mod(2ll, stage, 1e12+7);
                            for(kk = jj;kk < jj+conlen;++kk){
                                cc.at(ii).at(kk) = 0;
                            }
                        }
                    }
                }
                if(flag) break;
                ++stage;
            }
            ans = max(tmp,ans);
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N;
ll a[22][22];
ll sc[1<<16];
ll dp[1<<16];

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

  cin>>N;
  rep(i,N)rep(j,N)cin>>a[i][j];

  rep(S,1<<N){
    rep(i,N)rep(j,i){
      if(!((S>>i)&1))continue;
      if(!((S>>j)&1))continue;
      sc[S]+=a[i][j];
    }
  }

  rep(S,1<<N){
    dp[S]=sc[S];
    for(ll T=S-1;T>=0;T--){
      T&=S;
      ll _T=S^T;
      maxch(dp[S],dp[T]+dp[_T]);
    }
  }

  cout<<dp[(1<<N)-1]<<endl;

  return 0;
}


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

int a[200009];
int main()
{
  long int N, K, min = 0;
  cin>>N>>K;
  
  for (int i = 0; i<N; i++){
  	cin>>a[i];
  }
  
  sort(a, a+200009);
  reverse(a, a+200009);
    
  for (int i = 0; i<K; i++){
    a[i] = 0;
  }
  
  for(int i = 0; i<N; i++){
    min += a[i];
  }
  
  cout<<min<<endl;
  
  return 0;
}

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

#define ran 202202

int n;
pair<int, int> v[ran];

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		scanf("%d%d", &v[i].second, &v[i].first);
	}
	sort(v, v+n);
	
	int s = 0;
	for(int i=0;i<n;i++) {
		s += v[i].second;
		if(s > v[i].first) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int h,w,n;
	cin >> h >> w >> n;
	vi a;
	for(int i = 1; i <= n; i++){
		int aa; cin >> aa;
		for(int j = 0; j < aa; j++){
			a.emplace_back(i);
		}
	}

	int cnt = 0;
	for(int i = 0; i < h; i++){
		int tmp = cnt;
		for(int j = 0; j < w; j++){
			if(i%2 == 0) cout << a[cnt] << ' ';
			else{
				cout << a[tmp+w-1-j] << ' ';
			}
			cnt++;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = 998244353; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

ll mpow(ll x, ll n) { ll y = 1; for (; n > 0; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }
struct Combination {
    vector<ll> fact, ifact;
    Combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1; for (int i = 0; i < n; ++i) fact[i + 1] = fact[i] * (i + 1) % MOD;
        ifact[n] = mpow(fact[n], MOD - 2); for (int i = n; i > 0; --i) ifact[i - 1] = ifact[i] * i % MOD;
    }
    ll operator ()(int n, int k) { return k < 0 || k > n ? 0 : fact[n] * ifact[n - k] % MOD * ifact[k] % MOD; }
} C(4e3);

int main() {
    string S;
    cin >> S;
    int N = S.size();

    vector<int> bsum(N + 1);
    rep(i, N) bsum[i + 1] = bsum[i] + (S[i] - '0');

    vv<ll> memo = vvec(N + 1, N + 1, 0LL);
    memo[0][0] = 1;
    rep(i, N) {
        int bl = bsum[i] + (S[i] == '2'), bh = bsum[i] + (S[i] != '0');
        if (2 * i + 1 - bl >= i + 1) memo[i + 1][0] = memo[i][0];
        if (bh >= i + 1) memo[i + 1][i + 1] = memo[i][i];
        rep(j, 1, i + 1) {
            if (2 * i + 1 - bl >= i + 1 - j && bh >= j) {
                memo[i + 1][j] = (memo[i][j - 1] + memo[i][j]) % MOD;
            }
        }
    }

    ll ans = 0;
    rep(j, 0, N + 1) {
        if (memo[N][j]) {
            ans = (ans + memo[N][j] * C(N, bsum[N] - j)) % MOD;
        }
    }
    write(ans);
}

Measured memory_bytes: 31744
#include<bits/stdc++.h>
using namespace std;
int n, e[300010], w[300010], pe=0, pw=0;

int main(void){
    string s;
    cin >> n >> s;
    for(int i=0;i<n;++i){
        if(s[i]=='#') ++pw;
        w[i] = pw;
    }
    for(int i=n-1;i>=0;--i){
        if(s[i]=='.') ++pe;
        e[i] = pe;
    }
    int min = 800010;
    for(int i=0;i<n;++i){
        if(min > (w[i]+e[i]-1)) min = w[i]+e[i]-1;
    }
    cout << min << endl;
}


Measured memory_bytes: 2180
n=int(input())
ans=""
List=["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"]

while n>0:
    name=(n-1)%26
    ans=List[name]+ans
    n=(n-1-name)//26
    
print(ans)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,k,l,m,n,x,t,b;
    string a;
    cin>>n>>a;

    if(a.size()%2!=0){cout<<"No"<<endl;}
    else
    {
        for(i=0,j=(n/2),k=0;a[j];i++,j++)
        {
            if(a[i]!=a[j]){k=1;break;}
        }
        if(k==0){printf("Yes\n");}
        else
        {
            printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	int n,l;
	cin>>n>>l;
	vector<string>ss(n);
	for(int i=0;i<n;i++)cin>>ss[i];
	sort(ss.begin(),ss.end() );
	
	for(int i=0;i<n;i++)cout<<ss[i];
	cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define endl '\n'
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 <<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* coma = strchr(names + 1, ',');cerr.write(names, coma - names) << " : " << arg1<<" | ";__f(coma+1, args...);
}
#else
#define trace(...)
#endif
 
void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
}

const int MX = 1e5 + 5;

ll n;

ll score[MX][3], dp[MX][3];


int main(int argc, char const *argv[])
{
    // file();
    fast();

    cin>>n;

    for (int i = 0; i < n; ++i)
    {
        cin>>score[i][0]>>score[i][1]>>score[i][2];
    }

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            for (int t = 0; t < 3; ++t)
            {
                if(j != t)
                    if (i)dp[i][j] = max(dp[i][j], dp[i - 1][t] + score[i][j]);
                    else dp[i][j] = max(dp[i][j], score[i][j]);
            }
        }
    }
    cout<<max({dp[n - 1][0],dp[n - 1][1],dp[n - 1][2]});
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace I_am_an_idiot
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, k;
            string[] s;
            k = Convert.ToInt32(Console.ReadLine());
            s = Console.ReadLine().Split(' ');
            a = Convert.ToInt32(s[0]);
            b = Convert.ToInt32(s[1]);
            for (int i = 1; k * i < b + 1; ++i)
            {
                if (k * i >= a && k * i <= b)
                {
                    Console.WriteLine("OK");
                    return;
                }
            }
            Console.WriteLine("NG");
            return;
        }
    }
}

Measured memory_bytes: 17988
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

// https://atcoder.jp/contests/abc157/tasks/abc157_c
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		boolean flag = true;
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < M; i++) {
			int s = sc.nextInt();
			int c = sc.nextInt();
			if (map.containsKey(s)) {
				if (map.get(s) != c) {
					flag = false;
				}
			} else {
				if (s == 1 && c == 0 && N >= 2) {
					flag = false;
				} else {
					map.put(s, c);
				}
			}
		}
		sc.close();

		Integer[] ans = { -1, -1, -1 };
		for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
			ans[entry.getKey() - 1] = entry.getValue();
		}

		if (flag) {
			for (int i = 0; i < N; i++) {
				if (ans[i] >= 0) {
					System.out.print(ans[i]);
				} else {
					if (i == 0) {
						if (N == 1) {
							System.out.print("0");
						} else {
							System.out.print("1");
						}
					} else {
						System.out.print("0");
					}
				}
			}
//			System.out.println();

		} else {
			System.out.println(-1);
		}
	}
}

Measured memory_bytes: 21716