akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>
#include<cmath>
#include<utility>
#include<cstdlib>
#include<bitset>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iomanip>
using namespace std;                       

#define ll long long
#define pb push_back
#define mp make_pair

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const ll M = 1e9 + 7;

ll fastpo(ll a, ll x){
    if(x == 0) return 1;
    if(x == 1) return a;
    ll y = fastpo(a, x/2);
    if(x%2 == 0){
        return y*y;
    }
    return y*y*a;
}

ll inv(ll a, ll M){
    return fastpo(a, M-2);
}

ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}

ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
    if (g != 1) 
        return -1; 
    else
    { 
        ll res = (x%m + m) % m; 
        return res;
    } 
}


ll gcd(ll a, ll b){
    if(a == 0){
        return b;
    }
    return gcd(b%a, a);
}

ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}

void player1(){
    cout<<"Ashishgup"<<endl;
}

void player2(){
    cout<<"FastestFinger"<<endl;
}

bool isPrime(int n){
    if(n == 1) return false;
    for(int i=2; i*i<=n; i++){
        if(n%i == 0){
            return false;
        }
    }
    return true;
}

char pr(ll i){
    char a = 'a' + i;
    return a;
}


int main(){
//    clock_t time_req;
//     time_req = clock();
    // fastio;
    ll n;
    cin>>n;
    ll t = 26;
    ll len = 1;
    while(n > t){
        // cout<<"ä";
        n -= t;
        t *= 26;
        len++;
    }
    n--;
    string ans = "";
    for(int i=1; i<=len; i++){
        int t = (n)%26;
        ans = pr(t) + ans;
        n = (n/26);
    }
    cout<<ans<<endl;
    // time_req = clock()-time_req;
    // cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			int min, max;
			long total;

			int[] all = new int[n];

			for (int i=0; i < n; i++) {
				all[i] = sc.nextInt();
			}

			min = max = all[0]; //初期化
			total = 0; //初期化

			for (int i=0; i < n; i++) {
				total += all[i];
				min = Math.min(min, all[i]);
				max = Math.max(max, all[i]);
			}

			System.out.println(min + " " + max + " " + total);

		}
	}
}


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

int main(){
  int N, A, B;
  cin >> N >> A >> B;

  int ans = 0;
  if(A * N > B){
    ans = B;
  }else{
    ans = A * N;
  }

  cout << ans << endl;
 
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

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

    vector<int> longest;
    for (int i = 1; i < N; i++) {
        if (A[i] == A[i - 1]) {
            longest.push_back(A[i]);
            i++;
        }
        if (longest.size() == 2) {
            cout << (long long)longest[0] * longest[1] << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <assert.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <vector>

 
using namespace std;
 
typedef string str;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;




#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define trav(a, x) for (auto &a : x)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define PRINT_ARRAY(a, N)        \
  F0R(z, N) cout << a[z] << " "; \
  cout << "\n"
 
const int MOD = 1000000007;  // 998244353
const ll INF = 1e18;
const ld PI = 4 * atan((ld)1);


ll N, M;
bool vis[100005];
vi toposort;
vector<vi> AdjList(100005);

void dfs(int u) {
		vis[u] = true;
		F0R(i, (int) AdjList[u].size()) {
				int v = AdjList[u][i];
				if (!vis[v]) dfs(v);
		}
		toposort.pb(u);
}

int main() {
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		cout.tie(NULL);
		cin >> N >> M;

		F0R(i, M) {
				ll u, v;
				cin >> u >> v;
				AdjList[u-1].pb(v-1);
		}
		F0R(i, N) {
				if (!vis[i]) dfs(i);
		}

		reverse(toposort.begin(), toposort.end());

		vector<ll> d(N, -INF);

		ll ans = 0;
		for (int i = 0; i < N; i++) {
				int u = toposort[i];
				if (d[u] == -INF) {
						d[u] = 0;
				}
				for (auto v : AdjList[u]) {
					d[v] = MAX(d[v], d[u] + 1);
					ans = MAX(ans, d[v]);
				}
		}
		cout << ans << endl;

}


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

int X;

int main()
{
	cin >> X;
	if(X >= 400 && X <= 599)
		cout << 8 << endl;
	else if(X >= 600 && X <= 799)
		cout << 7 << endl;
	else if(X >= 800 && X <= 999)
		cout << 6 << endl;
	else if(X >= 1000 && X <= 1199)
		cout << 5 << endl;
	else if(X >= 1200 && X <= 1399)
		cout << 4 << endl;
	else if(X >= 1400 && X <= 1599)
		cout << 3 << endl;
	else if(X >= 1600 && X <= 1799)
		cout << 2 << endl;
	else
		cout << 1 << endl;

	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	string s;
	cin >> n >> s;
	int res = 0;
	rep (i, n - 2) if (s.substr(i, 3) == "ABC") res++;
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3640
import java.util.*;

public class Main{
    static long val = 10000000000L;
    static int n,m,x;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = Integer.parseInt(sc.next());
        m = Integer.parseInt(sc.next());
        x = Integer.parseInt(sc.next());
        int[][] a = new int[n][m];
        int[] c = new int[n];
        for(int i=0;i<n;i++){
            c[i] = Integer.parseInt(sc.next());
            for(int j=0;j<m;j++){
                a[i][j] = Integer.parseInt(sc.next());
            }
        }
        sc.close();
        int[] u = new int[m];
        int cost = 0;
        for(int i=0;i<1<<n;i++){
            cost = 0;
            Arrays.fill(u,0);
            for(int j=0;j<n;j++){
                if(((i>>j)&1)==1){
                    cost+=c[j];
                    for(int k=0;k<m;k++){
                        u[k]+=a[j][k];
                    }
                }
            }
            boolean flag = true;
            for(int k=0;k<m;k++){
                if(u[k]<x){
                    flag = false;
                    break;
                }
            }
            if(flag){
                val = Math.min(val,cost);
            }
        }
        if(val<10000000000L){
            System.out.println(val);
        }else{
            System.out.println(-1);
        }
        

    }
    
}

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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define ABS(X) ((X)<0?-(X):(X))

int main(void){
  int h,w,ans;
  int a[30][30];
  
  cin >> h >> w;
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      cin >> a[j][i];
    }
  }
  ans = 25*25*25*25*100;
  for (int i=0; i<h; i++){ // W2E
    for (int j=0; j<w; j++){ // N2S
      int tmp=0;
      for (int y=0; y<h; y++){ // (x,y): district
        for (int x=0; x<w; x++){
          if (ABS(y-i)<ABS(x-j)){
            tmp += ABS(y-i)*a[x][y];
          } else {
            tmp += ABS(x-j)*a[x][y];
          }
        }
      }
      ans = MIN(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3100
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
mx=0
for i in range(n):
    s=0
    for j in range(i,n):
        if v[j]>c[j]:
            s+=v[j]-c[j]
    mx=max(mx,s)
print(mx)

Measured memory_bytes: 3064
import math

A,B,H,M=map(int,input().split())
hx = A * math.cos(math.radians(90 - 30 * (H + M/60)))
hy = A * math.sin(math.radians(90 - 30 * (H + M/60)))
mx = B * math.cos(math.radians(90 - 6*M))
my = B * math.sin(math.radians(90 - 6*M))

print(math.sqrt((hx-mx)**2+(hy-my)**2))



Measured memory_bytes: 9568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}
// 1-indexedのBIT
struct BIT {
private:
    vector<ll> array;
    const int N;

    //左からi番目までのSUMを得る
    ll getSUM1(int i){
        ll ret = 0;
        int lsb;
        while(i >= 1){
            ret += array[i];
            lsb = i & (-i);
            i -= lsb;
        }
        return ret;
    }

public:
    // 0として初期化
    BIT(int _N) : array(_N + 1, 0), N(_N) {}

    // 左からi番目にxを加える
    void add(int i, ll x){
        int lsb;
        while(i <= N){
            array[i] += x;
            lsb = i & (-i);
            i += lsb;
        }
    }

    //左からi番目からj番目のSUMを得る
    ll getSUM(int i, int j){
        return getSUM1(j) - getSUM1(i-1);
    }
};
int main(){
    int N, Q;
    cin >> N >> Q;
    BIT bit(N);
    ll a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        bit.add(i+1, a);   
    }
    int q, l, r;    
    for (int i = 0; i < Q; i++) {
        cin >> q >> l >> r;
        if(q == 0){
            bit.add(l+1, r);
        }
        else{
            printf("%lld\n", bit.getSUM(l+1, r));
        }
    }

}

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

using namespace std;

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

    int a, b, c, d;

    cin >> a >> b >> c >> d;
    cout << (a * b > c * d ? a * b : c * d) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=998244353;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9;
const long double PI=acos(-1);



void solve(int T){
    ll n,m;
    cin>>n>>m;
    if(n==m){
        cout<<"Yes\n";
    }
    else cout<<"No\n";
}

int main() {
    //fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}


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

int main(){
    string o,e;
    cin>>o>>e;
    
    rep(i,e.length()){
        cout<<o[i]<<e[i];
    }
    if(o.length()>e.length()) cout<<o.back()<<"\n";
    return 0;
}

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

long long gcd(long long a, long long b) {
	return a == 0 ? b : gcd(b % a, a);
}

int main() {
	long long a, b;
	cin >> a >> b;

	cout << (a * b) / gcd(a, b);
	
	return 0;
}
	

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }
int abo[4];
	
int main() {
	int n,num[8];
	n=in();
	int i;
	for(i=0;i<n;i++){
		int k;
		
		for(k=0;k<8;k++)scanf("%1d",num+k);
		//for(k=0;k<8;k++)cout<<num[k]<<endl;;
		sort(num,num+8);
		int mx=0,mn=0;
		for(k=0;k<8;k++){
			mx=mx*10+num[7-k];
			mn=mn*10+num[k];
		}
		cout<<mx-mn<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(pos, len) for(int pos=0;pos<len;pos++)
#define repp(pos, len) for(int pos=1;pos<=len;pos++)

#define INF 987654321
#define IINF 2987654321987654321
#define MOD 1000000007

struct MaxFlowDinic {
	typedef long long flow_t;

	struct Edge {
		int to, ri;
		flow_t cap;
	};

	int n;
	vector<vector<Edge>> graph;
	vector<int> l, start;

	void init(int sz) {
		n = sz;
		graph.resize(n);
		for(int i = 0; i < n; i++)
			graph[i].clear();
	}
	
	void addNodes(int cnt) {
		n += cnt;
		graph.resize(n);
	}

	void addEdge(int s, int e, flow_t cap, flow_t caprev = 0) {
		Edge forward = {e, (int)graph[e].size(), cap};
		Edge reverse = {s, (int)graph[s].size(), caprev};
		graph[s].push_back(forward);
		graph[e].push_back(reverse);
	}

	bool assignLevel(int source, int sink) {
		memset(&l[0], 0, sizeof(l[0]) * l.size());
		l[source] = 1;
		queue<int> que;
		que.push(source);
		while(!que.empty() && !l[sink]) {
			int v = que.front(); que.pop();
			for(auto c : graph[v]) {
				if(c.cap == 0 || l[c.to]) continue;
				l[c.to] = l[v] + 1;
				que.push(c.to);
			}
		}
		return l[sink] != 0;
	}

	flow_t blockFlow(int v, int sink, flow_t currentFlow) {
		if(v == sink) return currentFlow;
		for(int &i = start[v]; i < (int)graph[v].size(); i++) {
			Edge &c = graph[v][i];
			if(c.cap == 0 || l[c.to] != l[v] + 1) continue;
			if(flow_t f = blockFlow(c.to, sink, min(currentFlow, c.cap))) {
				graph[v][i].cap -= f;
				graph[c.to][c.ri].cap += f;
				return f;
			}
		}
		return 0;
	}

	flow_t solve(int source, int sink) {
		l.resize(n), start.resize(n);
		flow_t maxFlow = 0;
		while(assignLevel(source, sink)) {
			memset(&start[0], 0, sizeof(start[0]) * start.size());
			while(flow_t f = blockFlow(source, sink, numeric_limits<flow_t>::max()))
				maxFlow += f;
		}
		return maxFlow;
	}
};


const int MAXN = 1e5 + 50;
int p[MAXN], q[MAXN];
int x[MAXN], y[MAXN];
int main() {
	int n; scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", &p[i]);
	for(int i = 0; i < n; i++)
		scanf("%d", &q[i]);

	int a = 0, b = 0;
	for(int i = 0; i < n; i++) {
		if(x[i]) continue;
		int cur = i;
		++a;
		while(!x[cur]) {
			x[cur] = a;
			cur = p[cur];
		}
	}
	for(int i = 0; i < n; i++) {
		if(y[i]) continue;
		int cur = i;
		++b;
		while(!y[cur]) {
			y[cur] = b;
			cur = q[cur];
		}
	}

	MaxFlowDinic mf;
	mf.init(a+b+2);
	int source = 0, sink = a+b+1, ans = n;

	for(int i = 0; i < n; i++) {
		if(p[i] == i && q[i] == i) ans--;
		else if(p[i] == i) mf.addEdge(a+y[i], sink, 1);
		else if(q[i] == i) mf.addEdge(source, x[i], 1);
		else if(p[i] != q[i]) mf.addEdge(a+y[i], x[i], 1);
		else {
			mf.addEdge(a+y[i], x[i], 1);
			mf.addEdge(x[i], a+y[i], 1);
		}
	}

	printf("%d\n", ans - mf.solve(source, sink));
}

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

int main(){
    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;

    vector<int> L1, L2;
    int last = -1e9;
    for(int i=0; i<N; i++){
        if(S[i] == 'o' && last+C < i){
            last = i;
            L1.push_back(i);
        }
        if(L1.size() == K) break;
    }
    int stock = 1e9;
    for(int i=N-1; i>=0; i--){
        if(S[i] == 'o' && stock >= C){
            L2.push_back(i);
            stock = 0;
        }else{
            stock++;
        }
        if(L2.size() == K) break;
    }

    reverse(L2.begin(), L2.end());
    for(int i=0; i<K; i++) if(L1[i] == L2[i]) cout << L1[i]+1 << endl;
    return 0;
}


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


int main (int argc, char const *argv[])
{
    int x,a,b;
    cin>>x>>a>>b;

    int A=abs(x-a);
    int B=abs(x-b);
  
    if (A<B) {
        cout<<'A'<<endl;
    }
    else
    {
        cout<<'B'<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
<?php
// Your code here!
    $num_array = str_split(fgets(STDIN));

    $sum = 0;
    foreach($num_array as $num){
        $sum += $num;
        $sum = $sum % 9;
    }
    
    if($sum){
        echo 'No';
    }else{
        echo 'Yes';
    }
    
?>

Measured memory_bytes: 28468
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <stack>
#include <math.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265
typedef pair<int, int> pii;
int main(){
long double a,b,x,i;
long double bu,ans;
cin>>a>>b>>x;
if(x>=a*a*b/2){
bu=x/(a*a); b-=bu;
ans=(long double)atan(b*2/a);
ans=ans*180/PI;

cout <<setprecision(9)<<fixed<<ans<<endl;

}else{
bu=x*2/(a*b);
//cout << b<<" "<<bu<<" "<<b/bu<<endl;
ans=(long double)atan(b/bu);

//ans = PI / 2 - atan(2*bu/b);
ans=ans*180/PI;
cout <<setprecision(9)<<fixed<<ans<<endl;

}







}


Measured memory_bytes: 256
(defun get-length (n m)
  (if (<= (/ (1- (expt 26 m)) 25) n (1- (/ (1- (expt 26 (1+ m))) 25)))
      m
      (get-length n (1+ m))))

(let* ((n (read))
       (l (get-length n 1))
       (min (/ (1- (expt 26 l)) 25))
       (m (- n min)))
  (loop :for i :from l :downto 1
        :do (multiple-value-bind (x y) (floor m (expt 26 (1- i)))
              (format t "~A" (code-char (+ 97 x)))
              (setf m y))))
(format t "~%")


Measured memory_bytes: 24652
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define Rint register int
#define FOR(i,a,b) for(register int i=(a),ed_##i=(b);i<=ed_##i;++i)
#define ROF(i,a,b) for(register int i=(a),ed_##i=(b);i>=ed_##i;--i)
typedef double DB;
inline int read(){
	reg int ans=0,f=1; reg char c=getchar();
	while(!isdigit(c)) f^=(c=='-'), c=getchar();
	for(;isdigit(c);c=getchar()) ans=(ans<<1)+(ans<<3)+(c^48);
	return f?ans:-ans;
}

const DB pi = acos(-1);
const int N = 3010;
int n, L, t[N];
DB ansx, ansy;

int main(){
	n = read(), L = read();
	FOR(i, 1, n) t[i] = read();
	reg DB x, y, res = n * (n - 1.0) * (n - 2.0) / 6.0;
	FOR(A, 1, n - 1) FOR(B, A + 1, n){
		x = cos(pi * (t[A] + t[B]) / L);
		y = sin(pi * (t[A] + t[B]) / L);
		ansx += x * (n - 2 * (B - A));
		ansy += y * (n - 2 * (B - A));
	}
	printf("%.12lf %.12lf\n", ansx / res, ansy / res);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5; int n;
const int inf = 1e6;
char c[maxN + 1];

// unordered_map<int, int> memo[maxN];
int memo[maxN][2];
int solve(int i = 0, int whites = 0, bool valid = true)
{
  if (i == n) return valid ? 0 : inf;
  if (memo[i][whites > 0] != -1) return memo[i][whites > 0];
  // if (memo[i].count(whites)) memo[i][whites];

  int ans = 0;
  if (c[i] == 'R' && whites)
  {
    ans = min(whites + solve(i + 1, 0, valid),
              1 + solve(i + 1, whites + 1, valid));
  }
  else
  {
    if (c[i] == 'R')
      ans = solve(i + 1, whites, valid);
    else
      ans = solve(i + 1, whites + 1, valid);
  }
  return memo[i][whites > 0] = ans;
  // return memo[i][whites] = ans;
}

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    // for (int i = 0; i < n; i++) memo[i].clear();
    memset(memo, -1, sizeof(memo));

    scanf(" %s", c);
    int ans = solve();

    int w = 0, r = 0;
    for (int i = 0; i < n; i++)
      if (c[i] == 'W') w++;
      else r++;

    int redToLeft = r;
    for (int i = 0; i < r; i++)
      redToLeft -= c[i] == 'R';
    int whiteToRight = w;
    for (int i = n - 1, j = 0; j < w; i--, j++)
      whiteToRight -= c[i] == 'W';
    ans = min({ans, redToLeft, whiteToRight});

    printf("%d\n", ans);
  }
  return 0;
}
// WRWWRWRR
// RRRRWWWW
// 

Measured memory_bytes: 18064
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int x, y;
	int t;

	for (;;) {
		scanf("%d%d", &x, &y);
		if (x == 0 && y == 0) break;
		if (x > y) t = x, x = y, y = t;
		printf("%d %d\n", x, y);
	}
	return 0;
}



Measured memory_bytes: 1984
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  int a, b;
  cin >> a >> b;

  if ((a + b) % 2 == 0) cout << ((a + b) / 2) << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;

int main() {
  int n;
  scanf("%d", &n);
  vi a(n + 1);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  ll res = 0;
  for (int i = 0; i < n; ++i) {
    res += a[i] / 2;
    if (a[i] % 2 && a[i+1]) {
      ++res;
      --a[i + 1];
    }
  }
  printf("%lld\n", res);
  return 0;
}

Measured memory_bytes: 640
sum = 0
A, B  = input().split(" ")
if A != int() and B != int():
    A = int(A)
    B = int(B)
    for i in range(2):
        if A > B:
            sum += A
            A -= 1
        elif B > A:
            sum += B
            B -= 1
        elif A==B:
            sum += A
            A -= 1
    print(sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
  	cin>>n;
  	vector<int> a(n), dp(n);
	for(int i = 0; i < n; ++i){
		cin>>a[i];
    }
	if(n == 1) return 0;
	dp[0] = 0, dp[1] = abs(a[1]-a[0]);
	for(int i = 2; i < n; ++i)
		dp[i] = min(abs(a[i]-a[i-1])+dp[i-1], abs(a[i]-a[i-2])+dp[i-2]);
	cout<<dp[n-1]<<"\n";
	return 0;
}

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	vector<ll> A(N+1,0);
	for(int i = 1; i <= N; ++i) cin >> A[i];
	vector<map<int,ll>> dp1(N+1); //最後にiを使ってない
	vector<map<int,ll>> dp2(N+1); //最後にiを使った
	dp1[0][0]=0;
	for(int i = 1; i <= N; ++i) {
		int M = i/2;
		for(int j = -3+M; j <= M+3; ++j) {
			dp1[i][j]=dp2[i][j]=-LOWINF;
			if(dp1[i-1].count(j)) chmax(dp1[i][j],dp1[i-1][j]);
			if(dp1[i-1].count(j-1)) chmax(dp2[i][j],dp1[i-1][j-1]+A[i]);
			if(dp2[i-1].count(j)) chmax(dp1[i][j],dp2[i-1][j]);
		}
	}
	cout << max(dp1[N][N/2],dp2[N][N/2]) << endl;
    return 0;
}


Measured memory_bytes: 198620
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to,cap,rev; 
	edge (int from, int to, int cap, int rev){
		this->from=from; this->to=to; this->cap=cap; this->rev=rev;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;


int h, w;
string s[110];
int main(){
	cin >> h >> w;
	FORI(0, h) {
		cin >> s[i];
	}
	FORI(0, h) {
		cout << s[i] << endl;
		cout << s[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    cout << "square1001" << endl;
    return 0;
}


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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;
const double PI = acos(-1);

int a, b, x;

double f(double m) {
    double rad = m / 180.0 * PI;
    double y = b / tan(rad);
    if (y <= a) {
        return y * b * a / 2.0;
    } else {
        return ((y - a) * tan(rad) + b) * a * a / 2.0;
    }
}

int main(){
    cin >> a >> b >> x;

    double l = 0.0, r = 90.0;
    rep(_, 10000) {
        double mid = (l + r) / 2.0;

        if (f(mid) < x) {
            r = mid;
        } else {
            l = mid;
        }
    }

    cout << fixed << setprecision(10) << l << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s;
int main(){
	cin>>s;
	if(!(s[0]=='1'&&s[s.size()-2]=='1'&&s[s.size()-1]=='0')){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=1;i<s.size()/2;i++){
		if(s[i]!=s[s.size()-2-i]){
			cout<<-1<<endl;
			return 0;
		}
	}
	int t=s.size()/2;
	for(int i=s.size()/2-1;i>=0;i--){
		cout<<i+1<<" "<<t+1<<endl;
		if(s[i]=='1'){
			t=i;
		}
	}
	for(int i=s.size()/2+1;i<s.size();i++){
		cout<<s.size()/2+1<<" "<<i+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
int main()
{
    ll a[200009];
    ll x=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) {cin>>a[i]; x=x^a[i];}
    for(int i=1;i<=n;i++) cout<<(x^a[i])<<" ";
}



Measured memory_bytes: 5148
N, M = map(int, input().split())
A = [0] * N
for i in range(N):
    A[i] = int(input())

for i in range(1, M+1):
    if i == 1:
        continue
    else:
        for j in range(N-1):
            if (A[j] % i) > (A[j+1] % i):
                tmp_val = A[j]
                A[j] = A[j+1]
                A[j+1] = tmp_val

for i in range(N):
    print(A[i])


Measured memory_bytes: 5612
#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);
    rep(i, n) cin >> A[i];
    int dp[202020] = {0};
    rep(i, k + 1) {
        rep(j, n) if(i - A[j] >= 0 && dp[i - A[j]] == 0) dp[i] = 1;
    }
    cout << (dp[k] ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 1024
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n;
  cin>>n;
  
  if(n==0){
    cout<<0<<endl;
    return 0;
  }
  
  vector<int> A;
  while(n!=0){
    if(abs(n)%2==1){
      A.push_back(1);
      n=-(n-1)/2;
    }
    else{
      A.push_back(0);
      n=-n/2;
    }
  }
  reverse(ALL(A));
  rep(i,A.size()) cout<<A[i];
  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 3632
n=int(input())
if 400<=n<600:
    print(8)
elif 600<=n<800:
    print(7)
elif 800<=n<1000:
    print(6)
elif 1000<=n<1200:
    print(5)
elif 1200<=n<1400:
    print(4)
elif 1400<=n<1600:
    print(3)
elif 1600<=n<1800:
    print(2)
elif 1800<=n<2000:
    print(1)


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

using namespace std;

int main()
{
	char c;
	scanf("%c", &c);
	
	map<char, int> m;
	
	m['a'] = 1;
	m['e'] = 1;
	m['i'] = 1;
	m['o'] = 1;
	m['u'] = 1;
	
	if(m[c])
		printf("vowel\n");
	else
		printf("consonant\n");
	
	return 0;
}

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


S = []
sum = 0
for i in range(N):
    sum += A[i]
    S.append(sum)

ans = 0
for i in range(N):
    ans += A[i] * (S[N-1] - S[i])

print(int(ans % (10**9 + 7)))

Measured memory_bytes: 31352
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <algorithm>
#include <ctime>
#include <cctype>
#include <cmath>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <map>
#include <set>
#define sqr(x) ((x)*(x))
#define PI 3.1415926535897932384626
#define jue(x) (x>0?x:-x)
 
#define maxm 
#define maxn 1010
using namespace std;

int flag[10];
int num[10];

void dfs(int x){
	flag[x] = 1;
	for(int i = x + 1; i < 10; i++){
		if(num[i] > num[x]){
			dfs(i);
			break;
		}
	}
}

int main(){
	int n, res;
	while(scanf("%d", &n) == 1){
		while(n > 0){
			n--;
			res = 0;
			for(int i = 0; i < 10; i++){
				scanf("%d", &num[i]);
			}
			for(int i = 0; i < 10; i++){
				memset(flag, 0, sizeof flag);
				dfs(0);
				int numm[10], x = 0, y = 1;
				for(int j = 0; j < 10; j++){
					if(!flag[j]){
						numm[x++] = num[j];
					}
				}
				for(int j = 1; j < x; j++){
					if(numm[j - 1] >= numm[j]){
						y = 0;
					}
				}
				res = y;
				if(res) continue;
			}
			if(res){
				printf("YES\n");
			} else {
				printf("NO\n");
			}	
		}
	}
	return 0;
}

Measured memory_bytes: 3104
import scala.io.StdIn.readLine

object Main {
  def getIndex(s:String) = s match {
    case "Rock" => 0 case "Fire" => 1 case "Scissors" => 2 case "Snake" => 3
    case "Human" => 4 case "Tree" => 5 case "Wolf" => 6 case "Sponge" => 7
    case "Paper" => 8 case "Air" => 9 case "Water" => 10 case "Dragon" => 11
    case "Devil" => 12 case "Lightning" => 13 case "Gun" => 14
  }
  val gestures = Array("Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning", "Gun")

  def scan(list:Array[Int],i:Int,n:Int):String = {
    if(i==n) "Draw"
    else {
      val win = (list((i+1)%n)-list(i)+15)%15
      val j = if(i>0) i-1 else n-1
      val lose = (list(i)-list(j)+15)%15
      if(win<=7 && lose>7) gestures(list(i))
      else scan(list,i+1,n)
    }
  }

  def main(args:Array[String]) = {
    var n = 0
    while({n=readLine.trim.toInt;n}!=0) {
      val list = {for(i<-1 to n) yield getIndex(readLine.trim)}.toArray.sorted
      println(scan(list,0,list.length))
    }
  }
}

Measured memory_bytes: 56504
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007
int32_t main() 
{
    fast;
    char c;
    cin>>c;
    cout<<(char)(c+1);
    
}

Measured memory_bytes: 256
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int N; cin >> N;
    int ans = 0;
    rep(i,0,N) {
        int l, r; cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		int[] r = new int[101];
		
		Scanner cin = new Scanner(System.in);
		int N = cin.nextInt();
		
		for (int i=0; i<N; i++) {
			int x = cin.nextInt();
			r[x]++;
		}

		int ans = 0;
		for (int i=100; i>=1; i--) {
			if (r[i] != 0) {
				ans++;
//				System.out.println(i + ":"+ r[i]);
			}
		}

		System.out.println(ans);
		
		cin.close();
	}

}

Measured memory_bytes: 25044
#include <iostream>
using namespace std;
int main()
{
    float a,b;
    int a1,b1;
    cin>>a>>b;
    a1=a;
    b1=b;
    if ((a+b)/2-(a1+b1)/2 >= 0.5)
    {
        cout<<(a1+b1)/2+1;
    }
    else
    {
        cout<<(a1+b1)/2;
    }
    return 0;
}

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

#define ll long long 
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()

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

	int n; cin >> n;
	string s;
	int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
	for(int i = 0; i < n; i++) {
		cin >> s;
		if(s == "AC") c1++;
		if(s == "WA") c2++;
		if(s == "TLE") c3++;
		if(s == "RE") c4++;
	}

	cout << "AC x " << c1 << "\n";
	cout << "WA x " << c2 << "\n";
	cout << "TLE x " << c3 << "\n";
	cout << "RE x " << c4 << "\n";
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4 + 7;
const double pi = acos(-1);
const int mod = 100007;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
struct node{
	int a,b,c,d;
}t[60]; 
int n,m,q,ans,a[20];

void dfs(int nw,int st){
	if(nw > n){
		int res = 0;
		for(int i = 1;i <= q;++i){
			if(a[t[i].b] - a[t[i].a] == t[i].c)
				res += t[i].d;
		}
		ans = max(ans,res);
		return ;
	}
	for(int i = st;i <= m;++i){
		a[nw] = i;
		dfs(nw+1,i);
	}
	return ;
}
int main(){
	cin >> n >> m >> q;
	for(int i = 1;i <= q;i++){
		scanf("%d %d %d %d",&t[i].a,&t[i].b,&t[i].c,&t[i].d);
	}
	ans = 0;
	dfs(1,1);
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3828
def main():
    A,B,C=map(int,input().split())
    X=[A,B,C]
    X.sort()
    if X[0]==X[2]:
        print(0)
    elif X[0]==X[1]:
        print(X[2]-X[1])
    elif X[1]==X[2]:
        if (X[1]-X[0])%2==1:
            print((X[1]-X[0])//2+2)
        else:
            print((X[1]-X[0])//2)
    else:
        if (X[1]-X[0])%2==0:
            print((X[2]-X[1])+(X[1]-X[0])//2)
        else:
            print((X[2]-X[1])+(X[1]-X[0])//2+2)

if __name__ == '__main__':
    main()


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

int main() {
    int n, c;
    cin >> n >> c;
    
    vector<vector<pair<int, int>>> p(c, vector<pair<int, int>>());
    for (int i = 0; i < n; i++)
    {
        int s, t, c;
        cin >> s >> t >> c;
        c--;
        p.at(c).push_back(make_pair(s, t));
    }
    
    
    vector<vector<bool>> table(c, vector<bool>(100001));
    for (int i = 0; i < c; i++)
    {
        sort(p.at(i).begin(), p.at(i).end());
        if ((int)p.at(i).size() == 1) {
            for (int k = p.at(i).at(0).first - 1; k <= p.at(i).at(0).second - 1; k++) table.at(i).at(k) = true;
        }
        
        for (int j = 0; j < (int)p.at(i).size() - 1; j++)
        {
            if (p.at(i).at(j).second == p.at(i).at(j + 1).first) {
                for (int k = p.at(i).at(j).first - 1; k <= p.at(i).at(j + 1).second - 1; k++)
                {
                    table.at(i).at(k) = true;
                }
            }
            else {
                for (int k = p.at(i).at(j).first - 1; k <= p.at(i).at(j).second - 1; k++)
                {
                    table.at(i).at(k) = true;
                }
                
                if (j == (int)p.at(i).size() - 2) {
                    for (int k = p.at(i).at(j + 1).first - 1; k <= p.at(i).at(j + 1).second - 1; k++)
                    {
                        table.at(i).at(k) = true;
                    }
                    
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i <= 100000; i++)
    {
        int cnt = 0;
        for (int j = 0; j < c; j++)
        {
            if (table.at(j).at(i)) cnt++;
        }
        ans = max(ans, cnt);
    }
    
    cout << ans << endl;
}


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

const int N = 2010;

struct edge {
    int to, next;
} e[N * 2];

int head[N], ecnt;

inline void adde(int from, int to) {
    e[++ecnt] = (edge){to, head[from]}, head[from] = ecnt;
    e[++ecnt] = (edge){from, head[to]}, head[to] = ecnt;
}

// sum: 子树内棋子个数 dp: 子树内最少操作步数
int sum[N], dp[N];

int val[N];

void dfs(int u, int f) {
    sum[u] = val[u], dp[u] = 0;
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != f) {
            dfs(e[i].to, u);
            sum[u] += sum[e[i].to], dp[u] += dp[e[i].to] + sum[e[i].to];
        }
}

// 子树的最小剩余深度
int dfs2(int u, int f) {
    int mx = 0;
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != f) 
            if (dp[e[i].to] >= dp[mx]) 
                mx = e[i].to;
    if (!mx) return 0;
    int tmp = dfs2(mx, u) + sum[mx];
    if (dp[u] - dp[mx] - sum[mx] >= tmp) return dp[u] & 1;
    return tmp - (dp[u] - dp[mx] - sum[mx]);
}

char s[N];

int main() {
    int n; scanf("%d%s", &n, s + 1);
    for (int i = 1; i <= n; i++) val[i] = s[i] == '1';
    for (int i = 1, a, b; i < n; i++) scanf("%d%d", &a, &b), adde(a, b);
    int res = 1e9;
    for (int i = 1; i <= n; i++) {
        dfs(i, 0);
        if (!dfs2(i, 0)) res = min(res, dp[i] / 2);
    }
    if (res < 1e8) printf("%d\n", res);
    else puts("-1");
    return 0;
}


Measured memory_bytes: 384
import math

A,B = [int(i) for i in input().split(" ")]

def check(A,B):
    for i in range(0,A*8+B*10):
        ans1 = i * 0.08
        ans2 = i * 0.1
        if int(ans1) == A and int(ans2) == B:
            return i
    return -1

print(check(A,B))

Measured memory_bytes: 3060
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,l,pie=0,min_l=10000000,ans=10000000,tmp;
  cin >> n >> l;
  for(int i=0;i<n;i++){
    pie += l+i;
  }
  for(int i=0;i<n;i++){
    tmp = pie - (l+i);
    if(abs(tmp-pie)<min_l){
      ans = tmp;
      min_l = abs(tmp-pie);
    }
  }
  cout << ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){

	int n;
	cin >> n;
	vector<int> a(n+1, 0);
	vector<bool> f(n, false);
	for(int i=0; i<n; i++) cin >> a[i];

	int cnt = 0;
	for(int i=0; i<n; i++){
		if( !f[i] && a[ a[i]-1 ] == i+1 ){
			f[ a[i]-1 ] = true;
			cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#undef NDEBUG
#include <cassert>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>

using namespace std;

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define pbk pop_back
#define sz(s) ((int) (s).size())
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL42
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif
#define prev huprev
#define next hunext
#define link hulink
#define hash huhash
#define rank hurank
#define y0 yy0
#define y1 yy1

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = 1e9;
const double eps = 1e-9;
const double pi = 4 * atan(1.0);
const int N = 111;

int a[N];

int main() {
#ifdef LOCAL42
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    for (int i = 0; i < 2 * n; ++i) {
        scanf("%d", a + i);
    }
    sort(a, a + 2 * n);
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += a[2 * i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tuple>
using namespace std;

#include <sys/mman.h>
static char *_in_buf = 
(char*)mmap(NULL, 1 << 26, PROT_READ, MAP_PRIVATE, fileno(stdin), 0);
inline int read() {
  int p = 0, v = 0;
  while (*_in_buf < 48) (*_in_buf ++ == 45) && (v = 1);
  while (*_in_buf > 47 && *_in_buf < 58) p = p * 10 + *_in_buf ++ - 48;
  return v ? -p : p;
}

#define mod 1000000007
int n, k;
long long ans = 1;
vector <int> g[100005];
void dfs(int u, int par, int sum) {
  int cnt = 0;
  for (auto &v: g[u]) {
    if (v == par) continue;
    (ans *= k - sum - cnt) %= mod;
    cnt ++, dfs(v, u, min(sum + 1, 2));
  }
}

int main() {
  n = read(), k = read();
  for (int i = 1; i < n; ++ i) {
    int u = read(), v = read();
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 0, 1);
  printf("%lld\n", ans * k % mod);
  return 0;
}

Measured memory_bytes: 10368
/*
[dp] V - Subtree
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 1e5;

int N;
ll M;
vector<int> g[MAX_N];
ll dp[MAX_N];
ll ans[MAX_N];

ll dfs1(int v, int p = -1) {
    dp[v] = 1;
    for (int to : g[v]) {
        if (to == p) {
            continue;
        }
        (dp[v] *= dfs1(to, v) + 1) %= M;
    }
    return dp[v];
}

void dfs2(int v, ll res_p = 0, int p = -1) {
    int d = g[v].size();

    vector<ll> ml(d + 1), mr(d + 1);
    ml[0] = mr[d] = 1;
    for (int i = 0; i < d; i++) {
        ll sub = (g[v][i] == p) ? res_p : dp[g[v][i]];
        ml[i + 1] = (ml[i] * (sub + 1)) % M;
    }
    for (int i = d - 1; i >= 0; i--) {
        ll sub = (g[v][i] == p) ? res_p : dp[g[v][i]];
        mr[i] = (mr[i + 1] * (sub + 1)) % M;
    }
    ans[v] = mr[0];

    for (int i = 0; i < d; i++) {
        int to = g[v][i];
        if (to == p) {
            continue;
        }
        dfs2(to, ml[i] * mr[i + 1] % M, v);
    }
}

void solve() {
    dfs1(0);
    dfs2(0);
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < N - 1; i++) {
        int x, y;
        cin >> x >> y;
        g[x - 1].push_back(y - 1);
        g[y - 1].push_back(x - 1);
    }

    solve();

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

    return 0;
}


Measured memory_bytes: 19712
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n, a[200010], ans;
bool b[200010];

int main()
{
	cin >> n;
	for (ll i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	for (ll i = 0; i < n; i++)
	{
		if (b[i]) continue;
		b[i] = true;
		ll pow = 1;
		while (pow <= a[i])
		{
			pow *= 2;
		}
		ll lb = i, ub = n;
		while (lb + 1 < ub)
		{
			ll mid = (lb + ub) / 2;
			if (a[mid] > (pow - a[i])) lb = mid;
			else if (a[mid] == (pow - a[i]) && b[mid]) lb = mid;
			else ub = mid;
		}
		if (ub == n) continue;
		if (a[ub] != (pow - a[i])) continue;
		b[ub] = true, ans++;
	}
	cout << ans << endl;
	int www;
	cin >> www;
}

Measured memory_bytes: 2048