akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}*/
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 
 














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




















 
 
 
 
 

















Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	int N, M;
	cin >> N >> M;
	vector<pair<int,int> > v;
	REP(i, N) {
		int a, b;
		cin >> a >> b;
		v.push_back(make_pair(a, b));
	}
	SORT(v);
	int ans = 0,i=0;
	while (M > 0) {
		if (v[i].second <= M) {
			ans += v[i].first*v[i].second;
			M -= v[i].second;
		}
		else {
			ans += v[i].first*M;
			break;
		}
		i++;
	}
	cout << ans << endl;
	return 0;

}



Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define TR(X) ({ if(1) cerr << "Trace: " << (#X) << " = " << (X) << endl; })

ll dp[405][405];
ll cost[405][405];
ll a[405];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n; cin >> n;
	memset(dp, 0x3f, sizeof(dp));
	for(ll i = 1; i <= n; i++) cin >> a[i], a[i] += a[i - 1];
	for(ll i = 0; i <= n; i++) dp[i][i] = 0, dp[i][i + 1] = 0;
	for(ll len = 2; len <= n; len++) {
		for(ll i = 1; i <= n - len + 1; i++) {
			ll j = i + len;
			ll s = a[j - 1] - a[i - 1];
			for(ll cut = i; cut < j; cut++) dp[i][j] = min(dp[i][j], dp[i][cut] + dp[cut][j] + s);
		}
	}
	cout << dp[1][n + 1] << '\n';
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll n, par[100005], dp[2][1000005];
vector<ll> adjlist[100005];
const ll mod = 1e9+7;
ll mult (ll a , ll b){
	return (a%mod * b%mod)%mod;
}
ll add(ll a, ll b){
	return (a%mod + b%mod + mod)%mod;
}
void dfs (ll x){
	for(auto i:adjlist[x]){
		if (i == par[x])continue;
		par[i] = x;
		dfs(i);
	}
}
ll dynamic(ll col, ll x){
	if (dp[col][x] != 0)return dp[col][x];
	//~ transition
	ll cur = 1;
	ll cur1 = 1;
	for (auto i:adjlist[x]){
		if (i == par[x])continue;
		//~ dp[0][x] += dynamic(1, i) + dynamic(0, i);
		cur = mult(cur, dynamic(1, i) + dynamic(0, i));
		cur1 = mult(cur1,dynamic(0, i));
	}
	dp[0][x] = cur%mod;
	dp[1][x] = cur1%mod;
	//~ if (dp[1][x] == 0)dp[1][x] = 1;
	return dp[col][x];
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for (ll i= 0; i < n-1; i++){
		ll a, b;
		cin >> a >> b;
		adjlist[a].pb(b);
		adjlist[b].pb(a);
	}
	dfs(1);
	//~ dp[x][i] stores the number of ways i can color the subtree rooted at i, given that the color of node i is x
	for (ll i = 1; i <= n; i++){
		if (adjlist[i].size() ==1 && i != 1)dp[0][i] = 1, dp[1][i] = 1;
	}
	dynamic(0, 1);
	dynamic(1, 1);
	cout << (dp[0][1] + dp[1][1])%mod;
	//~ for (ll i = 1; i <= n; i++){
		//~ cout << dp[0][i] << ' ' << dp[1][i] << '\n';
	//~ }
	
}


Measured memory_bytes: 20864
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n;
	cin >> n;
	vector<vector<int>> grid(2, vector<int>(n));
	for(auto &row : grid) for(auto &node : row) cin >> node;
	for(int i = 0; i < 2; ++i)
		for(int j = 0; j < n; ++j)
		{
			int answer = 0;
			if(i) answer = max(answer, grid[i - 1][j]);
			if(j) answer = max(answer, grid[i][j - 1]);
			grid[i][j] += answer;
		}
	cout << grid[1][n - 1] << '\n';
}

Measured memory_bytes: 3640
#include <iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include <iomanip> 
#include <stack> 
#include <cmath> 

#define maxn 100001
#define LL long long
#define inf 10000000000
#define mod 1000000007
#define pi 3.14159265359
using namespace std;
int dx[9] = { 1,0,-1,0,1,1,-1,-1 };
int dy[9] = { 0,1,0,1,1,-1,1,-1 };


LL n, m, k;
LL arr[maxn];
LL arr2[maxn];
int visit[maxn][2];
//int cache[maxn];
//int c[maxn];
//int g[maxn];
//int dfsnum = 0;
//vector<vector<int>>rvi;
//vector<vector<int>>scc;
//vector<pair<int, int>>ett;
//stack<int>st;
//bool flg = 1;
//LL s, d;
//
//int findp(int a) {
//	if (a == c[a])return a;
//	return c[a] = findp(c[a]);
//}
//void unionp(int a, int b) {
//	a = findp(a);
//	b = findp(b);
//
//	if (g[a] < g[b])swap(a, b);
//	c[b] = a;
//	g[a] += g[b];
//	g[b] = 1;
//
//}
//LL power(LL x, LL y) {
//	LL ret = 1;
//	while (y > 0) {
//		if (y % 2) {
//			ret *= x;
//			ret %= mod;
//		}
//		x *= x;
//		x %= mod;
//		y /= 2;
//	}
//	return ret;
//}
//void dfs2(int v) {
//	cache[v] = 1;
//	scc.back().push_back(v);
//	for (int nv : rvi[v]) {
//		if (cache[nv])continue;
//		dfs2(nv);
//	}
//
//}
//LL fac(LL n) {
//	if (n == 1) return 1;        
//	return (n * fac(n - 1) - power(2,n-1) )%mod;
//}
//int fac2(LL n) {
//	LL res, i;
//	if (n == 1)return n;
//	res = n;
//	for (int i = n - 1; i > 0; --i) {
//		res *= i;
//		res %= mod;
//	}
//	return res;
//}

LL gcd(LL a, LL b) {
	while (b != 0) {
		LL r = a % b;
		a = b;
		b = r;
	}
	return a;
}
vector<LL>vi;
vector<vector<int>>graph;
void dfs(int v, int p) {
	arr2[v] = 1;
	for (int nv : graph[v]) {
		if (nv == p)continue;
		dfs(nv, v);
		arr2[v] += arr2[nv];
	}
	if (p != 0)
		vi.push_back(arr2[v] * (n - arr2[v]));
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//int t;   cin >> t; cin.ignore();
	int t = 1;
	for (int test_case = 0; test_case < t; ++test_case) {
		int flg = 1;
		LL ans1 = 0, ans2 = 0;
		string ans[2] = { "No","Yes"};
		cin >> n;
		for (int i = 0; i < n; ++i) {
			cin >> arr[i];
		}

		LL mx = arr[0];
		for (int i = 1; i < n; ++i) {
			if (arr[i] < mx) {
				ans1 += mx - arr[i];
			}
			else {
				mx = arr[i];
			}
		}
		cout << ans1<< '\n';
	}
	return 0;
}


Measured memory_bytes: 4728
import std.stdio;
import std.array;
import std.conv;
import std.string;
import std.algorithm;


void main()
{
    while (true) {
        auto cards = readln.chomp.split(",").map!(to!int).array;
        
        if(!cards.length) break;
        cards.sort.hand.writeln;
    }
}


string hand(int[] cards){
    if(cards[0] == cards[1] && cards[1] == cards[2] && cards[2] == cards[3] ||
       cards[1] == cards[2] && cards[2] == cards[3] && cards[3] == cards[4]) {
        return "four card";
    }else if(cards[0] == cards[1] && cards[1] == cards[2] && cards[3] == cards[4] ||
             cards[0] == cards[1] && cards[2] == cards[3] && cards[3] == cards[4]){
        return "full house";
    }else if(cards[0] == 1 && cards[1] == 10 && cards[2] == 11 && cards[3] == 12 && cards[4] == 13 ||
             cards[1] == cards[0] + 1 && cards[2] == cards[0] + 2 && cards[3] == cards[0] + 3 && cards[4] == cards[0] + 4) {
        return "straight";
    }else if(cards[0] == cards[1] && cards[1] == cards[2] ||
             cards[1] == cards[2] && cards[2] == cards[3] ||
             cards[2] == cards[3] && cards[3] == cards[4]) {
        return "three card";
    }else if(cards[0] == cards[1] && cards[2] == cards[3] ||
             cards[0] == cards[1] && cards[3] == cards[4] ||
             cards[1] == cards[2] && cards[3] == cards[4]) {
        return "two pair";
    }else if(cards[0] == cards[1] ||
             cards[1] == cards[2] ||
             cards[2] == cards[3] ||
             cards[3] == cards[4]) {
        return "one pair";
    }else{
        return "null";
    }
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>n>>k;
    ll aa[n];
    for0(n)
        cin>>aa[i];
    sort(aa,aa+n);
    while(k--)
        c+=aa[d++];
    cout<<c<<endl;

}



Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    for (int i=0;i<6;i++){
        cin >> S[i];
    }
    for (int i=0;i<6;i++){
        if(S[2]==S[3] && S[4] == S[5]){
            cout <<"Yes" << endl;
            break;
        }
        else {
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3404
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[100010];
    double ans=0;
    cin>>n;
    rep(i,n) cin>>a[i];
    rep(i,n){
        ans+=(double)(1/(double)a[i]);
    }
    ans=(double)(1/ans);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ks = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))

ans = 0
on_off = [0]*n
checker = [0]*m
for i in range(2**n):
    for j in range(n):
        if on_off[j] == 1:
            on_off[j] = 0
        else:
            on_off[j] = 1
            break
    slider = [1]*m
    for j in range(m):
        checker[j] = p[j]
    for j in range(1,n+1):
        for k in range(m):
            for l in range(1,ks[k][0]+1):
                if ks[k][l] == j and on_off[j-1] == 1:
                        checker[k] = 1 - checker[k]
    for j in range(m):
        if checker[j] == 1:
            break
        elif j == m-1:
            ans += 1

print(ans)


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

int main() {
  string w;
  cin >> w;
  vector<int> c(26, 0);
  for (int i = 0; i < w.size(); i++) {
    c[w[i] - 'a']++;
  }
  for (int i = 0; i < c.size(); i++) {
    if (c[i] % 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,a,b;
map<ll,ll>mp;
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        mp[a]++;
        mp[b]++;
    }
    for(auto x:mp){
        if(x.second%2==1){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 5632
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    //int[] candle = new int[N];
    //int[] candleState = new int[N];
    List<Integer> positive = new ArrayList<Integer>();
    List<Integer> negative = new ArrayList<Integer>();
    int minDistance=300000000;

    for(int i=0;i<N;i++){
      int c=sc.nextInt();
      //candle[i]=c;
      if(c==0){
        //  candleState[i]=0;
        K--;
      }else if(c>0){
        //  candleState[i]=1;
        positive.add(c);
      }else{
        //  candleState[i]=-1;
        negative.add(c);
      }
    }
    Collections.reverse(negative);
    if(K>0){
      for(int i=Math.max(K-negative.size(),0);i<=Math.min(positive.size(),K);i++){
        if(i!=0&&i!=K){
          int pDis = positive.get(i-1);
          int nDis = negative.get(K-i-1);
          int dis = Math.min(pDis*2-nDis,pDis-nDis*2);
          minDistance=Math.min(dis,minDistance);
        }else if(i==0){
        minDistance =  Math.min(minDistance,negative.get(K-1)*(-1));
        }else{
          minDistance =  Math.min(minDistance,positive.get(K-1)*(1));
        }

      }
      System.out.println(minDistance);
    }else{
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 59480
#include <map>
#include <string>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

map <string, int> cnt;
int main(){
    int n;
    string str;
    cin >> n;
    while(n--) {
        cin >> str;
        cnt[str]++;
    }
    cout << "AC x " << cnt["AC"] << endl;
    cout << "WA x " << cnt["WA"] << endl;
    cout << "TLE x " << cnt["TLE"] << endl;
    cout << "RE x " << cnt["RE"] << endl;
    return 0;
}


Measured memory_bytes: 3636
def warshall_floyd(n,d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
##############################
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)

N, M, L = LI()
d = [[float("inf") for i in range(N)] for i in range(N)]
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(M):
    x,y,z = map(int,input().split())
    d[x-1][y-1] = z
    d[y-1][x-1] = z
for i in range(N):
    d[i][i] = 0 #自身のところに行くコストは０
#print(warshall_floyd(N,d))
cur = warshall_floyd(N,d)
newD = [[float("inf") for i in range(N)] for i in range(N)]
for i in range(N):
    for l,j in enumerate(cur[i]):
        if j<=L:
            newD[i][l] = 1
            newD[l][i]

ansC = warshall_floyd(N,newD)

Q = I()
for i in range(Q):
    s, t = LI()
    ans = ansC[s-1][t-1]-1
    if ans==inf:
        ans = -1
    print(ans)

Measured memory_bytes: 129884
n, m = gets.strip.split.map(&:to_i)
l = []
r = []

m.times do
  a, b = gets.strip.split.map(&:to_i)
  l << a
  r << b
end

min = 1
max = n

m.times do |i|
  if l[i] > min
    min = l[i]
  end
  if r[i] < max
    max = r[i]
  end
end

result = max - min + 1
if result < 0
  result = 0
end
puts result

Measured memory_bytes: 3460
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

int n, m, l, r, ableL = 0, ableR = 0x7f7f7f7f;

int main()
{
    std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
    std::cin >> n >> m;
    for (; m; --m)
    {
        std::cin >> l >> r;
        ableL = std::max(ableL, l), ableR = std::min(ableR, r);
    }
    int cnt = 0;
    for (int i = ableL; i <= ableR; ++i)
        ++cnt;
    std::cout << cnt << std::endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


    
void go();



main(){
    ios
    int Testcases=1;
    while(Testcases--){
        go();
    }
    return 0;
}
#define double long double
vector<pii> x,y;
int n;
double solve(double t){
    double lx=1e15,rx=-1e15;
    double ly=1e15,ry=-1e15;
    rep(i,n){
        chmin(lx,(double)(x[i].first+t*x[i].second));
        chmax(rx,(double)(x[i].first+t*x[i].second));
        chmin(ly,(double)(y[i].first+t*y[i].second));
        chmax(ry,(double)(y[i].first+t*y[i].second));
    }
    return (rx-lx)*(ry-ly);
}
void go(){
    n=in();
    rep(i,n){
        int a=in(),b=in();
        char c;cin>>c;
        switch(c){
            case 'R':
                x.eb(a,1);
                y.eb(b,0);
                break;
            case 'L':
                x.eb(a,-1);
                y.eb(b,0);
                break;
            case 'U':
                x.eb(a,0);
                y.eb(b,1);
                break;
            case 'D':
                x.eb(a,0);
                y.eb(b,-1);
                break;
        }
    }
    double l=0,r=1e9;
    int iter=1000;
    cout<<fixed<<setprecision(15);
    while(iter--){
        double t1=(l*2+r)/3.0 , t2=(l+r*2)/3.0;
        double s1=solve(t1),s2=solve(t2);
        // cout<<t1<<" "<<t2<<endl;
        // cout<<s1<<" "<<s2<<endl;
        if(s1<s2){
            r=t2;
        }
        else l=t1;
    }
    cout<<solve(l)<<endl;

}

Measured memory_bytes: 2036
law = 998244353
n = int(input())
robots = [tuple(map(int, input().split())) for _ in range(n)]

robots.sort(reverse = True)

ntrig = [-1] * n
dp = [0] * n
dp[0] = 2
for i, (x, d) in enumerate(robots):
    if i == 0:
        continue
    next = i-1
    while x + d > robots[next][0]:
        next = ntrig[next]
        if next == -1:
            break
    ntrig[i] = next
    if next == -1:
        dp[i] = dp[i-1] + 1
    else:
        dp[i] = dp[i-1] + dp[next]
    dp[i] %= law

print(dp[n-1])

Measured memory_bytes: 42356
/*  -*- coding: utf-8 -*-
 *
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_A = 256;

typedef long long ll;
const ll MOD = 1000000007;

/* typedef */

/* global variables */

ll fracs[MAX_N + 1];
int as[MAX_N];
ll dp[2][MAX_A][MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> as[i];

  fracs[0] = 1;
  for (int i = 1; i <= n; i++) fracs[i] = (fracs[i - 1] * i) % MOD;

  dp[0][0][0] = 1;
  int cur = 0, nxt = 1;

  for (int i = 0; i < n; i++) {
    int &ai = as[i];
    memcpy(dp[nxt], dp[cur], sizeof(dp[cur]));
    for (int a = 0; a < MAX_A; a++)
      for (int j = 0; j < n; j++) {
	dp[nxt][a ^ ai][j + 1] += dp[cur][a][j];
	dp[nxt][a ^ ai][j + 1] %= MOD;
      }
    cur ^= 1, nxt ^= 1;
  }

  ll sum = 0;
  for (int j = 0; j <= n; j++)
    sum += (dp[cur][k][j] * fracs[j]) % MOD;
  sum %= MOD;

  printf("%lld\n", sum);
  return 0;
}


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define PB push_back
#define F first
#define S second

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

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

	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if(w >= v || !(a+v*t >= b+w*t && a-v*t <= b-w*t)){
		cout << "NO\n";
	}else{
		cout << "YES\n";
	}
	
	return 0;
}


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

const double INF = DBL_MAX / 1000;
const double EPS = 1.0e-10;

int L;
vector<double> a;

double calculateError(int x, int y)
{
    double vMax = 0.0;
    double vMin = 1.0;
    for(int i=x; i<=y; ++i){
        vMax = max(vMax, a[i]);
        vMin = min(vMin, a[i]);
    }

    double ret = 0.0;
    for(int i=x; i<=y; ++i){
        int j = (int)((a[i] - vMin) * (L - 1) / (vMax - vMin) + EPS);
        double q1 = vMin + j * (vMax - vMin) / (L - 1);
        double q2 = vMin + (j + 1) * (vMax - vMin) / (L - 1);

        double d = min(abs(q1 - a[i]), abs(q2 - a[i]));
        d = d * d;
        ret += d;
    }
    return ret;
}

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m >> L;
        if(n == 0)
            return 0;

        L = 1 << L;

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

        vector<vector<double> > error(n, vector<double>(n));
        for(int i=0; i<n; ++i){
            for(int j=i+1; j<n; ++j){
                error[i][j] = calculateError(i, j);
            }
        }

        vector<vector<double> > dp(n+1, vector<double>(m+1, INF));
        dp[0][0] = 0.0;
        for(int i=0; i<n; ++i){
            for(int j=0; j<m; ++j){
                for(int k=i+1; k<n; ++k){
                    dp[k+1][j+1] = min(dp[k+1][j+1], dp[i][j] + error[i][k]);
                }
            }
        }

        printf("%.10f\n", dp[n][m]);
    }
}

Measured memory_bytes: 1924
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
	static long n;

	static void Main(){
		n = long.Parse(Console.ReadLine());
		long border = (long)Pow(n,0.5);
		while (border > 0){
			if (n % border != 0){
				border--;
				continue;
			}
			long bigger = n / border;
			Console.WriteLine(Count(bigger));
			return;
		}
	}

	static int Count(long k){ //kの桁数
		int c = 0;
		while (k > 0){
			k /= 10;
			c++;
		}
		return c;
	}
}

Measured memory_bytes: 13140
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>


using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
const string FILENAME = "input";
const int MAXN = 200228;

int n;
vector<int> g[MAXN];
bool used[MAXN];
int dist[MAXN];


void dfs(int u) {
	used[u] = true;
	for (auto h: g[u]) {
		if (!used[h]) {
			dist[h] = dist[u] + 1; 
			dfs(h);
		}
	}
}

int ans = 0;

void dfs1(int u) {
	used[u] = true;
	chkmax(ans, dist[u]);
	for (auto h: g[u]) {
		if (!used[h]) {
			dist[h] = dist[u] + 1; 
			dfs1(h);
		}
	}
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//read(FILENAME);
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	memset(used, 0, sizeof(used));
 	dist[0] = 1;
 	dfs(0);
 	int pos = 0;
 	for (int i = 0; i < n; i++) {
 		if (dist[i] > dist[pos]) {
 			pos = i;
 		}
 	}
 	dist[pos] = 1;
 	memset(used, 0, sizeof(used));
 	dfs1(pos);
 	if ((ans) % 3 != 2) {
 		cout << "First\n";
 	} else {
 		cout << "Second\n";
 	}
	return 0; 	
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
ll a,b;
cin >>a>>b;
if(a==b){
  cout <<a<<endl;
  return 0;
}
if(a%2==0){
  ll j=0,bi,e,k=a;
  for(ll i=a+1;j<=3;i++){
  k=i^k;
  if(j==0) bi=k;
  if(j==2) e=k;
  j++;
  }
  ll m=(a+1)%4;
  if(b%4==m) printf("%lld\n",bi);
  else if(b%4==(m+1)%4) printf("%lld\n",b^bi);
  else if(b%4==(m+2)%4) printf("%lld\n",e);
  else printf("%lld\n",b^e);
}
else{
  ll j=0,bi,e,k=a;
  for(ll i=a+1;j<=3;i++){
  k=i^k;
  if(j==1) bi=k;
  if(j==3) e=k;
  j++;
  }
  ll m=(a+1)%4;
  if(b%4==m) printf("%lld\n",b^e);
  else if(b%4==(m+1)%4) printf("%lld\n",bi);
  else if(b%4==(m+2)%4) printf("%lld\n",b^bi);
  else printf("%lld\n",e);
}
}


Measured memory_bytes: 256
from collections import defaultdict, deque

k = int(input())
l = ["1", "2", "3", "4", "5", "6", "7",  "8", "9"]
m =  ["1", "2", "3", "4", "5", "6", "7",  "8", "9"]
queue = deque(["1", "2", "3", "4", "5", "6", "7",  "8", "9"])
while len(l)<k+1:
    i = queue.popleft()
    if i[-1] == "0":
        l.append(i+"0")
        l.append(i+"1")
        queue.append(i+"0")
        queue.append(i+"1")
    
    elif i[-1] == "9":
        l.append(i+"8")
        l.append(i+"9")
        queue.append(i+"8")
        queue.append(i+"9")
    else:
        l.append(i+str(int(i[-1])-1))
        l.append(i+str(int(i[-1])))
        l.append(i+str(int(i[-1])+1))
        queue.append(i+str(int(i[-1])-1))
        queue.append(i+str(int(i[-1])))
        queue.append(i+str(int(i[-1])+1))

print(l[k-1])
    

Measured memory_bytes: 20832
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {

		// Listに標準入力の値を取得
		ArrayDeque<String> inputs = new ArrayDeque<>();
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			while (br.ready()) {
				String[] lineArray = br.readLine().split(" ");
				Arrays.<String> stream(lineArray).forEach(s -> inputs.add(s.trim()));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		// 入力取得
		int a_vit = Integer.parseInt(inputs.pop());
		int a_atk = Integer.parseInt(inputs.pop());
		int b_vit = Integer.parseInt(inputs.pop());
		int b_atk = Integer.parseInt(inputs.pop());

		while (true) {
			b_vit -= a_atk;
			if (b_vit <= 0) {
				System.out.println("Yes");
				break;
			}
			a_vit -= b_atk;
			if (a_vit <= 0) {
				System.out.println("No");
				break;
			}
		}
	}
}


Measured memory_bytes: 33692
import java.util.*;
import static java.lang.System.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    String mae = S.substring(0,(N/2));
    String ato = S.substring(N/2);
    if (N % 2 == 0) {
      if (mae.equals(ato)) {
        out.print("Yes");
      } else {
        out.print("No");
      }
    } else {
      out.print("No");
    }
  }
}


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

int main() {
    int a, b;
    cin >> a >> b;
    
    if (a > b) {
        cout << "a > b" << endl;
    }
    else if (a < b) {
        cout << "a < b" <<endl;
        
    }
    else {
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3056
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>

using size_type = std::string::size_type;
using Indexes = std::vector<size_type>;

Indexes make_indexes(const std::string& s)
{
  Indexes indexes;
  for (size_type pos = s.find("AC");
      pos != s.npos;
      pos = s.find("AC", pos + 2)) {
    indexes.push_back(pos);
  }
  return indexes;
}

int solve(const Indexes& indexes, int l, int r)
{
  auto first = std::lower_bound(indexes.begin(), indexes.end(), l - 1);
  auto last = std::lower_bound(indexes.begin(), indexes.end(), r - 1);
  return std::distance(first, last);
}

int main()
{
  int n, q;
  std::string s;
  std::cin >> n >> q >> s;

  const auto indexes = make_indexes(s);

  for (int i = 0; i < q; ++i) {
    int l, r;
    std::cin >> l >> r;

    std::cout << solve(indexes, l, r) << std::endl;
  }
}


Measured memory_bytes: 1528
#include <climits>
#include <cstdio>
#include <cstdint>
#include <cstring>

#include <algorithm>

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1);
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__);
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__);
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__);
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__);
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__);
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__);
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__);

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__);

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32")) return "%d";
  if(strcmp(fmt, "u32")) return "%u";
  if(strcmp(fmt, "f32")) return "%f";
  if(strcmp(fmt, "f64")) return "%lf";
  if(strcmp(fmt, "i64")) return "%lld";
  if(strcmp(fmt, "u64")) return "%llu";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__);
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__);
#define RF(...)   _FCN(_R, f32, __VA_ARGS__);
#define RD(...)   _FCN(_R, f64, __VA_ARGS__);
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__);
#define RULL(...) _FCN(_R, u64, __VA_ARGS__);

#define PI(...)   _FCN(_P, i32, __VA_ARGS__);
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__);
#define PF(...)   _FCN(_P, f32, __VA_ARGS__);
#define PD(...)   _FCN(_P, f64, __VA_ARGS__);
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__);
#define PULL(...) _FCN(_P, u64, __VA_ARGS__);

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

const u64 mod = 1000000007;

int main() {
  i32 o = INT_MAX;
  RI(N);
  REP(N) {
    RI(t);
    i32 k = 0;
    while (t % 2 == 0) { k++; t /= 2; }
    o = min(o, k);
  }
  PI(o);
}


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

using namespace std;

#define int long long

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k)
  {
    return (-data[find(k)]);
  }
};

signed main()
{
  int N, M, U[200000], V[200000];

  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    cin >> U[i] >> V[i];
  }

  UnionFind tree2(N + N), tree3(N);
  for(int i = 0; i < M; i++) {
    tree2.unite(U[i] + N, V[i]);
    tree2.unite(V[i] + N, U[i]);
    tree3.unite(U[i], V[i]);
  }

  int other = 0, one = 0, two = 0;
  for(int i = 0; i < N; i++) {
    if(tree3.find(i) == i) {
      if(tree3.size(i) == 1) ++other;
      else if(tree2.find(i) != tree2.find(i + N)) ++two;
      else ++one;
    }
  }

  int latte = other * N * 2 - other * other;
  cout << latte + two * two * 2 + one * one + two * one * 2 << endl;
}

Measured memory_bytes: 5760
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String args[]) throws IOException {
		Scanner scan = new Scanner(System.in);

		while(true) {
			int m = scan.nextInt();
			int n = scan.nextInt();

			if(m == 0 || n == 0) {
				break;
			}

			List<Integer> li = new ArrayList<Integer>();
			for(int i = 1;i <= m ; i++) { li.add(i); }

			int cursor = 0;
			String ansS,judgeS;

			for(int i = 1 ; i <= n;i++) {
				judgeS = "";
				ansS = scan.next();

				if(li.size() == 1) {continue;}
				if(i % 3 == 0) {judgeS += "Fizz";}
				if(i % 5 == 0) {judgeS += "Buzz";}
				if(judgeS.equals("") == true) {judgeS = Integer.toString(i);}

				if(judgeS.equals(ansS) == false) {
					li.remove(cursor--);
				}

				if(++cursor >= li.size()) {cursor = 0;}
			}

			for(Integer a : li) {
				System.out.print(Integer.toString(a));
				if(!a.equals(li.get(li.size() - 1))) {
					System.out.print(" ");
				}
			}
			System.out.println();
		}
		scan.close();
	}
}


Measured memory_bytes: 70056
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scn = new Scanner(System.in);
        int N = scn.nextInt();
        int M = scn.nextInt();
        boolean[] nusuke = new boolean[N];
        int a = 0;
        //M回ループ
        for(int i=0;i<M;i++){
            int d = scn.nextInt();
            //d回ループ
            for(int k=0;k<d;k++){
                a = scn.nextInt();
                nusuke[a-1] = true;
            }
        }

        int cnt = 0;

        for(int i=0;i<N;i++){
            if(nusuke[i] == false){
                cnt++;
            }
        }

        System.out.println(cnt);
    }
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    string ans;
    for (int i = 0; i < 3; ++i) {
        char c[3];
        for (int k = 0; k < 3; ++k) {
            cin >> c[k];
        }
        ans += c[i];
    }
    cout << ans << endl;





    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int N;
  int L[100] = {0};
  int p = 0,temp;
  int i,j,k;

  scanf("%d",&N);
  for(i = 0;i < N;i++)scanf("%d",&L[i]);

  for(i = 0;i < N - 1;i++)
  {
    for(j = N-1;j > i;j--)
    {
      if(L[j] < L[j-1] )
      {
        temp = L[j];
        L[j] = L[j-1];
        L[j-1] = temp;
      }
    }
  }
  
  for(i = 0;i < N-2;i++)
  {
    for(j = (i + 1);j < N -1;j++)
    {
      if(L[i] == L[j])continue;
      for(k = (j + 1);k < N;k++)
      {
        if(L[j] == L[k])continue;
        //printf("%d %d %d ",L[i],L[j],L[k]);
        if(L[k] < (L[i] + L[j]) )p++;
        //printf("%d\n",p);
      }
    }
  }

  printf("%d",p);
  
  return 0;
}


Measured memory_bytes: 1736
import java.util.*;
// Dont care if there is an optimal solution. O(n^2)
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		sc.nextInt();
		String tok = sc.next();
		int max = Integer.MIN_VALUE;
		Set<Character> a = new HashSet<Character>();
		Set<Character> b = new HashSet<Character>();
		for (int i=0; i<tok.length()-1; i++) {
			a.add(tok.charAt(i));
			b.remove(tok.charAt(i));
			for (int j=i+1; j<tok.length(); j++) b.add(tok.charAt(j));
			Set<Character> c = new HashSet<Character>(a);
			c.retainAll(b);
			max = Math.max(c.size(), max);
		}
		System.out.println(max);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 36572
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 n, a, b;
    cin >> n >> a >> b;
    if (a % 2 == b % 2)
    {
        cout << (b - a) / 2 << endl;
    }
    else
    {
        cout << (b - a + 1) / 2 + min(a - 1, n - b) << endl;
    }
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s;
  cin >> s;
  string ans;
  for(auto& t : s){
    string tmp;
    tmp = t;
    if(tmp == "0"){
      ans += "0";
    }else if(tmp == "1"){
      ans += "1";
    }else{
      if(ans.size() != 0){
        ans = ans.substr(0, ans.size() - 1);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int fw(const void *a, const void *b)
{
    return *(long int *)a - *(long int *)b;
}
int bw(const void *a, const void *b)
{
    return *(long int *)b - *(long int *)a;
}
int main()
{
    int n, a[100010] = {}, b[100010] = {};
    int h;
    int hit = 0, count = 0;
    scanf("%d %d", &n, &h);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d", &a[i], &b[i]);
    }
    qsort(a, n, sizeof(int), bw);
    qsort(b, n, sizeof(int), bw);
    for (int i = 0; b[i] > a[0] && hit < h; i++)
    {
        hit += b[i];
        count++;
    }
    while (hit < h)
    {
        hit += a[0];
        count++;
    }
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 1400
fun main(args: Array<String>) {
    val mod = 1000000007L
    val ncr = Array(2001) { LongArray(2001){0} }
    ncr[0][0] = 1
    for (i in 1..2000) {
        ncr[i][0] = 1
        for (j in 1..i) {
            ncr[i][j] = (ncr[i - 1][j - 1] + ncr[i - 1][j]) % mod
        }
    }
    val (n, k) = readLine()!!.split(' ').map(String::toInt)
    for (i in 1..k) {
        println(ncr[k - 1][i - 1] * ncr[n - k + 1][i] % mod)
    }
}


Measured memory_bytes: 92128
import numpy as np
n,m,x=map(int,input().split())
ans=10**10
f=1
s=[list(map(int,input().split())) for _ in range(n)]
for i in range(1<<n):
  t=np.zeros(m+1)
  for j in range(n):
    if (i>>j)&1:
      t=t+np.array(s[j])
  if all(t[1:]>=x):
    ans=min(t[0],ans)
    f=0
if f:
  print(-1)
else:
  print(int(ans))

Measured memory_bytes: 27160
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
typedef long long int ll;


void input(){
   int k , x; cin >> k >> x;
   int y = x + 1 - k;
   int z = k + x - 1;
   for(int i = y; i <= z; ++i)cout << i << " ";cout << endl;
}
int main()
{
 input();
 return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
long long mod=1e9+7;
int vis[100005];

int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {

        memset(vis,0,sizeof(vis));
       for(int i=1;i<=m;i++)
       {
           int x;
           scanf("%d",&x);
           vis[x]=-1;
       }
        vis[0]=1;
        for(int i=1;i<=n;i++)
        {
             if(vis[i]==-1)
            vis[i]=0;
        else
            if(i>=2)
        {
            vis[i]=vis[i-2]%mod+vis[i-1]%mod;
        }
        else
            vis[i]=vis[i-1]%mod;
        vis[i]%=mod;
        }

       printf("%d\n",vis[n]);
    }
    return 0;
}


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



int main(){
    ll H, W;
    cin >> H >> W;
    char a[H + 3][W + 3];
    memset(a, '#', sizeof(a));
    
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            cin >> a[i][j];
        }
    }

    for(int i = 0; i <= H + 1; i++){
        for(int j = 0; j <= W + 1; j++){
            cout << a[i][j];
        }
        cout << endl;
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <map>

using ll = long long;

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    ll cnt = 0;
    for (int i=1; 2*i<n; i++) {
        for (int j=0; j+2*i<n; j++) {
            set<char> st{s[j], s[j+i], s[j+2*i]};
            if (st.size() == 3) {
                cnt++;
            }
        }
    }
    map<char, ll> m;
    for (auto &c:s) m[c]++;
    cout << m['R'] * m['G'] * m['B'] - cnt << '\n';
    return 0;
}

Measured memory_bytes: 3632
h,w=map(int,input().split())
stand=h*w/3
prevh,prevw=1,1
mini=10**18
for i in range(2,h+1):
    if abs(stand-i*w)<abs(stand-prevh*w):
        prevh=i
if h-prevh>=2:
    mini=min(mini,max((h-prevh)//2*w,prevh*w,-(-(h-prevh)//2)*w)-min((h-prevh)//2*w,prevh*w,-(-(h-prevh)//2)*w))
mini=min(mini,max(w//2*(h-prevh),prevh*w,-(-w//2)*(h-prevh))-min(w//2*(h-prevh),prevh*w,-(-w//2)*(h-prevh)))
#print(mini)
for i in range(2,w+1):
    if abs(stand-i*h)<abs(stand-prevw*h):
        prevw=i
if w-prevw>=2:
    mini=min(mini,max((w-prevw)//2*h,prevw*h,-(-(w-prevw)//2)*h)-min((w-prevw)//2*h,prevw*h,-(-(w-prevw)//2)*h))
mini=min(mini,max(h//2*(w-prevw),prevw*h,-(-h//2)*(w-prevw))-min(h//2*(w-prevw),prevw*h,-(-h//2)*(w-prevw)))
print(mini)

Measured memory_bytes: 9000
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    ll a, b, ans, tree = 0;
    cin >> a >> b;
    for (int i = b - a; i >= 1; i--) {
        tree += i;
    }
    ans = tree - b;
    cout << ans << endl;
}


Measured memory_bytes: 256