akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main() {
    char b;
    std::cin >> b;
    if(b == 'A') std::cout << 'T' << std::endl;
    if(b == 'T') std::cout << 'A' << std::endl;
    if(b == 'C') std::cout << 'G' << std::endl;
    if(b == 'G') std::cout << 'C' << std::endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input());c=[1]*101
for i in range(2,n+1):
    for j in range(2,n+1):
        while i%j==0:i/=j;c[j]+=1
def N(M):return len([0 for x in c if x>=M])
print(N(75)+N(25)*~-N(3)+N(15)*~-N(5)+N(5)*~-N(5)//2*~-~-N(3))

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	int n;
	cin >> n;

	int a[n], b[n];

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

	for (int i = n-1; i >= 0; i--)
		cin >> b[i];

	bool swapped = true;
	int prev = -1, j;

	for (int i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			swapped = false;

			if (a[i] != prev)
				j = 0;

			for (; j < n; j++) {
				if (b[i] == b[j])
					continue;

				if (a[j] == b[i])
					continue;

				if (a[i] == b[j])
					continue;

				swap(b[i], b[j]);
				swapped = true;
				break;
			}

			if (!swapped)
				break;

			prev = a[i];
		}
	}

	if (swapped) {
		cout << "Yes" << endl;
		for (int i = 0; i < n; i++)
			cout << b[i] << " ";

	} else
		cout << "No";

	return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

string s[3];
int len[3];
bool ok[3][3][2010];

bool check(int a, int b, int i){
    for(int k=i; k<len[a] && k-i<len[b]; ++k){
        if(s[a][k] != '?' && s[b][k-i] != '?' && s[a][k] != s[b][k-i]){
            return false;
        }
    }
    return true;
}

int f(int a, int b, int c){
    int ret = mod;
    rep(i, len[a]+1)if(i >= len[a] || ok[a][b][i]){
        For(j, i, max(i+len[b], len[a])+1)if(j-i >= len[b] || ok[b][c][j-i]){
            if(j >= len[a] || ok[a][c][j]){
                chmin(ret, max({len[a], i+len[b], j+len[c]}));
            }
        }
    }
    return ret;
}

int main(){
    rep(i, 3) cin >> s[i], len[i] = s[i].size();
    rep(a, 3)rep(b, 3)if(a != b){
        rep(i, len[a]) ok[a][b][i] = check(a, b, i);
    }
    int id[3] = {0, 1, 2}, ans = mod;
    do{
        chmin(ans, f(id[0], id[1], id[2]));
    }while(next_permutation(id, id+3));
    printf("%d\n", ans);
}

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

int main()
{
	int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  	int k;
  	cin>>k;
  cout<<arr[k-1];
  return 0;
}

Measured memory_bytes: 256
s = input()
x = 0
count0 = 0
count1 = 0
for i in s:
    count0 = count0+1 if i==str(x) else count0
    x = int(not(x))
x = 1
for i in s:
    count1 = count1 + 1 if i == str(x) else count1
    x = int(not(x))
print(min(count0, count1))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <fstream>
using namespace std;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
template<class T>
void printv(vector<T> & vec) { for (T e : vec) cout << e << ' '; cout << endl; }



int main() {	
	
	int n, a, count(0);
	cin >> n;
	rep(i, n) {
		cin >> a;
		if (i % 2 == 0 && a % 2)
			count++;
	}
	cout << count << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  long i=1;
  cin >> N >> K;
  for(;N>0;N--){
    if(i<<1 > i+K)
      i+=K;
    else
      i<<=1;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc048/tasks/arc064_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

ll N, x, a, c, d, l;
int main()
{
  c = l = 0;
  cin >> N >> x;
  REP(i, N)
  {
    cin >> a;
    d = max(0ll, l + a - x);
    c += d;
    l = a - d;
  }

  cout << c << '\n';

  return 0;
}


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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int N;
vector<int> v;
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> N;
	v.resize(N-1);
	cin >> v;
	ll dp[2][10001];
	fill(dp[0], dp[1], linf);
	dp[0][1] = 0;
	REP(i, N-1) {
		fill(&dp[i+1&1][0], &dp[i+1&1][0]+10001, linf);
		FOR(j, 1, i+3) {
			int n1 = j, n2 = i+2-j;
			dp[i+1&1][j] = min(dp[i+1&1][j], dp[i&1][n1-1]);
			dp[i+1&1][j] = min(dp[i+1&1][j], dp[i&1][n2]+v[i]);
//			cout << i+1 << " " << j << " " << dp[i+1&1][j] << endl;
		}
	}
	cout << dp[(N-1)&1][N/2] << endl;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> A(N,0);
  rep(i,N) cin >> A[i];
  if(K > 2000) K = 2000;
  rep(k,K){
    vector<int> B(N+1,0);
    rep(i,N){
      int d = A.at(i);
      int s = i-d, l = i+d;
      if(s < 0) s=0;
      B.at(s)++;
      if(l < N-1) B.at(l+1)--;
    }
    for(int i =1; i < N; i++) B.at(i) += B.at(i-1);
    rep(i,N) A.at(i) = B.at(i);
  }
  
  rep(i,N) cout << A.at(i) <<' ';
  cout << endl;
  
}


Measured memory_bytes: 4816
#include <algorithm>
#include <complex>
#include <vector>
using namespace std;
const double eps = 1e-10;
#define EQ(a, b) (abs((a) - (b)) < eps)
using P = complex<double>;      // position
struct L : vector<P> {
    L(const P &a = P(), const P &b = P()) {
        emplace_back(a); emplace_back(b);
    }
};
double dot(const P &a, const P &b) { return real(conj(a) * b); }
double cross(const P &a, const P &b) { return imag(conj(a) * b); }

P project(const L &l, const P &p) {
    double t = dot(p - l[0], l[0] - l[1]) / norm(l[0] - l[1]);
    return l[0] + t * (l[0] - l[1]);
}
P reflect(const L &l, const P &p) {
    return p + (project(l, p) - p) * 2.0;
}

#include <iostream>
#include <iomanip>
int main() {
    cout << fixed << setprecision(10);
    int a, b, c, d; cin >> a >> b >> c >> d;
    L l(P(a, b), P(c, d));
    int q; cin >> q;
    while (q--) {
        int x, y; cin >> x >> y;
        P p = reflect(l, P(x, y));
        cout << p.real() << " " << p.imag() << endl;
    }
    return 0;
}


Measured memory_bytes: 3336
#include <iostream>
#include <vector>
#include <queue>

struct Point {
	int x;
	int y;
	int cost;
	bool checked;
};
bool operator > (const Point& p, const Point& q) { return p.cost > q.cost; }

int main()
{
	int n, m;
	while (true) {
		std::cin >> n >> m;
		if (n==0) break;
		char** board = new char*[m+2];
		for (int i=0; i<m+2; i++) board[i] = new char[n+2];
		for (int i=0; i<m+2; i++) { board[i][0] = board[i][n+1] = '.'; }
		for (int j=1; j<m+1; j++) { board[0][j] = board[m+1][j] = '.'; }
		for (int i=1; i<=m; i++) {
			for (int j=1; j<=n; j++) std::cin >> board[i][j];
		}
		Point** points = new Point*[m+2];
		for (int i=0; i<m+2; i++) points[i] = new Point[n+2];
		for (int i=0; i<m+2; i++) {
			for (int j=0; j<n+2; j++) {
				points[i][j].x = i;
				points[i][j].y = j;
				points[i][j].cost = m+n;
				points[i][j].checked = false;
			}
		}
		points[0][0].cost = 0;
		std::priority_queue<Point, std::vector<Point>, std::greater<std::vector<Point>::value_type> > pq;
		pq.push(points[0][0]);
		while (!pq.empty()) {
			Point p = pq.top(); pq.pop();
			// std::cout << p.x << " " << p.y << " " << p.cost << " " << p.checked << std::endl;
			points[p.x][p.y].checked = true;
			char c = board[p.x][p.y];
			if (c == '&') {
				std::cout << points[p.x][p.y].cost << std::endl; break;
			}
			if (p.x > 0) {
				if (!points[p.x-1][p.y].checked) {
					char d = board[p.x-1][p.y];
					int cost = (c == '#' && d != '#') ? 1 : 0;
					if (points[p.x-1][p.y].cost > points[p.x][p.y].cost + cost) {
						points[p.x-1][p.y].cost = points[p.x][p.y].cost + cost;
						pq.push(points[p.x-1][p.y]);
					}
				}
			}
			if (p.y > 0) {
				if (!points[p.x][p.y-1].checked) {
					char d = board[p.x][p.y-1];
					int cost = (c == '#' && d != '#') ? 1 : 0;
					if (points[p.x][p.y-1].cost > points[p.x][p.y].cost + cost) {
						points[p.x][p.y-1].cost = points[p.x][p.y].cost + cost;
						pq.push(points[p.x][p.y-1]);
					}
				}
			}
			if (p.x < m+1) {
				if (!points[p.x+1][p.y].checked) {
					char d = board[p.x+1][p.y];
					int cost = (c == '#' && d != '#') ? 1 : 0;
					if (points[p.x+1][p.y].cost > points[p.x][p.y].cost + cost) {
						points[p.x+1][p.y].cost = points[p.x][p.y].cost + cost;
						pq.push(points[p.x+1][p.y]);
					}
				}
			}
			if (p.y < n+1) {
				if (!points[p.x][p.y+1].checked) {
					char d = board[p.x][p.y+1];
					int cost = (c == '#' && d != '#') ? 1 : 0;
					if (points[p.x][p.y+1].cost > points[p.x][p.y].cost + cost) {
						points[p.x][p.y+1].cost = points[p.x][p.y].cost + cost;
						pq.push(points[p.x][p.y+1]);
					}
				}
			}
		}
		for (int i=0; i<m+2; i++) { delete[] board[i]; delete[] points[i]; }
		delete[] board; delete[] points;
	}
	return 0;
}



Measured memory_bytes: 3276
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");

		int n = Integer.parseInt(tmpArray[0]);
		int q = Integer.parseInt(tmpArray[1]);

		SqrtDecompositionRMQRAQ sq = new SqrtDecompositionRMQRAQ(n);

		for(int i = 0; i < q ; i++){
			tmpArray = br.readLine().split(" ");
			if(tmpArray[0].equals("0")){
				sq.add(Integer.parseInt(tmpArray[1]), Integer.parseInt(tmpArray[2]) + 1, Integer.parseInt(tmpArray[3]));
			}

			else {
				System.out.println(sq.findMin(Integer.parseInt(tmpArray[1]), Integer.parseInt(tmpArray[2]) + 1));
			}
		}
	}

}

class SqrtDecompositionRMQRAQ {
	int N, K;
	long[] data;
	long[] bucketAdd;
	long[] bucketMin;
	static final int sqrtN = 512;

	public SqrtDecompositionRMQRAQ(int n) {
		N = n;
		K = (N + sqrtN - 1) / sqrtN;
		data = new long[K * sqrtN];
		bucketAdd = new long[K];
		bucketMin = new long[K];
	}

	void add(int s, int t, int x) {
		for (int k = 0; k < K; ++k) {
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			if (r <= s || t <= l)
				continue;
			if (s <= l && r <= t) {
				bucketAdd[k] += x;
				bucketMin[k] += x;
			} else {
//				System.out.println("direct edit");
				for(int i = Math.max(s, l); i < Math.min(t, r); ++i) {
					data[i] += x;
				}
				bucketMin[k] = Integer.MAX_VALUE;
				for(int i = l; i < r; i++){
					bucketMin[k] = Math.min(bucketMin[k], data[i] + bucketAdd[k]);
				}
//				System.out.println("min "+ bucketMin[k]);
			}
		}
	}

	long findMin(int s, int t){
//		System.out.println("from "+s+" to "+t);
		long result = Integer.MAX_VALUE;
		for (int k = 0; k < K; ++k) {
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			if (r <= s || t <= l)
				continue;
			if (s <= l && r <= t) {

				result = Math.min(result, bucketMin[k]);
//				System.out.println("find bucket "+result);
			} else {

				for(int i = Math.max(s, l); i < Math.min(t, r); ++i) {
					result = Math.min(result, data[i] + bucketAdd[k]);
				}
//				System.out.println("find direct " + result);
			}
		}
		return result;
	}
}


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

int main(){
  int A, B;
  cin >> A >> B;
  if (10 <= A + B) {
    cout << "error" << endl;
  } else {
    cout << A + B << endl;
  }
  return 0;
}


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

dict = {'s': r, 'p': s, 'r': p}
cnt, ans = set(), 0
for i, ti in enumerate(t):
    if (i - k in cnt) and ti == t[i - k]:
        continue
    ans += dict[ti]
    cnt.add(i)
print(ans)


Measured memory_bytes: 82224
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int c[]={0,2,5,5,4,5,6,3,7,6};

int n,m;
bool can[10];
int dp[10005][5005];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	mset(dp,-1);
	
	cin>>n>>m;
	forn(i,0,m){ int x; cin>>x; can[x]=1; }
	
	dp[0][0]=0;
	fore(i,1,n){
		forn(j,1,5005){
			for(int k=9;k>=1;k--){
				if(!can[k]) continue;
				if(i-c[k]<0) continue;
				if(dp[i-c[k]][j-1]!=-1){
					dp[i][j]=k;
					break;
				}
			}
		}
	}
	
	int len=0;
	for(int i=5003;i>=0;i--){
		if(dp[n][i]!=-1){ len=i; break; }
	}
	
	int curcost=n;
	while(len){
		int x=dp[curcost][len];
		cout<<x;
		len--;
		curcost-=c[x];
	}
	
	cout<<'\n';
	
	return 0;
}


Measured memory_bytes: 195968
N = int(input())
s = []
s_ = set([])
for i in range(N):
    tmp = input()
    s.append(tmp)
    s_.add(tmp)

M = int(input())
t = []
t_ = set([])
for j in range(M):
    tmp = input()
    t.append(tmp)
    t_.add(tmp)

u = s_.union(t_)

counter = []
for factor in u:
    v = s.count(factor) - t.count(factor)
    if v < 0:
        v = 0
    counter.append(v)
    

print(max(counter))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, W, H;
  cin >> N >> W >> H;
  vector<int> x(N), y(N), w(N);
  for (int i = 0; i < N; i++){
    cin >> x[i] >> y[i] >> w[i];
  }
  vector<int> dx(W * 2 + 2, 0);
  for (int i = 0; i < N; i++){
    dx[max(x[i] * 2 - w[i] * 2, 0)]++;
    dx[min(x[i] * 2 + w[i] * 2 + 1, W * 2 + 1)]--;
  }
  vector<int> dy(H * 2 + 2, 0);
  for (int i = 0; i < N; i++){
    dy[max(y[i] * 2 - w[i] * 2, 0)]++;
    dy[min(y[i] * 2 + w[i] * 2+ 1, H * 2 + 1)]--;
  }
  for (int i = 0; i <= W * 2; i++){
    dx[i + 1] += dx[i];
  }
  for (int i = 0; i <= H * 2; i++){
    dy[i + 1] += dy[i];
  }
  bool ok1 = true;
  for (int i = 0; i <= W * 2; i++){
    if (dx[i] == 0){
      ok1 = false;
    }
  }
  bool ok2 = true;
  for (int i = 0; i <= H * 2; i++){
    if (dy[i] == 0){
      ok2 = false;
    }
  }
  if (ok1 || ok2){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 5476
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=1;
int k,n;
int a[11111],day[11111];
signed main(){
	cin>>n>>k;
	int max=0,sum=0;
	rep(i,k){
		cin>>a[i];
		max=std::max(a[i],max);
		sum+=a[i];
	}
	sum-=max;
	cout<<std::max(max-sum-1,0LL);
	
}


Measured memory_bytes: 256
l = [2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349, 15127, 24476, 39603, 64079, 103682, 167761, 271443, 439204, 710647, 1149851, 1860498, 3010349, 4870847, 7881196, 12752043, 20633239, 33385282, 54018521, 87403803, 141422324, 228826127, 370248451, 599074578, 969323029, 1568397607, 2537720636, 4106118243, 6643838879, 10749957122, 17393796001, 28143753123, 45537549124, 73681302247, 119218851371, 192900153618, 312119004989, 505019158607, 817138163596, 1322157322203, 2139295485799, 3461452808002, 5600748293801, 9062201101803, 14662949395604, 23725150497407, 38388099893011, 62113250390418, 100501350283429, 162614600673847, 263115950957276, 425730551631123, 688846502588399, 1114577054219522, 1803423556807921, 2918000611027443, 4721424167835364, 7639424778862807, 12360848946698171, 20000273725560978, 32361122672259149, 52361396397820127, 84722519070079276, 137083915467899403, 221806434537978679, 358890350005878082, 580696784543856761, 939587134549734843, 1520283919093591604]
print(l[int(input())])

Measured memory_bytes: 3064
def main():
    n = int(input())
    matrix = []
    tb = [[0] * 4 for _ in range(n + 1)]
    for _ in range(n):
        matrix.append([int(e) for e in input().split()])
    
    for i in range(1, n + 1):
        for j in range(1, 4):
            for l in range(1, 4):
                if j == l: continue
                tb[i][j] = max(tb[i][j], tb[i - 1][l] + matrix[i - 1][j - 1])
    
    print(max(tb[n]))
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 74348
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b; scanf("%d%d", &a, &b);
	
	if(a <= b) printf("%d\n", a);
	else printf("%d\n", a - 1);
	return 0;
}


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

void textIO()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}


int main()
{
    //textIO();
    fastIO();

    long long x;
    cin >> x;

    for(int a = -1000;a<=1000;a++){
        for(int b=-1000;b<=1000;b++){
            if(pow(a, 5)-pow(b,5) == x){
                cout << a << " " << b << '\n';
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 4024
#!/usr/bin/env python3
# 754

N = 753
S = input().strip()
i = 0
subs = []
while i < len(S)-2:
  sub = int(S[i:i+3])
  subs.append(sub)
  i += 1
diffs = list(map(lambda x: abs(N-x), subs))
print(min(diffs))

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

#define X first
#define Y second

const int MAXN = 1e5 + 5;
vector<int> adj[MAXN];
int sz[MAXN];
int n;

void input();
void dfs(int, int);
void solve();

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	input();
	solve();
	return 0;
}

void input() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

void dfs(int u, int par) {
	int cnt = 0;
	sz[u] = 1;
	for (auto v: adj[u]) {
		if (v == par) continue;
		dfs(v, u);
		sz[u] += sz[v];
		cnt += (sz[v] & 1);
	}
	if (cnt > 1) {
		cout << "First" << endl;
		exit(0);
	}
}

void solve() {
	if (n & 1) {
		cout << "First" << endl;
		return;
	}
	dfs(0, -1);
	cout << "Second" << endl;
}


Measured memory_bytes: 9556
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  size_t n;
  cin >> n;
  vector<int> a(n);
  cin >> a;

  size_t out = 1;
  int f = 0;
  for(size_t i = 1; i < n; ++i)
  {
    const int g = a[i] < a[i - 1] ? -1 : a[i - 1] < a[i] ? 1 : 0;
    if(f && g && f != g)
    {
      ++ out;
      DEBUG(i);
      f = 0;
    }
    else if(g)
      f = g;
  }

  cout << out;

  return EXIT_SUCCESS;
}



Measured memory_bytes: 640
/*
 * 	If you gave me a chance
 * 		I'll take it
 * 			It's a shot in the dark
 * 				But I will make it:D
 */
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifndef rd
#define endl '\n'
#endif
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#endif
#define deb cout<<"Line: "<<__LINE__<<" plz "
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=2e18;
const int infi=2e9;
const int mod=1e9+7;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
auto clk=clock();
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

void solve() {
	int n,q;
	cin>>n>>q;
	string s;
	cin>>s;
	int lo=-1,hi=n-1,mid=(lo+hi+1)/2;
	char te1,te2;
	vector<pair<char,char>> moves;
	for(int i=0; i<q; i++) {
		cin>>te1>>te2;
		moves.pb({te1,te2});
	}
//	trace(s);
	while(lo<hi) {
//		trace(lo,hi);
		int place=mid;
		bool dark=0;
		for(int i=0; i<q; i++) {
			if(s[place]==moves[i].fi) {
				if(moves[i].se=='L')
					place--;
				else
					place++;
				if(place==n) {
					break;
				}
				if(place==-1) {
					dark=1;
					break;
				}
			}
		}
		if(dark) {
			lo=mid;
		} else {
			hi=mid-1;
		}
		mid=(lo+hi+1)/2;
	}
	int ans=lo+1;
	lo=0;
	hi=n;
	mid=(lo+hi)/2;
	while(lo<hi) {
//		trace(lo,hi);
		int place=mid;
		bool dark=0;
		for(int i=0; i<q; i++) {
			if(moves[i].fi==s[place]) {
				if(moves[i].se=='R')
					place++;
				else
					place--;
				if(place==-1) {
					break;
				}
				if(place==n) {
					dark=1;
					break;
				}
			}
		}
		if(dark)
			hi=mid;
		else
			lo=mid+1;
		mid=(lo+hi)/2;
	}
	ans+=n-mid;
	cout<<n-ans<<endl;
}
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cerr<<endl<<endl<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 1172
#include <iostream>
using namespace std;
int main(void){
   int H,W;
   while(true){
       cin >> H >> W;
       if (H == 0 && W == 0){
           break;
       }
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
   }
}



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

int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  if (abs(A-B)%2 == 0) cout << abs(A-B) / 2 << endl;
  else {
    cout << min((A+B-1)/2, (N*2-A-B+1)/2) << endl;
  }
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;

int main(){
    int N;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++)
        cin >> a[i];
    int maxi=-1000000,mini=1000000;
    int ta,tb;
    for(int i=0;i<N;i++){
        if(a[i]>maxi){
            maxi=a[i];
            ta=i+1;
        }
        if(a[i]<mini){
            mini=a[i];
            tb=i+1;
        }
    }
    cout << 2*(N-1) << endl;
    int key;
    if(abs(mini)>=abs(maxi)){
        key=tb;
        for(int i=1;i<=N;i++){
            if(i!=key)
                cout << key << " " << i << endl;
        }
        for(int i=N;i>1;i--){
            cout << i << " " << i-1 << endl;
        }
    }
    else{
        key=ta;
        for(int i=1;i<=N;i++){
            if(i!=key)
                cout << key << " " << i << endl;
        }
        for(int i=1;i<N;i++){
            cout << i << " " << i+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define ALL(x)          (x).begin(), (x).end()
#define rALL(x)         (x).rbegin(), (x).rend()
#define REP(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rREP(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define FOR(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    double l; cin >> l;
    double a = l / 3.0;
    double b = l / 3.0;
    double c = l / 3.0;

    fcout << a*b*c << endl;

return 0;
}

Measured memory_bytes: 3772
<?php
list($n, $m) = ints();
$w[] = 0;
$v[] = 0;
for($i = 0; $i < $n; $i++)list($w[], $v[]) = ints();
$mv = array_sum($v)+1;
$dp = array_fill(0,$n+1,array_fill(0, $mv, 10**10));
$dp[0][0] = 0;
for($i = 1; $i <= $n; ++$i){
    $vi = $v[$i];
    $wi = $w[$i];
    $dp0 = $dp[$i-1];
    $dp1 = &$dp[$i];
    $dp1 = $dp0;
    for($j = 0; $j < $mv; ++$j){
        if($j-$v[$i] >= 0)chmin($dp1[$j], $dp0[$j-$vi] + $wi);
    }
}
$max = 0;
for($j = 0; $j < $mv; ++$j){
    if($dp[$n][$j] <= $m){
        chmax($max, $j);
    }
}
echo $max;


function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 649720
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
using P = pair<ll, ll>;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";

    }
    os << "\n";
    return os;
}

ld solve(vector<ld>& P, int N){
    /*
        区間[s,t]をiで分割する
        　　　i
        　子    子
        ・・・　・・・
        にする(今回はダミーは関節点に来ないことに注意)
    
        すると、dp[s][t] = min(dp[s][i-1] + dp[i+1][t]) + (s~tのコストの和)で表せる  (s<i<t かつ　実際の(ダミーでない)ノード)
    */
   vector<vector<ld>> dp(N,vector<ld>(N,1<<30)); 
    for(int i=0;i<N;i++) dp[i][i] = P[i]; 
    
    vector<ld> cumsum(N+1,0);
    REP(i,N) {cumsum[i+1]=cumsum[i]+P[i];}  //累積和(s~tのコストの和をO(1)で使うために)
    for(int i=2 ;i<N;i+=2){ 
        for(int left=1;left < N-i;left+=2){ // ダミー,...,ダミーを単位としてやる
            int right = left + i; //区間右端(閉)
            for(int mid = left+1; mid<right; mid+=2){ //ダミーは関節点に来ない
                chmin(dp[left][right], dp[left][mid-1] + dp[mid+1][right]); //上記の分割
            }
            dp[left][right] += cumsum[right+1]-cumsum[left];
        }
    }
    ld res = dp[1][N-1]; //1-indexに注意
    return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int L = 2*(N+1);  
    vector<ld> P(L,0);//1-index   DVDVDVDVDVDVDVDVD (D:ダミー,V:実際の)
    REP(i,N) cin >> P[2*(i+1)];
    REP(i,N+1) cin >> P[2*i+1];

    ld ans=solve(P,L);
    cout << fixed<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 18844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;
typedef vector <int> vi;
typedef pair <int, int> ii;

const int INF = (int)1e9;

#define maxn 100010
#define mod (ll) (1e9 + 9)

ll inv(ll a, ll b){
    return 1 < a ? b - inv(b % a, a) * b / a : 1;
}

int main() {
#ifdef BZ
    freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(6);

    int n, k;
    cin >> n >> k;

    vector <ii> a (n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }

    vector <vector <ll>> dp (n + 1, vector<ll> (k + 1, -INF));

    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            if (dp[i][j] != -INF and j + a[i].first <= k) {
                dp[i + 1][j + a[i].first] = max (dp[i + 1][j + a[i].first], dp[i][j] + a[i].second);
            }
            dp[i + 1][j] = max (dp[i + 1][j], dp[i][j]);
        }
    }

    ll ans = 0;
    for (int i = 0; i <= k; i++) {
        ans = max (ans, dp[n][i]);
    }

    cout << ans << "\n";

}

Measured memory_bytes: 80256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  string s;
  cin>>n>>s;
  vector<pair<char,int> > ps;
  char prev = s[0];
  int acc=1;
  repeat(i,1,n) {
      if(prev!=s[i]) {
	  ps.push_back(make_pair(prev,acc));
	  prev=s[i];
	  acc=1;
      } else {
	  acc++;
      }
  }
  ps.push_back(make_pair(prev,acc));
  int m=ps.size();
  const int inf=1e7;
  vector<int> b(m);
  vector<int> w(m);
  if(ps[0].first=='.') {
      b[0]=ps[0].second;
  } else {
      w[0]=ps[0].second;
  }
  repeat(i,1,m) {
      if(ps[i].first=='.') {
	  b[i]=min(w[i-1]+ps[i].second,b[i-1]+ps[i].second);
	  w[i]=w[i-1];
      } else {
	  // ps[i].first=='#'
	  b[i]=min(w[i-1],b[i-1]);
	  w[i]=w[i-1]+ps[i].second;
      }
  }
  cout << min(b[m-1],w[m-1]) << endl;
  return 0;
}


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

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

    int64_t N;
    cin >> N;
    int64_t ret = N - 1;
    for (int64_t i = 2; i * i <= N; i++) {
        if (N % i == 0) {
            ret = min(ret, i + N / i - 2);
        }
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int mod = 1e9+7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << ( b-a == c-b ? "YES" : "NO" ) << endl;

  return 0;
}


// EOF


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

#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;


void solve()
{

	int x, a;
	cin >> x >> a;
	if (x < a )
		cout << 0;
	else
		cout << 10;
}

int main()
{


	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	// cin >> t;
	while (t--)
	{
		solve();
	}

	return 0;
}




Measured memory_bytes: 3656
def solve(s):
    if int(s[0:2]) == 0 and int(s[2:4]) == 0:
        print("NA")
        return 0
    if int(s[0:2]) > 12 and int(s[2:4]) > 12:
        print("NA")
        return 0
    if 0 < int(s[0:2]) < 13 and 0 < int(s[2:4]) < 13:
        print("AMBIGUOUS")
        return 0
    elif 0 < int(s[2:4]) < 13:
        print("YYMM")
        return 0
    elif 0 < int(s[0:2]) < 13:
        print("MMYY")
        return 0
    else:
        print("NA")
        return 0


if __name__ == "__main__":
    S = input()
    solve(S)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;

int main()
{
	int x;

	cin >> x;
	int res = 0;

	for (int i = 1; i < 100; i++)
	{
		int ans = i;
		for (int j = 1; j < 100; j++)
		{
			ans *= i;
			if (ans <= x)
			{
				res = max(res, ans);
			}
			else {
				break;
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
struct UnionFind{
    //par[i]:iの親の番号
    vector<int> par;

    //コンストラクタ
    UnionFind(int N) : par(N){
        for(int i=0; i<N; i++) par[i] = i;
    }

    //木の根を再帰で得る
    int root(int x){
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    //xとyの木を併合
    void unite(int x, int y){
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if(rx == ry) return; //元から併合済み
        par[rx] = ry; //xの根rxをyの根ryにつける
    }

    //xとyが同じ集合（木）か否か
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main(){
    int N,M;
    cin>>N>>M;
    vector<int> p(N);
    UnionFind tree(N);
    rep(i,N){
        int a;
        cin>>a;
        a--;
        p[i]=a;
    }
    rep(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        tree.unite(a,b);
    }
    int ans=0;
    rep(i,N){
        if(tree.same(p[i],i)) ans++;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  
  int N,i,j,k,l,h;
  long x[200005],y[200005],B,b[200002],buff;
  char str[2500000],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  x[1]=atoi(p);
  for(i=2;i<N+1;i++){
   p=strtok(NULL," \n"); 
    x[i]=atoi(p);
  }
  for(i=1;i<N+1;i++){
   y[i]=x[i]; 
  }
  
  for(h=1;h<N/9;h=3*h+1);
  
  for(;h>0;h=h/3){
    for(i=h+1;i<=N;i++){
      j=i;
      while(j>=h+1 && y[j-h]<y[j]){
        buff=y[j-h],y[j-h]=y[j],y[j]=buff;
        j-=h;
      }
    }
  }
  
  B=y[N/2];
  for(i=1;i<N+1;i++){
   if(x[i]<B){
    b[i]=y[N/2]; 
   }
   if(x[i]>=B){
     b[i]=y[(N/2)+1];
   }
    printf("%ld\n",b[i]);
  }
  
  
  
 return 0; 
}

Measured memory_bytes: 7680
N, C = map(int, input().split())
d = [list(map(int, input().split())) for i in range(C)]
c = [list(map(int, input().split())) for i in range(N)]
cnt = [[0] * C for i in range(3)]
for i in range(N):
    for j in range(N):
        cnt[(i + j + 2) % 3][c[i][j] - 1] += 1
ans = float('inf')
for c1 in range(C):
    for c2 in range(C):
        if c1 == c2:
            continue
        for c3 in range(C):
            if c1 == c3 or c2 == c3:
                continue
            tmp = 0
            for i in range(3):
                for j in range(C):
                    tmp += d[j][[c1, c2, c3][i]] * cnt[i][j]
            ans = min(ans, tmp)
print(ans)


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

int main() {
  char c;
  cin >> c;
  
  if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

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

constexpr ll INF = ll(1e+18) + 1;

int main() {
    ll N;
    ll buf;
    ll sum = 0;

    cin >> N;
    vector<ll> a(N+1);
    vector<ll> b(N+1);

    rep(i, N) {
        cin >> buf;
        a[buf]++;
        b[i+1] = buf;
    }

    for (int i = 1; i <= N; i++) {
        sum += (a[i]*(a[i]-1))/2;
    }

    for (int i = 1; i <= N; i++) {
        if (a[b[i]] >= 3) {
            cout << sum - (a[b[i]]-1) << endl;
        } else if (a[b[i]] == 2) {
            cout << sum - 1 << endl;
        } else {
            cout << sum << endl;
        }
    }
    
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cout << n * (n + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    public static void Main()
    {
        var S = Console.ReadLine().ToArray();
        var T = Console.ReadLine().ToArray();
        int count = 0;
        if(S[0] == T[0])
        {
            count = count + 1;
        }
        if (S[1] == T[1])
        {
            count = count + 1;
        }
        if (S[2] == T[2])
        {
            count = count + 1;
        }

        Console.WriteLine(count);
    }

}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


long long combination(long long m, long long n){
    n = (n < m - n) ? n : m - n;
    long long c = 1;
    for(long long k = 1; k <= n; ++k){
        c = c * m / k;
        m--;
    }
    return c;
}

int N, K;
int adj[100][100];

signed main(){
    cin >> N >> K;
    if(N == 2){
        if(K == 0){
            PRINT("1");
            cout << "1 2" << ENDL; 
        }else{
            cout << "-1" << ENDL;
        }
        return 0;
    }
    ll com = combination(N - 1, 2);
    if(K > com){
        PRINT("-1");
        return 0;
    }
    REP(i, N) REP(j, N) adj[i][j] = 0;
    FOR(i, 1, N){
        adj[0][i] = 1;
    }
    int i = 1, j = 2;
    REP(k, com - K){
        while(i >= j) j++;
        adj[i][j] = 1;
        if((j + 1) % N == 0) i++;
        j = (j + 1) % N;
    }
    PRINT(com - K + N - 1);
    REP(i, N){
        REP(j, N){
            if(adj[i][j] == 1) cout << i + 1 << " " << j + 1 << ENDL;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]
 
// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }
 
// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};
 
// Functions
 
// Main
fn main(){
    input!{
        X: u64,
        A: u64,
    }
    println!("{}",if X<A{0}else{10});
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

int main() {
    ll s;
    cin >> s;
    map<ll,ll> mp;
    ll out = 0;
    ll cnt = 0;
    ll a = 0;
    while(1){
        if(cnt==0){
            a = s;
            mp.emplace(a,1);
            cnt++;
        }
        else{
            if(a%2==1) a = 3*a+1;
            else a = a/2;
            if(mp.count(a)){
                out = cnt+1;
                break;
            }else{
                mp.emplace(a,1);
                cnt++;
            }
        }
    }
    cout << out << endl;
    return 0;
}


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

int main(){
  int n, a;
  long long min=1000000, max=-1000000, sum=0;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a<min) min=a;
    if(a>max) max=a;
    sum+=a;
  }

  cout<<min<<" "<<max<<" "<<sum<<endl;

  return 0;
}

Measured memory_bytes: 3084