akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
bool ispairwise(int a[],int n){
	vector<int> v(1e6+10,0);
	for(int i=0;i<n;i++)
	v[a[i]]++;
	for(int i=2;i<=1e6;i++){
		int sum=0;
		for(int j=i;j<=1e6;j+=i){
			sum+=v[j];
		}
	//	cout<<"i="<<i<<" sum="<<sum<<endl;
		if(sum>1)
		return 0;
	}
	return 1;
}
bool issetwise(int a[],int n){
	int g=a[0];
	for(int i=1;i<n;i++){
		g=__gcd(g,a[i]);
	}
	return g==1;
}
void solve(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	if(ispairwise(a,n)){
		cout<<"pairwise coprime";
	}
	else if(issetwise(a,n)){
		cout<<"setwise coprime";
	}
	else{
		cout<<"not coprime";
	}
}
int main(){
	solve();
}


Measured memory_bytes: 11076
// #include<bits/stdc++.h>
// using namespace std;
// #define F first
// #define S second
// #define PB push_back
// #define MP make_pair
// #define REP(i,a,b) for (int i = a; i <= b; i++)

// typedef long long ll;
// typedef vector<int> vi;
// typedef pair<int,int> pii;

// int main() {
//   ios::sync_with_stdio(0);
//   cin.tie(0);
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
//   //(a + b) mod m = (a mod m + b mod m) mod m;
//   //(a - b) mod m = (a mod m - b mod m) mod m;
//   //(a * b) mod m = (a mod m * b mod m) mod m;
//   // x = x % m;
//   // if (x < 0) x += m;
// }

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	//freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  string S,T;
  cin >> S >> T;
  int count = 0;
  FOR(i, 0, S.size())
  {
    if(S[i]!=T[i])
      count++;
  }
  cout << count;
  return 0;
}

// read the question correctly (ll vs int)
// template by bqi343




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

ll a, b;

ll comp(ll x, ll y, int n) {
	//x, y, are <= n+1 digits long
	if (n == 0)
		return 1+y-x;
	if ((x >> n) == (y >> n))
		return comp(x%(1LL<<n), y%(1LL<<n), n-1);

	// cout << n << ' ' << x << ' ' << y << endl;
	int s[65];

	for (int i = 0; i < n+1; ++i) {
		s[i] = y%2;
		y/= 2;
	}

	int ind = -1;
	for (int i = n-1; i >= 0; --i) {
		if (s[i] == 1) {
			ind = i;
			break;
		}
	}

	ll t = (1LL<<(ind+1))-1;
	ll ans = 0;
	ans += (1LL<<n)-x;
	if (t < x) {
		ans += t+1+(1LL<<n)-x;
	} else {
		ans += (1LL<<n);
	}

	return ans;
}

int main() {
	cin >> a >> b;
	cout << comp(a, b, 61) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in = br.readLine().split(" ");
        long n = Long.parseLong(in[0]);
        if(n>=30) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 25356
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef pair<int, int> P;

int main() {
  int N, M; cin >> N >> M;
  map<int, vector<P>> m;
  for (int i = 0; i < M; ++i) {
    int P, Y; cin >> P >> Y;
    m[P].push_back({Y, i});
  }

  vector<P> ps(M);
  for (auto [p, v] : m) {
    sort(v.begin(), v.end());
    for (int a = 1; a <= v.size(); ++a) {
      auto [y, i] = v[a-1];
      ps[i] = {p, a};
    }
  }
  for (auto [p, i] : ps) {
    printf("%06d%06d\n", p, i);
  }
}


Measured memory_bytes: 14724
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
#define ALL(X) X.begin(), X.end()
using lint = long long;
template <typename T>
void print_container(std::vector<T> vec)
{
    for (auto iter = vec.begin(); iter != vec.end(); ++iter)
    {
        std::cout << *iter << " ";
    }
    std::cout << std::endl;
}

int main()
{
    lint n, m;

    scanf("%lld", &n);
    scanf("%lld", &m);

    lint inf = 1e9;

    lint pat_num = 1 << n;

    std::vector<lint> key_pat(pat_num, inf);
    key_pat[0] = 0;

    for (int i = 0; i < m; ++i)
    {
        lint a, b;
        scanf("%lld", &a);
        scanf("%lld", &b);

        lint key = 0;
        for (int j = 0; j < b; ++j)
        {
            lint c;
            scanf("%lld", &c);
            key += 1 << (c - 1);
        }

        for (int j = 0; j < pat_num; ++j)
        {
            lint next = j | key;
            if (next == j)
            {
                continue;
            }
            else if (key_pat[j] + a < key_pat[next])
            {
                key_pat[next] = key_pat[j] + a;
            }
        }
    }

    if (key_pat.back() == inf)
    {
        std::cout << -1 << "\n";
    }
    else
    {
        std::cout << key_pat.back() << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

const int MAX_W = 1002;
const int MAX_H = 1002;

int w, h, n;
char field[MAX_H][MAX_W];
bool G[MAX_H][MAX_W];

int bfs(pii s, pii g){
	fill_n((bool *)G, MAX_H*MAX_W, false);

	int step = 0;
	queue<pii> que;
	que.push(s);
	que.push({-1, -1});

	while(1){
		pii p = que.front(); que.pop();
		if(p.first == -1){
			if(que.empty()){
				break;
			}
			que.push(p);
			step++;
			continue;
		}
//		LOG("%d %d %c\n",p.first, p.second, field[p.second][p.first]);
		if(p == g){
			return step;
		}

		REP(i, 4){
			int sx = p.first + dx[i];
			int sy = p.second + dy[i];
			if(field[sy][sx] != 'X'){
				if (G[sy][sx] == false){
					G[sy][sx] = true;
					que.push({sx, sy});
				}
			}
		}
	}

	return -1;
}

int main() {
	(cin >> h >> w >> n);
	fill_n((char *)field, MAX_H*MAX_W, 'X');
	vector<pii> cheese(n + 1);

	REP(y, h){
		REP(x, w){
			char c;
			cin >> c;
			if(isdigit(c)){
				cheese[c-'0'] = {x + 1, y + 1};
			}else if(c == 'S'){
				cheese[0] = {x + 1, y + 1};
			}
			field[y + 1][x + 1] = c;
		}
	}

	//		REP(y, h + 2){
	//			REP(x, w + 2){
	//				cout << field[y][x];
	//			}
	//			cout << endl;
	//		}

	int res = 0;
	REP(i, n){
		int m = bfs(cheese[i], cheese[i+1]);
//		LOG("%d \n", m);
		res += m;
	}

	cout << res << endl;
}

Measured memory_bytes: 3176
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

	using i8 = std::int_least8_t;
	using i32 = std::int_least32_t;
	using i64 = std::int_least64_t;
	using u8 = std::uint_least8_t;
	using u32 = std::uint_least32_t;
	using u64 = std::uint_least64_t;
	using isize = std::ptrdiff_t;
	using usize = std::size_t;

	class rep {
		const usize f, l;

	public:
		class itr {
			friend rep;
			usize i;
			constexpr itr(const usize x) noexcept : i(x) {}

		public:
			void operator++() noexcept { ++i; }
			constexpr usize operator*() const noexcept { return i; }
			constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
		};
		constexpr rep(const usize first, const usize last) noexcept
			: f(first), l(last) {}
		constexpr itr begin() const noexcept { return itr(f); }
		constexpr itr end() const noexcept { return itr(l); }
	};
	class revrep {
		const usize f, l;

	public:
		class itr {
			friend revrep;
			usize i;
			constexpr itr(usize x) noexcept : i(x) {}

		public:
			void operator++() noexcept { --i; }
			constexpr usize operator*() const noexcept { return i; }
			constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
		};
		constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
		constexpr itr begin() const noexcept { return itr(l); }
		constexpr itr end() const noexcept { return itr(f); }
	};
	template <class T> using vec_alias = std::vector<T>;
	template <class T> auto md_vec(const usize n, const T &value) {
		return std::vector<T>(n, value);
	}
	template <class... Args> auto md_vec(const usize n, Args... args) {
		return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
	}
	template <class T> constexpr T difference(const T &a, const T &b) {
		return a < b ? b - a : a - b;
	}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>

namespace n91 {

	void main_() {
		usize n;
		std::string s;
		std::cin >> n >> s;
		usize ans = n;
		std::vector<usize> w(n + 1), b(n + 1);
		for (const auto i : rep(0, n)) {
			if (s[i] == '.') {
				w[i + 1] = w[i] + 1;
				b[i + 1] = b[i];
			}
			else {
				w[i + 1] = w[i];
				b[i + 1] = b[i] + 1;
			}
		}
		for (const auto i : rep(0, n + 1)) {
			ans = std::min(ans, b[i] + w[n] - w[i]);
		}
		std::cout << ans << std::endl;
	}

} // namespace n91

int main() {
	n91::main_();
	return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

struct UnionFind {
    // par[i]: iの親の番号　(例) par[3] = 99 : 3の親が99
    // cnt[i]: 各枝に含まれる点の個数。
    //         全部更新してるわけじゃないので、cnt[root[i]]を見に行くこと。
    vector<int> par;
    vector<int> cnt;

    UnionFind(int N) : par(N), cnt(N) {    // 初期化
        for (int i = 0; i < N; i++) {
            par[i] = i;
            cnt[i] = 1;
        }
    }

    void print() {
        for (int i = 0; i < par.size(); i++)
            printf("par[%d] = %d\n", i, par[i]);

        for (int i = 0; i < par.size(); i++)
            printf("cnt[%d] = %d\n", i, cnt[i]);
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {    // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (cnt[rx] < cnt[ry]) {
            par[rx] = ry;
            cnt[ry] += cnt[rx];
        } else {
            par[ry] = rx;
            cnt[rx] += cnt[ry];
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size() {
        int N = par.size();
        set<int> s;
        for (int i = 0; i < N; i++) {
            s.insert(root(i));
        }
        return s.size();
    }

    int count(int x) {
        return cnt[root(x)];
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vec<int> p(N);
    rep(i, N) cin >> p[i], --p[i];
    UnionFind uf(N);
    rep(i, M) {
        int x,y;
        cin >> x >> y, --x, --y;
        uf.unite(x,y);
    }

    int ans = 0;
    rep(i,N) {
        if(uf.same(i,p[i])) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if(a + b == 3){
        	System.out.println(3);}
        else if(a + b == 5) {
            System.out.println(1);}
       else {
            System.out.println(2);
       }
    }
}

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

using namespace std;

struct Dise
{
  int top;
  int bottom;
  int north;
  int east;
  int south;
  int west;
  void toNorth()
  {
    int t = top, b = bottom, n = north, s = south;
    top = s;
    bottom = n;
    north = t;
    south = b;
  }
  void toEast()
  {
    int t = top, b = bottom, e = east, w = west;
    top = w;
    bottom = e;
    east = t;
    west = b;
  }
  void toSouth()
  {
    int t = top, b = bottom, n = north, s = south;
    top = n;
    bottom = s;
    north = b;
    south = t;
  }
  void toWest()
  {
    int t = top, b = bottom, e = east, w = west;
    top = e;
    bottom = w;
    west = t;
    east = b;
  }
} d;

int main()
{
  cin >> d.top >> d.south >> d.east >> d.west >> d.north >> d.bottom;
  string o;
  cin >> o;
  for (auto &s : o)
  {
    switch (s)
    {
    case 'N':
      d.toNorth();
      break;
    case 'E':
      d.toEast();
      break;
    case 'S':
      d.toSouth();
      break;
    case 'W':
      d.toWest();
      break;
    }
  }
  cout << d.top << endl;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  for(int N, tc=1; cin >> N && N; tc++) {
    vector<double> xs, ys;
    vector<tuple<double, double, double>> squares;
    rep(i, N) {
      double x, y, r; cin >> x >> y >> r;
      xs.push_back(x-r); xs.push_back(x+r);
      ys.push_back(y-r); ys.push_back(y+r);
      squares.emplace_back(x, y, r);
    }
    sort(all(xs));
    xs.erase(unique(all(xs)), xs.end());
    sort(all(ys));
    ys.erase(unique(all(ys)), ys.end());
    map<int, double> xmp, ymp;
    int xcnt = 0, ycnt = 0;
    for(auto e: xs) xmp[xcnt++] = e;
    for(auto e: ys) ymp[ycnt++] = e;

    double ans = 0.0;
    rep(i, ycnt - 1) {
      double yl = ymp[i], yr = ymp[i + 1];
      double centy = (yl + yr) / 2.0;
      rep(j, xcnt - 1) {
        double xl = xmp[j], xr = xmp[j + 1];
        double centx = (xl + xr) / 2.0;
        bool ok = 0;
        for(auto& q: squares) {
          double sx, sy, sr; tie(sx, sy, sr) = q;
          if(   sy-sr <= centy && centy <= sy+sr
            &&  sx-sr <= centx && centx <= sx+sr) {
            ok = 1; break;
          }
        }
        if(ok) ans += (yr - yl) * (xr - xl);
      }
    }

    printf("%d %.2f\n", tc, round(ans * 100) / 100.0);
  }
  
  return 0;
}

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

int main() {
	int a, b, c, ans;
	cin >> a >> b >> c;
	ans = 0;

	for (int i = 0; i <= b; ++i) {
		if ((a*i) % b == c) {
			ans = 1;
			break;
		}
	}
	if (ans == 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
		return 0;
}

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

#define X real()
#define Y imag()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define FastF freopen("in.txt","r",stdin); freopen("out.txt","w",stdout)
#define Fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0)
using ll = long long;
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vi::iterator vii;
typedef vector<ll> vl;
typedef vl::iterator vli;
typedef long double C;
typedef complex<C> P;
const int INF = 1e9 + 5;
const ll INFF = 1e18 + 5;
const int M = 1e9 + 7;
const double pi = acos(-1);

int main()
{
	//FastF;
	//Fast;

    int N, W; cin >> N >> W;
    vi weights(N + 1);
    vi profits(N + 1);
    vl dp(W + 1, 0), temp(W + 1, 0);
    for(int i = 1; i <= N; ++i){
        cin >> weights[i] >> profits[i];
        for(int j = 1; j <= W; ++j)
            dp[j] = max(temp[j], (j < weights[i]) ? 0 : (temp[j - weights[i]] + profits[i]));
        temp = dp;
    }
    cout << dp[W] << '\n';
	return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;
  while(cin >> a >> b){
    cout << gcd(a,b)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//---------------from here-----------------

int main(){
    string s; cin>>s;
    int ans =0;
    rep(i,s.size()){
        for(int j=i; j<=s.size()-1;j++){
            int length=0;
            for(int k=i; k<=j; k++){
                if(s[k]=='A'||s[k]=='C'||s[k]=='G'||s[k]=='T'){
                    length++;
                }else{
                    length=0;
                    break;
                }
            }
            ans=max(length,ans);
        }
    }
    cout<<ans<<endl;
}

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

int a[200010];
map <int, int> mp;

int Get(int x){
	int res = 1;
	while (res <= x) res *= 2;
	return res;
}

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		mp[a[i]]++;
    }
	sort(a, a + n), reverse(a, a + n);
	int res = 0;
	for (int i = 0; i < n; i++){
//		cout << a[i] << endl;
		if (mp[a[i]] == 0) continue;
		int tot = Get(a[i]);
		mp[a[i]]--;
		if (mp.count(tot - a[i]) && mp[tot - a[i]] != 0) mp[tot - a[i]]--, res++;
    }
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 10368
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cerr << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
/*
 
 1->2->3->4
 
 */
struct edge{
    int a,b,c;
    edge(int a,int b,int c):a(a),b(b),c(c){}
};
ostream &operator<<(ostream &os, edge x){
    cout << x.a << " " << x.b << " " << x.c;
    return os;
}
int main(){
    int L;
    cin >> L;
    vector<edge>ans;
    int n = 32-__builtin_clz(L);
//    show(n);
    rep(i,n-1){
        ans.emplace_back(i+1,i+2,0);
        ans.emplace_back(i+1,i+2,1<<i);
    }
//    show(L);
    for(int i = n; i >= 0; i--){
        if(L-(1<<(n-1))>=(1<<i)){
            ans.emplace_back(i+1,n,L-(1<<i));
            L -= (1<<i);
        }
    }
    cout << n << " " << ans.size() << endl;
    for(auto &x:ans){
        cout << x << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,x,y,z;
  
    scanf("%d",&a);
    scanf("%d",&b);
    x=a+b;
    y=a-b;
    z=a*b;
    if((x<=y && z<=x)||(x<=z && z<=y)){
        printf("%d",y);
    }else if((x<=y && y<=z)||(y<=x && x<=z)){
        printf("%d",z);
    }else{
        printf("%d",x);
    }    
    // Your code here!
    
}


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

int main()
{
    int k, s;
    cin >> k >> s;
    int count = 0;
    rep(i, s + 1)
    {
        if (i > k) break;
        rep(j, s - i + 1)
        {
            if (j > k) break;
            if (s - i - j <= k) count++;
        }
    }
    cout << count << endl;
}



Measured memory_bytes: 256
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    ll s;
    cin >> s;
    vll fac(s+1, 1);
    for (int i = 2; i <= s; i++) {
        fac[i] = (i*fac[i-1])%mod;
    }
    ll ans = (s - 3 >= 0);
    for (int k = 2; s - 2*k - 1 >= (k-1); k++) {
        ll n = s - 2*k - 1;
        ll r = k - 1;
        ans += (fac[n]*(modInverse(fac[r])*modInverse(fac[n - r])%mod)%mod);
        ans %= mod;
    }
    cout << ans << "\n";
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    solve();

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
// check for edge cases in limits
// printing double may print 1.223232e9 like values, beware of that
// carefully observe simulation of test cases
// multiset erase is does not do what it is supposed to


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

using ll = long long;
using pii = pair<int, int>;

template <typename T> constexpr T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;
template <> constexpr double inf<double> = 1e18;

template<typename T>
std::vector<T> table(int n, T v) { return std::vector<T>(n, v); }
 
template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return std::vector<decltype(val)>(n, std::move(val));
}


int main() {
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for(int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    for(int i = 0; i < N; ++i) {
        cin >> b[i];
    }
    if(a == b) {
        cout << 0 << endl;
        return 0;
    }

    // [until][from][to]
    auto can_make = table(51, 51, 51, -1);
    function<int(int, int, int)> rec = [&](int until, int from, int to) {
        if(until == 0) {
            return from == to || to == 0 ? 1 : 0;
        }
        if(from < to) return can_make[until][from][to] = 0;
        if(can_make[until][from][to] != -1) {
            return can_make[until][from][to];
        }
        int res = 0;
        res |= rec(until - 1, from, to) == 1;
        res |= rec(until - 1, from % until, to) == 1;
        return can_make[until][from][to] = res;
    };

    ll ans = 0;
    vector<set<int>> now(N);
    for(int i = 0; i < N; ++i) {
        now[i].insert(a[i]);
    }
    for(int until = 50; until >= 1; until--) {
        bool check = true;
        for(int i = 0; i < N; ++i) {
            bool check2 = false;
            for(auto val : now[i]) {
                check2 |= rec(until - 1, val, b[i]) == 1;
            }
            check &= check2;
        }
        if(!check) {
            //cout << "until: " << until << endl;
            ans += (1LL << until);
            for(int i = 0; i < N; ++i) {
                auto nxt = now[i];
                for(auto val : now[i]) {
                    nxt.insert(val % until);
                }
                now[i] = move(nxt);
            }
        }
    }

    // last one
    bool last = false;
    for(int i = 0; i < N; ++i) {
        if(b[i] == 0 && now[i].count(0) == 0) {
            now[i].insert(0);
            last = true;
        }
    }
    if(last) ans += 2;

    bool ok = true;
    for(int i = 0; i < N; ++i) {
        ok &= now[i].count(b[i]);
    }
    if(ok) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        String s = in.next();
        if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5))
            System.out.println("Yes");
        else {
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 22736
#2:03

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

if A+K-1 >= B-K+1:
    for i in range(A, B+1):
        print(i)

else:
    for i in range(A, A+K):
        print(i)
    for i in range(B-K+1, B+1):
        print(i)

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

int main() {
	long long n,k,i,j,at=0,curr,curl,curm,res,jud;
	cin >> n >> k;
	vector<long long> a(n),f(n);
	for(i=0; i<n; i++){
		cin >> a[i];
		at+=a[i];
	}
	for(i=0; i<n; i++){
		cin >> f[i];
	}
	sort(a.begin(),a.end());
	reverse(a.begin(), a.end());
	sort(f.begin(),f.end());
	
	if(at<=k){
		cout << 0; return 0;
	}else{
		at-=k;
	}
	
	curl=0; curr=0;
	for(i=0; i<n; i++){
		curr=max(curr,a[i]*f[i]+1);
	}
	
	while(curr-curl>1){
		curm=(curr+curl)/2;
		jud=0; res=0; //cout << curm << ' ';
		for(i=0; i<n; i++){
			res+=min(curm/f[i],a[i]);
			
		}
		//cout << res;
		if(res>=at){
			curr=curm; //cout << "Y" << endl;
		}else{
			curl=curm; //cout << "N" << endl;
		}
	}
	cout << curr;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using plglg = pair<ll, ll>;
using tlglglg = tuple<ll, ll, ll>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    int x; cin >> x;
    if (x == 0) {
        print(1);
    } else {
        print(0);
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 100005;

int n, m, a[MAXN];
lint dx1[MAXN], dx2[MAXN];
lint ret[MAXN];

void range_add(int s, int e, int x){
	if(s > e){
		range_add(s, m-1, x);
		range_add(0, e, x + m-s);
		return;
	}
	dx1[s] += x - s;
	dx1[e+1] -= x - s;
	dx2[s] += 1;
	dx2[e+1] -= 1;
}

int main(){
	scanf("%d %d",&n,&m);
	for(int i=1; i<=n; i++){
		scanf("%d",&a[i]);
		a[i]--;
	}
	lint D = 0;
	for(int i=2; i<=n; i++){
		D += (a[i] - a[i-1] + m) % m;
		a[i-1] = (a[i-1] + 1) % m;
		range_add(a[i-1], a[i], 0);
	}
	for(int i=1; i<m; i++){
		dx1[i] += dx1[i-1];
		dx2[i] += dx2[i-1];
	}
	for(int i=0; i<m; i++) ret[i] = dx1[i] + dx2[i] * i;
	cout << D - *max_element(ret, ret + m + 1) << endl;
}


Measured memory_bytes: 2944
//be naame khodaa
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define F first
#define S second
#define pb push_back
#define sz(x) ((int)(x).size())

inline int in(){ int x, y; y = scanf("%d", &x); return x; }

const int N = 105;

bool mark[N][N];

int main(){
	int n = in();
	vector <pii> v;
	for (int i = 1; i <= n/2; i++)
		mark[i][n-i+(1-n%2)] = true;
	cout << n*(n-1)/2 - n/2 << endl;
	for (int i = 1; i <= n; i++)
		for (int j = i+1; j <= n; j++)
			if (!mark[i][j])
				cout << i << ' ' << j << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int N = s.length();
        int ans = 0;
        
        for(int i = 0; i < N/2; i++){
            if(s.charAt(i) != s.charAt(N-i-1)){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35484
/*
Till the roof comes off, till the lights go out
Till my legs give out, canâ��t shut my mouth.
Till the smoke clears out. Am I high? Perhaps
I'ma rip this shit till my bones collapse.
*/
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string.h>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#include <stack>
#include <complex>


#define ll long long
#define X real()
#define Y imag()
#define f first
#define s second
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p1,p2)             (dp(vec(p1,p2),vec(p1,p2)) < EPS)
#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define lngth(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)

using namespace std;

const int N=100005;
typedef pair<int,int>ii;
typedef pair<ii,int>event;
typedef complex<double>point;
const double EPS = 1e-9;
const int INF=100000;

const double PI = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

int n,arr[100005];

int main()
{
   // freopen("test.in","r",stdin);
   //freopen("output.txt","w",stdout);
    scanf("%d",&n);
    memset(arr,0,sizeof(arr));
    for(int i=0;i<n;i++){
        int a;
        scanf("%d",&a);
        arr[a]++;
    }
    int mx=0;
    for(int i=1;i<N-2;i++){
        mx=max(mx,arr[i-1]+arr[i]+arr[i+1]);
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 640
def main():
    import sys

    MOD = 1000000007
    N, *A = map(int, sys.stdin.buffer.read().split())
    C = [0] * (N + 1)
    C[0] = 3
    ans = 1
    for a in A:
        ans = ans * C[a] % MOD
        C[a] -= 1
        C[a + 1] += 1

    print(ans)
    return


if __name__ == '__main__':
    main()


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

using namespace std;
mt19937_64 rng(58);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s, t;
    cin >> s >> t;
    int ans = s.length();
    for (int i = 0; i <= s.length() - t.length(); i++) {
        int diff = 0;
        for (int j = 0; j < t.length(); j++) {
            if (s[i + j] != t[j]) diff++;
        }
        ans = min(diff, ans);
        // cerr << i << ", " << diff << endl;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
struct node{int p,c,l,r;};
node t[100001];
long long cost[100001];
bool alr[100001]={true};
void dfs(int now,long long nowc){
	cost[now]=nowc;
	alr[now]=true;
	if(t[now].p&&alr[t[now].p]==false) dfs(t[now].p,nowc+t[now].c);
	if(t[now].l&&alr[t[now].l]==false) dfs(t[now].l,nowc+t[t[now].l].c);
	int tmp=t[now].l;
	while(t[tmp].r){
		tmp=t[tmp].r;
		if(alr[tmp]==false) dfs(tmp,nowc+t[tmp].c);
	}
}
	
int main(){
	
	int n,a,b,c; 
	
	cin>>n;
	for(int i=0;i<n-1;i++){
		cin>>a>>b>>c;
		if(t[b].p!=0) swap(a,b);
		t[b].p=a;
		if(t[a].l) t[b].r=t[a].l;
		t[a].l=b;
		t[b].c=c;
	}
	int q,k,x,y;
	cin>>q>>k;
	dfs(k,0);
	//for(int i=0;i<=n;i++) cout<<i<<":"<<cost[i]<<endl;
	for(int i=0;i<q;i++){
		cin>>x>>y;
		cout<<cost[x]+cost[y]<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 7424
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using System.Threading;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            List<long> n = new List<long>();
            for(long i = 1; i <= N; i++)
            {
                if (i % 3 != 0 && i % 5 != 0)
                {
                    n.Add(i);
                }
            }
            Console.WriteLine(n.Sum());

        }
    }
}

//文字列の入力
//string s = Console.ReadLine();
//整数の入力
//long n = long.Parse(Console.ReadLine());
//文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');
//整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine();
//Console.ReadKey();


Measured memory_bytes: 40688
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var a=sc.Ia2;
		var r=new int[s[0]+1];
		var hs=new Dictionary<int,int>();
		hs.Add(0,1);
		long ans=0;
		for(int i = 1;i<=s[0];i++) {
			r[i]=a[i]-1;
			r[i]+=r[i-1];
			r[i]%=s[1];
			if(hs.ContainsKey(r[i])){
				ans+=hs[r[i]];
				hs[r[i]]++;
			}
			else{hs.Add(r[i],1);}
			if(i>=s[1]-1){hs[r[i+1-s[1]]]--;}
		}
		Console.WriteLine(s[1]==1?0:ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

typedef unsigned long long ll;

unsigned int a[100000];
// unsigned int b[100000];

int main()
{
	unsigned int n;
	unsigned int m, p;
	ll kari = 0;
	cin >> n;

	m = p = 0;

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

	for(unsigned int i = 0; i < n; ++i) {
		unsigned int x;
		cin >> x;
		if (x > a[i]) {
			kari += x - a[i];
			++m;
			a[i] = 0;
		} else {
			a[i] -= x;
		}
		// cerr << m << endl;
	}

	sort(a, a+n);
	ll azuke = 0;
	for(unsigned int i = n; i > 0; --i) {
		if (kari <= azuke)
			break;

		azuke += a[i-1];
		++m;
		// cerr << m << " " << azuke << endl;
	}
	int e = -1;
	if (kari <= azuke)
		cout << m << endl;
	else
		cout << e << endl;

	return 0;
}


Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  string S, T;
  cin >> S >> T;

  const int N = S.size();
  for (int i = 0; i < N; i++) {
    rotate(S.begin(), S.begin() + 1, S.end());
    if (S == T) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3540
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-06-27(Sat)
   note   
**********************************************************************/

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

int main() {
  string s, t;
  cin >> s >> t;
  int count = 0;
  int counter = s.size();
  for (int i = 0; i < counter; ++i) {
      if (s.at(i) != t.at(i)) {
          count++;
      }
  }
  cout << count << endl;
  return 0; 
}

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

using namespace std;

const int MAXN = 200200;
const int MOD = 998244353;

int N;
int dp[MAXN][3][3][2];

void add(int &x, int y) {
   x += y;
   if (x >= MOD) x -= MOD;
}

unordered_set<string> vals;

void brute(string S) {
   if (vals.count(S)) return;
   vals.emplace(S);
   for (int i = 0; i + 1 < N; ++i) {
      if (S[i] != S[i + 1]) {
         char nv = 'a' + 'b' + 'c' - S[i] - S[i + 1];
         string T = S;
         T[i] = T[i + 1] = nv;
         brute(T);
      }
   }
}

int main() {
   ios_base::sync_with_stdio(false);
   string S;
   cin >> S;
   N = S.size();
   if (N <= 7) {
      brute(S);
      cout << int(vals.size()) << "\n";
      return 0;
   }
   for (int i = 0; i < 3; ++i) {
      dp[1][i][i][0] = 1;
   }
   for (int i = 2; i <= N; ++i) {
      for (int sum = 0; sum < 3; ++sum) {
         for (int last = 0; last < 3; ++last) {
            for (int was = 0; was < 2; ++was) {
               for (int nxt = 0; nxt < 3; ++nxt) {
                  add(dp[i][(sum + nxt) % 3][nxt][was | (last == nxt)], dp[i - 1][sum][last][was]);
               }
            }
         }
      }
   }
   int sum = 0;
   bool flagDiff = true;
   bool flagSame = true;
   for (int i = 0; i < N; ++i) {
      sum += int(S[i] - 'a');
      sum %= 3;
      if (i) flagDiff &= (S[i] != S[i - 1]), flagSame &= (S[i] == S[i - 1]);
   }
   int ans = flagDiff;
   for (int i = 0; i < 3; ++i) {
      add(ans, dp[N][sum][i][1]);
   }
   if (flagSame) ans = 1;
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 14740
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)

int count(int N)
{
        int ans = 0;
        while (N)
        {
                ans++;
                N /= 10;
        }
        return ans;
}

int main()
{
        int A, B, K;
        cin >> A >> B >> K;
        int ans;
        vector<int> vec;
        int cnt = 0;
        for (int i = 1; i < min(A, B) + 1; i++)
        {
                if (A % i == 0 && B % i == 0)
                {

                        cnt++;
                        vec.push_back(i);
                }
        }
        sort(all(vec));
        reverse(all(vec));

        cout << vec[K - 1] << endl;

        return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

inline void chkmax(int& a,int b){
	if(a<b) a=b;
}

const int N=305;

char s[N];

int lim,n,f[N][N][N];

int main(){
	scanf("%s%d",s+1,&lim); n=strlen(s+1);
	for(int i=1;i<=n;++i) for(int k=0;k<=lim;++k) f[i][i][k]=1;
	for(int i=n;i>=1;--i){
		for(int j=i+1;j<=n;++j){
			for(int k=0;k<=lim;++k){
				if(k) chkmax(f[i][j][k],f[i][j][k-1]);
				chkmax(f[i][j][k],f[i][j-1][k]);
				chkmax(f[i][j][k],f[i+1][j][k]);
				if(s[i]==s[j]) chkmax(f[i][j][k],f[i+1][j-1][k]+2);
				else if(k) chkmax(f[i][j][k],f[i+1][j-1][k-1]+2);
			}
		}
	}
	printf("%d\n",f[1][n][lim]); return 0;
}

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

using namespace std;

int main()
{
    string s;
    getline(cin, s);
    int k;
    cin >> k;

    vector<string> vs;

    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 1; j <= min<int>(k, s.size() - i); j++)
        {
            vs.push_back(s.substr(i, j));
        }
    }
    sort(vs.begin(), vs.end());
    vs.erase(unique(vs.begin(), vs.end()), vs.end());

    cout << vs[k - 1] << endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n,a,f = 0;
  cin>>n;
  a = n;
  while(n!=0){
  f += n % 10;
  n /= 10;
  }
  cout << (a%f==0 ? "Yes" : "No") << endl; 
}

Measured memory_bytes: 256
N, A, B, C  = map(int, input().split())
L = [int(input()) for _ in range(N)]
INF = 10 ** 9


def dfs(cur, a, b, c):
  if cur == N:
    # -30で各Lの一回目の使用のコストを調整する。abs(a-A)で何度+-1の処理が必要かを計算する。
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  # 各Lを使うか使わないか決める
  ret0 = dfs(cur + 1, a, b, c) # 材料として使わない場合
  ret1 = dfs(cur + 1, a + L[cur], b, c) + 10 # aの材料として使う場合
  ret2 = dfs(cur + 1, a, b + L[cur], c) + 10 # bの材料として使う場合
  ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10 # cの材料として使う場合
  return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064