akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

vector<int> tree;

int Get(int v, int vleft, int vright, int pos) {
	if (vleft + 1 == vright) {
		return tree[v];
   	}

   	int vmid = (vleft + vright) / 2;
   	if (pos < vmid) {
   		return min(Get(2 * v + 1, vleft, vmid, pos), tree[v]);
   	} else {
   		return min(Get(2 * v + 2, vmid, vright, pos), tree[v]);
	}
}

void Set(int v, int vleft, int vright, int pos, int val) {
	if (vleft + 1 == vright) {
		tree[v] = val;
		return;
	}

	int vmid = (vleft + vright) / 2;
	if (pos < vmid) {
		tree[2 * v + 2] = min(tree[v], tree[2 * v + 2]);
		Set(2 * v + 1, vleft, vmid, pos, val);
	} else {
		tree[2 * v + 1] = min(tree[v], tree[2 * v + 1]);
		Set(2 * v + 2, vmid, vright, pos, val);
	}
	tree[v] = inf;
}

void Umn(int v, int vleft, int vright, int left, int right, int val) {
	if (left == vleft && right == vright) {
		tree[v] = min(tree[v], val);
		return;
	}

	int vmid = (vleft + vright) / 2;
	
	if (left < vmid) {
		Umn(2 * v + 1, vleft, vmid, left, min(right, vmid), val);
	}
	if (right > vmid) {
		Umn(2 * v + 2, vmid, vright, max(left, vmid), right, val);
	}
}

int main () {
//  ios_base::sync_with_stdio(0);
//	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);

	int n;
	scanf("%d", &n);

	vector<int> b(n);
	for (int i = 0; i < n; ++i) {
	    scanf("%d", &b[i]);
	}

	int m;
	scanf("%d", &m);
	vector<vector<int>> seg(n);
	for (int i = 0; i < m; ++i) {
		int left, right;
		scanf("%d%d", &left, &right);
		--left;
		seg[left].pb(right);
	}

    int num_0 = 0;
    for (int i = 0; i < n; ++i) {
    	num_0 += (b[i] == 0);
    }

    tree.resize(4 * (n + 1), inf);
    
    Set(0, 0, n + 1, n, 0);
    for (int i = n - 1; i >= 0; --i) {
    	Set(0, 0, n + 1, i, Get(0, 0, n + 1, i + 1) + (b[i] == 1 ? 1 : -1));
    	for (int j = 0; j < sz(seg[i]); ++j) {
    		Umn(0, 0, n + 1, i, seg[i][j], Get(0, 0, n + 1, seg[i][j]));
    	}
    }

    printf("%d\n", num_0 + Get(0, 0, n + 1, 0));

	return 0;
}


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



int main(){
	ll n,k,s;
	cin>>n>>k>>s;
	vector<ll>v;
	for(int i=0;i<k;i++)v.push_back(s);
	if(s==1e9){
		for(int i=0;i<n-k;i++)v.push_back(1);
	}else{
	  for(int i=0;i<n-k;i++)v.push_back(1e9);
	}
	for(auto x:v)cout<<x<<' ';
	return 0;
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


#define V 100005
int main(){fastio
    ll n,w;cin>>n>>w;
    ll a[n],b[n];rep(i,0,n-1)cin>>a[i]>>b[i];
    ll dp[n+1][V];rep(i,0,n)rep(j,0,V-1)dp[i][j]=inf;
    dp[0][0]=0;
    rep(i,1,n){
        rep(j,0,V-1){
            dp[i][j]=dp[i-1][j];
            if(j-b[i-1]>=0)Min(dp[i][j],dp[i-1][j-b[i-1]]+a[i-1]);
        }
    }
    /*
    rep(i,0,n){
        rep(j,0,20){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }cout<<endl;*/
    ll ans=0;
    rep(i,0,V-1){
        if(dp[n][i]<=w)Max(ans,i);
    }
    cout<<ans<<endl;
    
    return 0;
}

/*
 3 8
 3 2
 4 3
 5 4
 */


Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 
	int N;
	cin >> N;
	string S[N];
	vector<P> vec1;
	vector<pair<int, P>> vec2;
	rep(i,N){
		cin >> S[i];
		int T{}, M{};
		rep(j,S[i].size()){
			if(S[i][j] == '('){
				T++;
			}
			else{
				T--;
			}
			chmin(M, T);
		}
		if(T >= 0){
			vec1.push_back({M,T});
		}
		else{
			vec2.push_back({T-M,P(M,T)});
		}
	}
	sort(vec1.begin(), vec1.end());
	reverse(vec1.begin(), vec1.end());
	sort(vec2.begin(), vec2.end());
	reverse(vec2.begin(), vec2.end());
	int tmp = 0;
	bool ok = true;
	rep(i,vec1.size()){
		if(tmp+vec1[i].first < 0) ok = false;
		tmp += vec1[i].second;
	}
	rep(i,vec2.size()){
		if(tmp+vec2[i].second.first < 0) ok = false;
		tmp += vec2[i].second.second;
	}
	if(tmp != 0) ok = false;
	cout << (ok ? "Yes" : "No") << endl;
}

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

int main() {

    string s, t; cin >> s >> t;
    if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.*;  
import java.util.regex.Matcher;  
import java.util.regex.Pattern;  
import java.lang.*;  
import java.math.*;  
import java.io.*;  
  
import static java.lang.Math.*;  
import static java.util.Arrays.*;  
  
public class Main{  
  
 Scanner sc=new Scanner(System.in);  
  
 int INF=1<<28;  
 double EPS=1e-9;  
  
 void run(){  
  for(int n=sc.nextInt(); n>0; n--){  
   String s=sc.next();  
   Matcher m=Pattern.compile("^>'(=+)#(=+)~$").matcher(s);  
   if(m.find()){  
    if(m.group(1).length()==m.group(2).length()){  
     println("A");  
     continue;  
    }  
   }  
   m=Pattern.compile("^>\\^(Q=)+~~$").matcher(s);  
   if(m.find()){  
    println("B");  
    continue;  
   }  
   println("NA");  
  }  
 }  
  
 void debug(Object... os){  
  System.err.println(Arrays.deepToString(os));  
 }  
  
 void print(String s){  
  System.out.print(s);  
 }  
  
 void println(String s){  
  System.out.println(s);  
 }  
  
 public static void main(String[] args){  
  // System.setOut(new PrintStream(new BufferedOutputStream(System.out)));  
  new Main().run();  
 }  
}  

Measured memory_bytes: 35404
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n - 1); i >= 0; --i)
#define D(n, retu)                                                             \
  REP(i, n) { cin >> retu[i]; }
#define mod 1000000007
#define INF 93193111451418101
#define MIN -933111451418101
//#define INF 931931114518101
using namespace std;
typedef pair<ll, ll> P;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
#define yo 100001
//------------------変数-----------------------//
ll n, maxmove = 0, movesize;

//-------------------関数----------------------//

int main() {
  cin >> n;
  ll a[1001], cnt = 1, iz = 1;
  REP(i, n) {
    cin >> a[i];
    if (a[i] % 2 == 0) {
      cnt *= 2;
    }
    iz *= 3;
  }
  cout << iz - cnt << endl;

  return 0;
}


Measured memory_bytes: 256
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B, C, X, Y = get_ints

min_two = [A + B, C * 2].min

max_ab = [[A, X], [B, Y]].max { |a, b| a[1] <=> b[1] }
max_ab[0] = C * 2 if (C * 2) < max_ab[0]

puts min_two * [X, Y].min + max_ab[0] * (X-Y).abs


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

int main(){
	double a,b,c;
  	cin>>a>>b>>c;
  	double max1=max(a,b);
  	max1=max(max1,c);
  	if((a+b+c)/max1==2)cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1e5 + 10;

vector<int> x[MAXn], y[MAXn];
long long sumdeg, n, cntup, cntdown, ans;
bool flag[MAXn][2];
void dfs(int a, bool down) {
	if (down) {
		cntdown++;
		flag[a][1] = true;
		for (int i : y[a]) {
			if (!flag[i][0])
				dfs(i, 0);
		}
	}
	else {
		cntup++;
		sumdeg += x[a].size();
		flag[a][0] = true;
		for (int i : x[a]) {
			if (!flag[i][1])
				dfs(i, 1);
		}
	}
}


int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		x[a].push_back(b);
		y[b].push_back(a);
	}
	for (int i = 0; i < MAXn; i++)
		if (!flag[i][0]) {
			dfs(i, 0);
			ans += (cntdown * cntup) - sumdeg;
			cntdown = cntup = sumdeg = 0;
		}
	cout << ans;
}


Measured memory_bytes: 10240
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (long long i = 0; i < (n); ++i)
#define rep(i, a, b) for (long long i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n, t;
    cin >> n >> t;
    long long ans = 0;
    int cur = t;
    int a[n];
    REP(i, n)
    {
        cin >> a[i];
    }
    REP(i, n - 1)
    {
        ans += min(a[i + 1] - a[i], t);
    }
    ans += t;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void) {
	int h, w,dis=0,flag;
	int i,j;
	char str[110][110];

	scanf("%d %d",&h,&w);
	for (i = 0; i < h; i++)
		scanf("%s",str[i]);

	for (i = 0; i < h; i++) {
		flag = 0;
		for (j = 0; j < w; j++) {
			if (str[i][j] == 'c') {
				dis = 0;
				flag = 1;
				if(j != 0)printf(" 0");
				else printf("0");
			}
			else if(flag){
				dis++;
				if(j != 0)printf(" %d",dis);
				else printf("%d",dis);
			}
			else {
				if(j != 0)printf(" -1");
				else printf("-1");
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
    int n, ma, mb;
    cin >> n >> ma >> mb;

    vector<int> a(n), b(n), c(n);
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    vector<vector<vector<int>>> dp(n+1, vector<vector<int>>(n*10 + 1, vector<int>(n*10 + 1, INF)));// dp[items][a][b]
    dp[0][0][0] = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n*10; j++){
            for(int k=0; k<n*10; k++){
                if(dp[i][j][k] == INF) continue;

                dp[i+1][j][k]           = min(dp[i+1][j][k],           dp[i][j][k]       );
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k] + c[i]);
            }
        }
    }

    int ans = INF;
    for(int j=1; j<=n*10; j++){
        for(int k=1; k<=n*10; k++){
            if(j * mb == k * ma) ans = min(ans, dp[n][j][k]);
        }
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27264
#include <iostream>
#include <string>
using namespace std;
long long p2(int x){
    long long res = 1;
    for(int i=0;i<x;i++){
        res *= 2;
    }
    return res;
}
int main(void){
    int len;
    long long ans = 0;
    string s;
    cin >> s;
    len = s.length();
    for(int i=0;i<len;i++){
        for(int j=i+1;j<=len;j++){
            long long t = stoll(s.substr(i, j-i));
            ans += t * p2(i-1) * p2(len-j-1);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int n, x, y, pmin, pmax, mmin, mmax;
  cin >> n;
  cin >> x >> y;
  pmin = pmax = x + y;
  mmin = mmax = x - y;
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    pmin = min(pmin, x + y);
    pmax = max(pmax, x + y);
    mmin = min(mmin, x - y);
    mmax = max(mmax, x - y);
  }
  cout << max(pmax - pmin, mmax - mmin) << endl;
}

Measured memory_bytes: 3600
def main():
    n = int(input())
    for h1 in range(3500):
        h = h1 + 1
        for w1 in range(h):
            w = w1 + 1
            if (4*h*w-n*h-n*w) <= 0: continue
            aint = n*w*h//(4*h*w-n*h-n*w)
            a = n*w*h/(4*h*w-n*h-n*w)
            if aint == a:
                print(h, w, aint)
                return 0

main()

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();
        StringBuilder ans = new StringBuilder();

        for (int i = 0; i < n; i++) {
            ans.append(s.charAt(i));
            ans.append(t.charAt(i));
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 21204
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {

		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		Set<Integer> list = new HashSet<Integer>();
		for (int i = 0; i < N; i++) {
			int n = reader.nextInt();
			if (list.contains(n)) {
				list.remove(n);
			} else {
				list.add(n);
			}
		}


		System.out.print(list.size());
		reader.close();

	}

}





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

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <typename X> inline X abs(const X &a) {return a < 0 ? -a : a;}
template <typename X> inline X sqr(const X &a) {return a * a;}

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9;
const ld PI = acosl(ld(-1));

mt19937 mt(time(NULL));

const int N = 300 + 13;
int n, m;
char s[N][N];

inline bool read() {
	if (scanf ("%d%d", &n, &m) != 2)
		return false;
	forn (i, n)
		assert(scanf ("%s", s[i]) == 1);

	return true;
}

int d[N][N];
int z[2 * N][N];

inline int calc (int diff, int it)
{
	if (it == 0)
		return 0;
	return z[diff + n][it - 1];
}

inline int calc (int id)
{
	for (int diff = -n; diff <= n; diff++)
		forn (it, n)
		{
			int i1 = it;
			int i2 = it + diff;
			
			z[diff + n][it] = (it == 0 ? 0 : z[diff + n][it - 1]);
			if (i1 >= 0 && i2 >= 0 && i1 < n && i2 < n)
				z[diff + n][it] += (s[i1][id] == s[i2][id + 1]);
		}
		
	forn (i, n + 1)
		forn (j, n + 1)
			d[i][j] = INF;
			
	d[n][n] = 0;
	ford(i, n + 1)
		ford(j, n + 1)
		{
			if (!i && !j)
				continue;

			int dv = d[i][j];
			if (dv == INF)
				continue;
			
			int val = calc(j - i, i);
			
			//cerr << i << ' ' << j << ' ' << dv << ' ' << val << endl;
				
			if (i > 0)
				d[i - 1][j] = min(d[i - 1][j], dv + val);
			if (j > 0)
				d[i][j - 1] = min(d[i][j - 1], dv + val);
		}
		
	return d[0][0];
}

inline void solve() {
	int ans = 0;
	forn (i, m - 1)
		ans += calc(i);
		
	cout << ans << endl;
}

int main() {
#ifdef SU2_PROJ
	assert(freopen("input.txt", "r", stdin));
	assert(freopen("output.txt", "w", stdout));
#endif

	cout << setprecision(25) << fixed;
	cerr << setprecision(10) << fixed;
	
	assert(read());
	solve();

#ifdef SU2_PROJ
	cerr << "TIME: " << clock() << endl;
#endif
	return 0;
}

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

const int N = 2e3 + 5;

int a[N] , n , sum;

bitset <N * N> dp;

int main(void) {
    scanf("%d" , &n); dp[0] = 1;
    for(int i = 1;i <= n;++ i) scanf("%d", &a[i]) , sum += a[i], dp = dp | dp << a[i];
    int tot = 0 , all = dp.count();
    for(int i = 0;i < N * N;++ i) {
	if(dp[i]) {
	    ++ tot;
	    if(tot == all / 2 + 1) {
		cout<< i << endl;
		return 0;
	    }
	}
    }
}


Measured memory_bytes: 2176
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    VCIN(a);

    int sum = 0;
    for(int i=0; i<n; i++){
        sum += a[i];
    }

    if(h > sum){
        COUT("No");
    }else{
        COUT("Yes");
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

bool ok(string &s){
	for(auto &c : s)
		if(c != 'A' && c != 'C' && c != 'G' && c != 'T')
			return false;
	return true;
}

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	string s;
	cin >> s;
	
	int ans = 0;
	
	for(int i = 0; i < s.size(); i++)
		for(int j = i; j < s.size(); j++){
			string x = "";
			for(int k = i; k <= j; k++)
				x += s[k];
			if(ok(x))
				ans = max(ans, j - i + 1);
		}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
static const int NMAX = 100;
static const int AMAX = 1000;

int main()
{
    int N = 0;
    int A[NMAX] = {0};
    cin >> N;
    for(int i = 0 ; i < N ; i++)
    {
        cin >> A[i];
    }
    for(int m = 0 ; m < N ; m++)
	{
		cout << A[m];
		if(m == N-1)
		{
			cout << "\n";
		}
		else
		{
			cout << " ";
		}
	}
    for(int i = 1 ; i < N ; i++)
    {
        int temp = A[i];
        int j = i - 1; 
        for( ; j >= 0 && temp < A[j]; j--)
        {
            A[j+1] = A[j];
        }
        A[j+1] = temp;
        for(int m = 0 ; m < N ; m++)
		{
			cout << A[m];
			if(m == N-1)
			{
				cout << "\n";
			}
			else
			{
				cout << " ";
			}
		}
    }
	return 0;
}


Measured memory_bytes: 3056
import sys
input = sys.stdin.readline

class DSU:
    def __init__(self, n):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a, b):
        x, y = self.leader(a), self.leader(b)
        if x == y:
            return x
        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x

    def same(self, a, b):
        return self.leader(a) == self.leader(b)

    def leader(self, a):
        while self.parent_or_size[a] >= 0:
            a = self.parent_or_size[a]
        return a

    def size(self, a):
        return -self.parent_or_size[self.leader(a)]

    def groups(self):
        leader_buf = [self.leader(i) for i in range(self._n)]
        group_size = [0] * self._n
        for i in leader_buf:
            group_size[i] += 1
        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)
        result = [i for i in result if i]
        return result


n, q = map(int, input().split())
dsu = DSU(n)

for _ in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        dsu.merge(u, v)
    else:
        print(1 if dsu.same(u, v) else 0)


Measured memory_bytes: 74256
t = input()
p = input()

ok = 1
result1 = [0] * len(p); idx = 0
for i, c in enumerate(t):
    if idx < len(p) and c == p[idx]:
        result1[idx] = i
        idx += 1
if idx < len(p):
    ok = 0
result2 = [0] * len(p); idx = len(p)-1
for i in range(len(t)-1, -1, -1):
    c = t[i]
    if idx >= 0 and c == p[idx]:
        result2[idx] = i
        idx -= 1
if idx >= 0:
    ok = 0
if ok and result1 == result2:
    print("yes")
else:
    print("no")

Measured memory_bytes: 48348
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#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)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
vector<vector<int>> getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
using namespace std;
long long Manhattan_dist(long long x1, long long y1, long long x2, long long y2){return abs(x1-x2) + abs(y1-y2);}

void Out(bool ans){
	if(ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}
void OUT(bool ans){
	if(ans == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}

 unsigned long long gcd(const unsigned long long a, const unsigned long long b){
 	return (b==0) ? a : gcd(b,a%b);
 }
int main(){
	int A,B,C;
	cin >> A >> B >> C;
	OUT(C%gcd(A,B)==0);
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

llong get_max(llong A2, llong B1) {
    llong ret = A2 * B1;
    llong x = (A2 + B1) / 2;
    llong y = A2 + B1 - x;
    if (x <= A2 && B1 <= y) ret = max(ret, x * y);
    return ret;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int q;
    cin >> q;
    while (q--) {
        int a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        int s = 0, e = b - 1;
        while (s < e) {
            int m = (s + e + 1) / 2;
            if (get_max(m, a + 1) < (llong)a * b) s = m;
            else e = m - 1;
        }
        printf("%d\n", a - 1 + s);
    }
    return 0;
}

Measured memory_bytes: 256
from collections import OrderedDict

N = int(input())
X = {}
tmp1 = []
for i in range(N):
    tmp1.append(input())
    tmp2 = tmp1[i].split()
    if tmp2[0] in X:
        X[tmp2[0]].append(int(tmp2[1]))
    else:
        X[tmp2[0]] = [int(tmp2[1])]

X_sorted = OrderedDict(sorted(X.items(), key=lambda x:x[0]))
for i in X_sorted.keys():
    X_sorted[i] = sorted(X_sorted[i],reverse=True)

res = []
for i in X_sorted.keys():
    for j in range(len(X_sorted[i])):
        res.append(i+" "+str(X_sorted[i][j]))

for i in range(len(res)):
    print(tmp1.index(res[i])+1)


Measured memory_bytes: 3316
// THANK YOU MR SOLVING!!!!!!!!

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using std::sort;
using std::reverse;

using ll = long long;

#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())
#define push_back emplace_back
#define endl '\n'

class solver {
private:
    double TIME;

    static const ll INF = static_cast<ll>(1e9) + 7;
    static const int MAXN = static_cast<ll>(1e2) + 17;
    const int MAGIC = 62;

    ll a, b, c;

public:
    static bool FLAG;

    solver() {
        TIME = static_cast<double>(clock()) / CLOCKS_PER_SEC;
    }

    bool read() {
        if (!(cin >> a >> b >> c))
            return false;

        return true;
    }

    void solve() {
        forn (i, 1000000) {
            if (a % 2 || b % 2 || c % 2) {
                cout << i << endl;
                return ;
            }

            auto x = a / 2;
            auto y = b / 2;
            auto z = c / 2;
            a = y + z;
            b = x + z;
            c = x + y;
        }

        cout << -1 << endl;
    }

    ~solver() {
#ifdef SEREZHKA
        if (FLAG)
            cerr << "Time elapsed: " << static_cast<double>(clock()) / CLOCKS_PER_SEC - TIME << endl;
#endif
    }
};

bool solver::FLAG = true;

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    cerr << std::fixed << std::setprecision(5);

#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');
#else
    std::mt19937 rand(time(NULL));
#endif

    while (solver::FLAG) {
        solver solution;

        if (!solution.read())
            solver::FLAG = false;
        else
            solution.solve();
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] data = new int[5];
    int[] table = new int[5];

    for (int i = 0; i < 5; i++) {
      data[i] = sc.nextInt();
      table[i] = (10-data[i]%10)%10;
    }

    Arrays.sort(table);

    int total = 0;

    for (int i = 0; i < 5; i++) {
      total += data[i] + table[i];
    }

    System.out.println(total-table[4]);


  }

}


Measured memory_bytes: 21204
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,k = list(map(int, input().split()))

for i in range(1,k+1):
    if n-k+1 >= i:
        print(combinations_count(n-k+1,i)*combinations_count((k-i)+(i-1),(i-1)) % (10**9+7))
    else:
        print(0)

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

int main(){
  int i,j,cnt=0;
  string s;
  cin>>s;
  for(i=0;i<=7;i++){
    if(s.substr(0,i)+s.substr(s.size()-(7-i),7-i)=="keyence"){
      cout<<"YES";
      return 0;
    }
  }
  cout<<"NO";
}

Measured memory_bytes: 256
<?php
class help {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}
$input = trim(fgets(STDIN));
$alphabet = str_split('abcdefghijklmnopqrstuvwxyz');
$n = [];


for ($i=0; $i < count($alphabet); $i++) {
  if (strpos($input, $alphabet[$i]) === false) {
    $n[] = $alphabet[$i];
  }
}
if (count($n) == 0) {
  echo "None".PHP_EOL;
} else {
  sort($n);
  help::println($n[0]);
}


?>


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

struct point{double x,y;};
double X[110],Y[110];
double eps = 1e-9;
int N;
int main(){
    while(true){
        cin >> N;
        if(N==0) return 0;
        vector<point> window,curtain;
        double x,y;
        window.clear();
        curtain.clear();
        for(int i=1;i<=N;i++){
            cin >> x >> y;
            window.push_back({x,y});
            X[i] = x; Y[i] = y; 
        }
        for(int i=1;i<=4;i++){
            cin >> x >> y;
            X[N+i] = x;
            Y[N+i] = y;
            curtain.push_back({x,y});
        }
        sort(X+1,X+N+5);
        sort(Y+1,Y+N+5);
        double ans = 0;
        for(int i=1;i<=N+3;i++){
            for(int j=1;j<=N+3;j++){
                double cx = (X[i]+X[i+1])/2,cy = (Y[j]+Y[j+1])/2;
                int cnt = 0;
                for(int k=0;k<N;k++){
                    if(cx>window[k].x) continue;
                    double uy = max(window[k].y,window[(k+1)%N].y);
                    double dy = min(window[k].y,window[(k+1)%N].y);
                    if(dy<cy && cy<uy) cnt++;
                }
                if(cnt%2==0) continue;
                cnt = 0;
                for(int k=0;k<4;k++){
                    if(cx>curtain[k].x) continue;
                    double uy = max(curtain[k].y,curtain[(k+1)%4].y);
                    double dy = min(curtain[k].y,curtain[(k+1)%4].y);
                    if(dy<cy && cy<uy) cnt++;
                }
                if(cnt%2==1) continue;
                ans += (X[i+1]-X[i])*(Y[j+1]-Y[j]);
            }
        }
        cout << (int) ans << endl;
    }
}


Measured memory_bytes: 3240
#  k個t種類のケーキがある。
k,t = map(int,input().split())
# それぞれのケーキの個数リスト a
a = list(map(int,input().split()))
#print(k,t,a)

#タイプiのケーキ以外のケーキが何個あるのか調べる。
for i in range(t):
  not_i = k - 2 * a[i]
  #not_iがマイナスってことは、他のケーキの種類が足りていない。
  #逆にそれ以外のタイプのケーキにとっては、タイプiの方が多いんやから。足りてる。
  if not_i < 0:
    #一番最初の日に一番多いタイプを食べれば、１減らせる
    print(abs(not_i)-1)
    exit()
#前日と同じ奴じゃなくて済むやつしかなければ、0を出力    
print(0)  

Measured memory_bytes: 2940
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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 , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


fn main() {
    input!{n:usize, k:usize, s:i64};
    if s < 1e9 as i64 {
        for i in 0..k { print!("{} ", s); }
        for i in 0..n-k { print!("{} ", 1e9 as i64); }
    }
    else {
        for i in 0..k { print!("{} ", s); }
        for i in 0..n-k { print!("{} ", s-1); }
    }
    println!("");
}

Measured memory_bytes: 5372
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var s string

	fmt.Scan(&n)
	fmt.Scan(&s)

	if (s == strings.Repeat(s[:n/2],2)) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
	int a[5]; int i, k, q, q1;
	for (i = 0; i < 5; i++)
	{
		cin >> a[i];
	}
	cin >> k;
	q = 0; q1 = 0;
	for (int i = 0; i < 4; i++)
	{
		for (int j = i + 1; j < 5; j++)
		{
			if (a[j] - a[i] <= k)  q = 1;
			else if (a[j] - a[i] > k) q1 = 1;
		}
	}
	if (q1 == 1) cout << ":(" << endl;
	else if (q == 1)  cout << "Yay!" << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import exit, setrecursionlimit


def get_node_id(i, j, node_id_db):
    if i < j:
        return node_id_db[i][j]
    else:
        return node_id_db[j][i]


def dfs(node_id, edges, dp):
    t = dp[node_id]
    if t >= 0:
        return t
    dp[node_id] = 0
    result = 0
    for n in edges[node_id]:
        t = dfs(n, edges, dp)
        if t == 0:  # looped
            print(-1)
            exit()
        if t > result:
            result = t
    result += 1
    dp[node_id] = result
    return result


def main():
    N = int(input())
    A = [[int(e) - 1 for e in input().split()] for _ in range(N)]

    node_id_db = [[0] * N for _ in range(N)]
    v = 0
    for i in range(N):
        for j in range(i + 1, N):
            node_id_db[i][j] = v
            v += 1

    start_nodes = []
    edges = [[] for _ in range(N * (N - 1) // 2)]
    for i in range(N):
        Ai = A[i]
        from_id = get_node_id(i, Ai[0], node_id_db)
        if i < Ai[0]:
            start_nodes.append(from_id)
        for j in range(1, N - 1):
            to_id = get_node_id(i, Ai[j], node_id_db)
            edges[from_id].append(to_id)
            from_id = to_id

    dp = [-1] * (N * (N - 1) // 2)
    print(max(dfs(n, edges, dp) for n in start_nodes))


setrecursionlimit(1000000)
main()


Measured memory_bytes: 138900
#include <bits/stdc++.h>
using namespace std;
template <typename T> using V = vector<T>;

int a, b, c, d;

void calc(const string &s, int &idx, stack<int> &st) {
    if(s[idx] == '[') {
        idx++;
        calc(s, idx, st);
        calc(s, idx, st);
        int l = st.top(); st.pop();
        int r = st.top(); st.pop();
        int res;
        switch(s[idx]) {
            case '+': res = l | r; break;
            case '*': res = l & r; break;
            case '^': res = l ^ r; break;
            default: assert(false);
        }
        st.push(res);
        idx++;
        assert(s[idx] == ']');
        idx++;
    } else {
        switch(s[idx]) {
            case 'a': st.push(a); break;
            case 'b': st.push(b); break;
            case 'c': st.push(c); break;
            case 'd': st.push(d); break;
            default: assert(false);
        }
        idx++;
    }
}

void set_abcd(int num) {
    d = num % 10; num /= 10;
    c = num % 10; num /= 10;
    b = num % 10; num /= 10;
    a = num % 10; num /= 10;
}

int calc_hash(const string &s, int num) {
    set_abcd(num);
    stack<int> st;
    int idx = 0;
    calc(s, idx, st);
    return st.top();
}

bool solve() {
    string s;
    cin >> s;
    if(s == ".") return false;
    reverse(s.begin(), s.end());
    for(char &c : s) {
        if(c == ']') c = '[';
        else if(c == '[') c = ']';
    }
    int num;
    cin >> num;
    int hash = calc_hash(s, num);
    int ans = 0;
    for(int i = 0; i < 10000; i++) {
        int hash_i = calc_hash(s, i);
        ans += (hash == hash_i);
    }
    cout << hash << ' ' << ans << endl;
    return true;
}

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



Measured memory_bytes: 3160
# -*- coding: utf-8 -*-


S = input()

ans = True

if S[0] != 'A':
    ans = False
if S[2:-1].count('C') != 1:
    ans = False
if len([i for i in S if i.islower()]) != len(S) - 2:
    ans = False

print('AC' if ans else 'WA')

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

int main(){
  int a,b;
  char s;
  bool f=1;
  cin>>a>>b;
  fr(i,a){
    cin>>s;
    if(s<'0' || s>'9') f=0;
  }
  cin>>s;
  if(s!='-') f=0;
  fr(i,b){
    cin>>s;
    if(s<'0' || s>'9') f=0;
  }
  cout<<(f?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll n, d; cin >> n >> d;
   vector<pair<ll,ll>> v;
   rep(i,n){
      ll x, y; cin >> x >> y;
      v.push_back({x,y});
   }
   d *= d;
   int ans = 0;
   rep(i,n){
      ll dist = v[i].first * v[i].first + v[i].second*v[i].second;
      if (dist <= d)ans++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 7432
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>

#include<map>
#include<set>
#include<iomanip>
#include<cstdio>
#include<sstream>
#include<cstring>

#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<bitset>
#include<numeric>
#include<utility>
#include<cstdlib>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n; cin >> n;
	if(n >= 30)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

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

int main() {
  string A,B,C; cin >> A >> B >> C;
  if ( A[A.length()-1] == B[0] && B[B.length()-1] == C[0] ) {
    cout << "YES" << endl;
  }else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

#define MAX_V 100100

vector<pair<lli,lli>> G[MAX_V];
lli depth[100100];
bool vis[100100];

void func(lli now,lli nowD){
	vis[now]=true;
	depth[now]=nowD;
	for(auto e:G[now]){
		if(vis[e.first])continue;
		vis[e.first]=true;
		func(e.first,nowD+e.second);
	}
}

signed main(){

	lli n;
	cin>>n;

	REP(i,0,n-1){
		lli u,v,w;
		cin>>u>>v>>w;
		u--,v--;
		G[u].push_back(mp(v,w));
		G[v].push_back(mp(u,w));
	}

	func(0,0);
	vector<lli> ans(n);
	REP(i,0,n)cout<<depth[i]%2<<endl;

	return 0;
}

Measured memory_bytes: 10240
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

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

  ll ans = pow(3, N);

  ll sub = 1;
  REP(i, 0, N){
    int a;
    cin >> a;

    if((a % 2) == 0){
      sub *= 2;
    } else {
      sub *= 1;
    }
  }

  cout << ans - sub << endl;

  return 0;
}


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

typedef long long ll;
const int N = 1e6 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
//int dx[] = {1, 0, -1, 0};
//int dy[] = {0, 1, 0, -1}; //4 Direction
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

//-- "كلٌّ من يسعى لابد يصل .. كلٌّ من يسعى مضمون له الوصول" --//

int x , dp[N];

int a[] = {100,101,102,103,104,105};

bool solve(int idx , int remW){
	if(remW < 0)
		return 0;
	if(idx == 6){
		if(remW == 0)
			return 1;
		return 0;
	}
	int &ret = dp[remW];
	if(~ret) return ret;
	ret = solve(idx , remW-a[idx]) | solve(idx+1 , remW-a[idx]) | solve(idx+1 , remW);
	return ret;
}


int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	
	scanf("%d" , &x);
	clr(dp , -1);
	if(solve(0 , x))
		puts("1");
	else 
		puts("0");
		
	
	
    return 0;
}




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

int main(void)
{
    int N;
    ll sum = 0;
    cin >> N;

    vector<int> v(3*N);

    rep(i, 3*N){
        cin >> v[i];
    }

    sort(v.begin(),v.end(),greater<int>());

    rep(i,2*N){
        if(i%2 == 1)
            sum += v[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4572
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if(a==1&&b==0&&c==0){
cout<<"Close"<<endl;
}
else if(a==0&&b==1&&c==0){
cout<<"Close"<<endl;
}
else if(a==1&&b==1&&c==0){
cout<<"Open"<<endl;
}
else if(a==0&&b==0&&c==1){
cout<<"Open"<<endl;
}
else if(a==0&&b==0&&c==0){
cout<<"Close"<<endl;
}
         return 0;
      }

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
int main() {

	int k, i;
	char s[101];

	scanf("%d", &k);
	scanf("%s", s);

	if (strlen(s) <= k)
		printf("%s", s);

	else {
		for (i = 0; i < k; i++)
			printf("%c", s[i]);
		printf("...");
	}

	return 0;
}

Measured memory_bytes: 2100