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

using std::sort;

const int Mx = 2e5 + 10;
const int Mod = 1000000007;

struct Node{
	int x, v, vv, l, r;
}p[Mx];

int n, tot;
int f[Mx], q[Mx];

inline bool cmp1(Node a, Node b){
	return a.v < b.v;
}

inline bool cmp2(Node a, Node b){
	return a.x < b.x;
}

inline bool cmp3(Node a, Node b){
    return a.r < b.r || a.r == b.r && a.l < b. l;
}

inline void cl(){
	int mx = 0, mn = tot + 1;
	for(int i = 1; i <= n; ++i){
		mx = std::max(mx, p[i].vv);
		p[i].r = mx;
	}
	for(int i = n; i >= 1; --i){
		mn = std::min(mn, p[i].vv);
		p[i].l = mn;
	}
// 	for(int i = 1; i <= n; ++i){
// 	    printf("%d %d\n", p[i].l, p[i].r);
// 	}
}

inline void dp(){
	int sum = 0, head = 0, tail = 0;
	f[0] = 1;
	q[tail++] = 0, sum = 1; 
	++n;
	p[n].l = p[n].r = n;
	for(int i = 1; i <= n; ++i){
		while(head < tail && p[i].l > p[q[head]].r + 1){
			sum = (sum - f[q[head]] + Mod) % Mod, ++head;
		}
		f[i] = sum;
		sum = (sum + f[i]) % Mod;
		q[tail++] = i;
	}
	printf("%d\n", f[n]);
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		scanf("%d %d", &p[i].x, &p[i].v);
	}
	sort(p + 1, p + n + 1, cmp1);
	for(int i = 1; i <= n; ++i){
		if(p[i].v == p[i - 1].v){
			p[i].vv = p[i - 1].vv;
		}else 
			p[i].vv = ++tot;
	}
	sort(p + 1, p + n + 1, cmp2);
	cl();
    sort(p + 1, p + n + 1, cmp3);
	dp();
	return 0;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	VI a(4);
	rep(i, 4) a[i]=s[i]-'0';
	
	rep(i, 1<<3){
		int sm = a[0];
		string op="---";
		rep(j, 3){
			if(i>>j &1){ sm += a[j+1]; op[j]='+';}
			else sm -= a[j+1];
		}
		if(sm == 7){
			rep(j, 3) cout <<a[j]<<op[j];
			cout <<a[3] <<"=7\n";
			return 0;
		}
		//dbg(sm, op);
	}
	return 0;
}


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

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int sign(int x){
  return (x>0)-(x<0);
}



int main(){
  int n;
  int a[SIZE];
  
  scanf("%d",&n);  
  
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
  }

  int t = 0;
  int ans = 0;

  while(t+1 < n && a[t] == a[t+1]) t++;
  
  bool isup = (a[t+1] - a[t]) > 0;
  int counter = 0;
  
  for(;t+1<n;t++){
    while(t+1 < n && a[t] == a[t+1]) t++;

    if(t+1 >= n) break;
    
    if(a[t+1] - a[t] > 0 && isup){
      counter++;
    }else if(a[t+1] - a[t] < 0 && !isup){
      counter++;
    }else{
      ans = max(ans, counter);
      counter = 1;
      while(t+1 < n && a[t] == a[t+1]) t++;
      if(t+1 >= n) break;
      isup = (a[t+1] - a[t]) > 0;
    }
  }

  ans = max(ans, counter);

  printf("%d\n",ans + 1);
  
  return 0;
}

Measured memory_bytes: 3596
#include "stdio.h"

long long int N;
long long int pro[2][1000] = {};
long long int num[2][1000] = {};
long long int cross;

int main() {
	scanf("%lld", &N);
	scanf("%lld %lld", &pro[0][0], &pro[1][0]);
	num[0][0] = pro[0][0];
	num[1][0] = pro[1][0];
	//printf("%lld %lldになった\n", num[0][0], num[1][0]);
	for (int i = 1; i < N; i++) {
		scanf("%lld %lld", &pro[0][i], &pro[1][i]);
		if (pro[0][i] >= num[0][i - 1] && pro[1][i] >= num[1][i-1]) {
			num[0][i] = pro[0][i];
			num[1][i] = pro[1][i];
			//printf("%lld %lldになった\n", num[0][i], num[1][i]);
		}
		else {
			if (num[0][i - 1] % pro[0][i] == 0)cross = num[0][i - 1] / pro[0][i];
			else cross = num[0][i - 1] / pro[0][i] + 1;
			if (cross < num[1][i - 1] / pro[1][i] + 1 && num[1][i - 1] % pro[1][i] != 0)cross = num[1][i - 1] / pro[1][i] + 1;
			else if (cross < num[1][i - 1] / pro[1][i] && num[1][i - 1] % pro[1][i] == 0)cross = num[1][i - 1] / pro[1][i];
			num[0][i] = pro[0][i] * cross;
			num[1][i] = pro[1][i] * cross;
			//printf("%lld %lldになった\n", num[0][i], num[1][i]);
		}
	}
	printf("%lld\n", num[0][N - 1] + num[1][N - 1]);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;

int main() {
    int n, m;
    cin >> n >> m;
    int s[m], c[m];
    rep(i, m) {
        cin >> s[i] >> c[i];
    }
    int ans = -1;
    rep(i, 1000) {
        string str = to_string(i);
        if (str.size() != n) continue;
        bool flag = true;
        rep(i, m) {
            if (str[s[i]-1]-'0' != c[i]) {
                flag = false;
            }
        }
        if (flag) {
            ans = stoi(str);
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
//2020-05-27

#include <iostream>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s,t;
    cin >> s >> t;

    for (int i=0;i<s.length();i++){
        
        if (s[i] != t[i]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 2992
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
long long c[5];
long long a[5];
int main()
{
	for (int i = 1; i <= 4; i ++)
	cin >> a[i];
	c[1] = a[1] * a[3];
	c[2] = a[1] * a[4];
	c[3] = a[2] * a[3];
	c[4] = a[2] * a[4];
	sort (c + 1, c + 5);
	cout << c[4];
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;int gb,ans;
	cin>>a>>b;
	int la=a.size(),lb=b.size();
	ans=la;
	for(int i=0;i<=la-lb;i++)
	{
		gb=0;
		for(int j=i;j<i+lb;j++)
		{
			if(a[j]!=b[j-i]) gb++;
		}
		ans=min(ans,gb);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

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

  ll N;
  std::string S, T, ans;
  std::cin >> N >> S >> T;

  for (ll i = 0; i < N; ++i) {
    ans += S[i];
    ans += T[i];
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <cstring>
#include <set>
using namespace std;
const int maxn = 5e5 + 100;
set<string> st;
char s[maxn];
int main(){
    int k;
    scanf("%s",s);
    scanf("%d",&k);
    int len = strlen(s);
    set<string> ::iterator it;
    st.clear();
    for (int i = 0; i < len; i++){
        string tmp;
        tmp.clear();
        for (int j = i; j < len; j++){
                if (j - i + 1 > k) break;
                tmp.push_back(s[j]);
                if (st.size() == 0 || st.find(tmp) == st.end()){
                       st.insert(tmp);
                }
                while (st.size() > k){
                    it = st.end();
                    it--;
                    st.erase(*it);
                }
        }
    }
    it = st.end();
    it--;
    cout << *it  << endl;
 
 
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <limits>
#include <vector>

using namespace std;

typedef long long ll;

int r, c, n;
struct cell {
  int r, c, a;
};
vector<cell> R[1 << 20], C[1 << 20];
ll Rb[1 << 20], Cb[1 << 20];
void dfsR(int r, ll b);
void dfsC(int r, ll b);
ll lb, ub;
// SR[r]=ax+b
void dfsR(int r, ll b) {
  Rb[r] = b;
  vector<cell> ces;
  ces.swap(R[r]);
  for (auto& ce : ces) {
    if (!C[ce.c].empty()) {
      dfsC(ce.c, ce.a - b);
    } else if (Cb[ce.c] != ce.a - b) {
      ub = numeric_limits<ll>::min();
      lb = numeric_limits<ll>::max();
    }
  }
  //  printf("%d: x+%lld\n", r, b);
  lb = max(lb, -b);
}
// SC[r]=b-x
void dfsC(int c, ll b) {
  Cb[c] = b;
  vector<cell> ces;
  ces.swap(C[c]);
  for (auto& ce : ces) {
    if (!R[ce.r].empty()) {
      dfsR(ce.r, ce.a - b);
    } else if (Rb[ce.r] != ce.a - b) {
      ub = numeric_limits<ll>::min();
      lb = numeric_limits<ll>::max();
    }
  }
  //  printf("%d: %lld-x\n", c, b);
  ub = min(ub, b);
}

int main() {
  scanf("%d%d%d", &r, &c, &n);
  for (int i = 0; i < n; ++i) {
    int ri, ci, ai;
    scanf("%d%d%d", &ri, &ci, &ai);
    R[ri].push_back({ri, ci, ai});
    C[ci].push_back({ri, ci, ai});
  }
  for (int i = 1; i <= r; i++) {
    if (!R[i].empty()) {
      lb = numeric_limits<ll>::min();
      ub = numeric_limits<ll>::max();
      dfsR(i, 0);
      //      printf("=== %lld %lld\n", lb, ub);
      if (lb > ub) {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
}


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

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

    int n = b - a + 1;

    if (a <= 0 && b >= 0){
        cout << "Zero" << endl;
    }
    else if (a > 0 && b < 0){
        cout << "Zero" << endl;
    }
    else if ( a < 0 && b < 0 && n % 2 == 0){
        cout << "Positive" << endl;
    }
    else if (a < 0 && b < 0 && n % 2 == 1){
        cout << "Negative" << endl;
    }
    else {
        cout << "Positive" << endl;
    }
}


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

int main() {
	int A;
	int B;
	int C;
	int D;
	cin >> A >> B >> C >> D;

	int L = A + B;
	int R = C + D;

	if( L > R ) {
		cout << "Left" << endl;
	}
	else if( R > L ) {
		cout << "Right" << endl;
	}
	else {
		cout << "Balanced" << endl;
	}
}


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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
  transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
  transform(s3.begin(), s3.end(), s3.begin(), ::toupper);

  cout << s1[0] << s2[0] << s3[0] <<endl;
}


Measured memory_bytes: 256
using System;

namespace AOJ.Volume1
{
    public class HammingNumber
    {
        private static bool Check(int x)
        {
            // ハミング数チェック
            // ハミング数は2,3,5以外の約数を持たない

            // 5で割る
            while (x % 5 == 0) { x = x / 5; }
            if (x == 1) { return true; }

            // 3で割る
            while (x % 3 == 0) { x = x / 3; }
            if (x == 1) { return true; }

            // 2で割る
            while (x % 2 == 0) { x = x / 2; }
            if (x == 1) { return true; }

            return false;
        }

        public static int Main()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (input == "0") { break; }

                int pos = input.IndexOf(' ');
                int m = int.Parse(input.Substring(0, pos));
                int n = int.Parse(input.Substring(pos + 1));

                int answer = 0;
                for (int i = m; i <= n; i++)
                {
                    if (Check(i)) { answer++; }
                }

                Console.WriteLine(answer);
            }
            return 0;
        }
    }
}

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

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fore(i,a,b) for(int i = a; i < b; i++)
#define rfor(i, a, b) for(int i = a - 1; i >= b; i--)

ll n,m;
ll dp[100010];
bool visited[100010];
vector<int> g[100010];



ll dfs(int node){
    if(dp[node] != -1)return dp[node];
    ll ma = 0;
    for(auto x :g[node]){
        ma = max(ma,dfs(x)+1);
    }
    dp[node] = ma;
    return dp[node];
}


int main(){
    cin>>n>>m;
    fore(i,0,m){int v,w;cin>>v>>w;g[v].push_back(w);visited[w] = true;}
    fore(i,1,n+1)dp[i] = -1;
    fore(i,1,n+1){if(!visited[i])dfs(i);}
    ll ma = 0;
    // fore(i,1,n+1)cout<<dp[i]<<" ";
    // cout<<endl;
    fore(i,1,n+1)ma = max(ma,dp[i]);
    cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 11264
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        double r = double.Parse(Console.ReadLine());
        double menseki;
        double shu;

        menseki = r * r * Math.PI;
        shu = 2 * r * Math.PI;
       
        Console.WriteLine(String.Format("{0:F6} {1:F6}", menseki, shu));
        
    }
}


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

const int MAX = 10; // 横
const int MAX2 = 101; // 高さ
const int MOD = 1000000007; // 今回使う余り
int main() {
	int H, W, K;
	cin >> H >> W >> K;
	int64_t fib[MAX]; // あみだくじの場合、長さnはfib(n)を参照(ただしf(0)=0とする)
	fib[0] = 0;
	fib[1] = 1;
	for (int i = 2;i <= W + 1;++ i) fib[i] = fib[i - 1] + fib[i - 2]; // ここまででO(W)
	
	int64_t dp[MAX2][MAX]; // 番兵付きなので間違えないように！dp[i][j]は高さiにおける左からj番目に辿れる組み合わせ
	for (int i = 0;i <= H;++ i) for (int j = 0;j <= W + 1;++ j) dp[i][j] = 0;
	dp[0][1] = 1;
	for (int i = 1;i <= H;++ i) for (int j = 1;j <= W;++ j) dp[i][j] = (dp[i - 1][j - 1] * fib[j - 1] * fib[W - j + 1] + dp[i - 1][j] * fib[j] * fib[W - j + 1] + dp[i - 1][j + 1] * fib[j] * fib[W - j]) % MOD;
	
	cout << dp[H][K];
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

上から考えていこう
まず、高さ1の時点での1の存在は、1-2に線が引かれていない場合は1に行き、その組み合わせは2からWまでの全ての横線を引く組み合わせに等しい
そして、1-2に線が引かれていれば2に行き、その組み合わせは3からWまでの全ての横線を引く組み合わせに等しい

……a-b間における組み合わせは先に計算すると良さそうなのでまず考えてみよう
平行移動しても同じなので、b-a=xとする長さを考えてf(x)で定義しよう
まず、f(0)=0, f(1)=1なのは自明
f(2)=f(1)(引かない場合)+f(0)(引いた場合)
以下、f(n)=f(n-1)+f(n-2)と導出できるので、これはフィボナッチ数列になるね

次に、今辿っている位置がxにある時の次の組み合わせを考えよう
・x-1に移動する組み合わせ
・xに移動する組み合わせ
・x+1に移動する組み合わせ
これ以外はあり得ないので、これだけ考えれば良いね
まず、x-1に移動する場合、(x-1)-xにあみだが引かれたので、(x-2)-(x-1)とx-(x+1)にはあみだが引かれない
よって、この組み合わせは1-(x-2)間×(x+1)-W間の組み合わせ、よってf(x-1)*f(W-x+1)となる
次にxに移動する場合は(x-1)-xとx-(x+1)にはあみだが引かれないので、f(x)*f(W-x+1)となるね
最後にx+1に移動する場合はx-(x+1)にあみだが引かれ、(x-1)-xと(x+1)-(x+2)にはあみだが引かれないのでf(x-1)*f(W-x)となる

ということは、これであみだくじを1個下に動く遷移がO(W)でできたので答えはO(HW)、間に合うね
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  int n;
  cin >> n;
  vector<int> l(n);
  repr(i, n, 0) cin >> l[i];

  sorti(l);
  int ans = 0;
  for (int i = 0; i < n-1; ++i) {
    for (int j = i+1; j < n; ++j) {
      int sum = l[i] + l[j];
      auto right = lower_bound(l.begin(), l.end(), sum) - l.begin();
      ans += max<int>(right - (j+1), 0);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

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

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

	int ans = 10000;

	if (12.5 * A <= 10*B and 10*B < 12.5 * (A+1)) {
		ans = min(ans, 10*B);
	}

	if (10 * B <= 12.5 * A and 12.5 * A < 10 * (B + 1)) {
		if (A % 2 == 0) {
			ans = min(ans, 25 * A / 2);
		} else if (10*B <= ceil(12.5*A) and ceil(12.5*A) < 10*(B+1)) {
			ans = min(ans, (int)ceil(12.5*A));
		}
	}

	if (ans == 10000) 
		cout << -1 << endl;
	else
		cout << ans << endl;
}


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

int main() {
  uint64_t Ans = 0;  // 回答：
  int N; cin >> N;  // 文字列数１～４０００
  string S; cin >> S; // 対象文字列

  if ( N<3 ){cout << 0 << endl; return 0;}
  // ①Ｒ・Ｇ・Ｂから、一つずつ選ぶ組の数を出す。
  // ②ポイント i から ポイント j の向こうに距離の等しいポイント k を選定し、
  // 　ＲＧＢ３色なら、①の数から引く。
  uint64_t R=0;  // Rの数
  uint64_t G=0;  // Rの数
  uint64_t B=0;  // Rの数
  rep(i,N){
    if(S.at(i)=='R'){R++;}
    if(S.at(i)=='G'){G++;}
    if(S.at(i)=='B'){B++;}
  }
  Ans = R*G*B;

  // int wk_int=0;
  // rep(i,N-2){     // i の場所：０～Ｎ－３
  //   rep1(j,N){    // i から j までの距離：１～(N-i)/2 までで良いけど、端数処理が面倒
  //     wk_int = i+j+j;
  //     if( wk_int >= N ){break;}
  //     if( S.at(i)!=S.at(i+j) && S.at(i)!=S.at(i+j+j) && S.at(i+j)!=S.at(i+j+j) ) { Ans--; }
  //   }
  // }
//  rep1(d,N){
  for(int d=1;d<N;d++){  // ２点間の距離：一定
    for(int i=0,j=d,k=2*d; k<N ; i++,j++,k++ ) {    // i の位置を１つずつずらす
      if(S[i]!=S[j]&&S[j]!=S[k]&&S[k]!=S[i]){ Ans--;}
    }
  }
  cout << Ans << endl;
}


Measured memory_bytes: 3636
def inner?(x,y,l1x,l1y,l2x,l2y)
  return true if x.between?(l1x,l2x) and y.between?(l1y,l2y)
  return false
end

while gets
  xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2=$_.split.map(&:to_f)
  if inner?(xa1,ya1,xb1,yb1,xb2,yb2) or inner?(xa1,ya2,xb1,yb1,xb2,yb2) or inner?(xa2,ya1,xb1,yb1,xb2,yb2) or inner?(xa2,ya2,xb1,yb1,xb2,yb2) or
     inner?(xb1,yb1,xa1,ya1,xa2,ya2) or inner?(xb1,yb2,xa1,ya1,xa2,ya2) or inner?(xb2,yb1,xa1,ya1,xa2,ya2) or inner?(xb2,yb2,xa1,ya1,xa2,ya2) or
     (xa1<xb1 and xa2>xb2 and ya1>yb1 and ya2<yb2) or (xa1>xb1 and xa2<xb2 and ya1<yb1 and ya2>yb2) then
    puts "YES"
  else
    puts "NO"
  end
end

Measured memory_bytes: 8588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int N, M; cin >> N >> M;
  vector<int> a(N);
  rep (i, M) cin >> a[i];
  int ans = -1;
  int sum = 0;
  sum = accumulate(ALL(a),sum);
  chmax(ans, N - sum);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7212
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static void printArrayL(long[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + ", ");
		}
		System.out.println();
	}

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W = sc.nextInt();
		int[] w = new int[N];
		int[] v = new int[N];
		for (int i = 0; i < N; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		long[] values = new long[W+1];
		for (int i = 0; i < N; i++) {
			int wi = w[i];
			int vi = v[i];
			for (int j = W; j >= wi; j--) {
				values[j] = Math.max(values[j], values[j-wi] + vi);
			}
		}
		long max = values[0];
		for (int i = 1; i <= W; i++) {
			max = Math.max(max, values[i]);
		}
		// printArrayL(values);
		System.out.println(max);
	}
}


Measured memory_bytes: 24148
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  cout << (a == b && b == c ? "Yes" : "No") << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

int a[1000];
int n;

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

int j;
for( j = n - 1; j  > -1 ; j = j - 1 )
	{cout<<a[j];
		 if(j>0){ cout<<" ";}
	 	 if(j==0 ){ cout<<endl;}
	}
}



Measured memory_bytes: 3120
#include<stdio.h>
#include<math.h>
double distance(double x, double y);
int kaijo(int n);
int main(){
    int n;
    scanf("%d",&n);
    double x[10];
    double y[10];
    int i;
    for(i=1;i<=n;i++){
        scanf("%lf %lf",&x[i],&y[i]);
    }
    int j;
    int roop;
    roop = kaijo(n)/kaijo(n-1);
    int a =kaijo(n);
    double dis=0;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            dis = dis + distance(x[j]-x[i],y[j]-y[i]);
        }
    }
    double ans;
    ans =dis/n; //いける点どうしの組み合わせ＝辺の数+対角線 天才
    //n-1 は経路１つごとの矢印の数
    printf("%lf\n",ans);
    return 0;
}
int kaijo(int n){
    int i=1;
    int sum =1;
    for(i=1;i<=n;i++){
        sum = sum+i;
    }
    return sum;
}
double distance(double x, double y){
    return sqrt(x*x+y*y);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	static final long DIVISOR = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		int N = sc.nextInt();
		sc.close();
		
		// 結果の出力
		long answer = (powmod(10, N) - powmod(9, N)) % DIVISOR;
		answer = (answer - powmod(9, N)) % DIVISOR;
		answer = (answer + powmod(8, N)) % DIVISOR;
		answer = (answer + DIVISOR) % DIVISOR;
		System.out.println(answer);
	}
	
	static long powmod(long x, long y) {
		long res = 1;
		for (long i = 0; i < y; i++) {
			res = res * x % DIVISOR;
		}
		return res;
	}
}

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

int solve(vector<int>&v,int k)
{
    bool dp[k+1];
    memset(dp,0,sizeof dp);

    for(int i=1;i<=k;i++)
    {
        for(int x:v)
        {
            if(x>i)
                continue;

            if(dp[i-x]==0)
                dp[i]=1;
        }
    }
  return dp[k];

}

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

     if(solve(v,k)==1)
        cout<<"First"<<"\n";

     else
        cout<<"Second"<<"\n";

    return 0;
}


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

int main(void){
  int n;
  cin >> n;
  int sum=0,count=1;	//重複数countを最初から1としておく
  vector<int> a(n);
  for(int i=0;i<n;i++)	cin >> a[i];
  sort(a.begin(), a.end());
  if(n==1)	sum++;		//n-1を扱うのでn=1の場合は除外
  for(int i=0;i<n-1;i++){
    if(a[i+1]==a[i]){	//前後比較；重複数とcountを一致させる
      count++;
    }
    else{
      if(count%2==1){	//countが奇数個ならsum++
        sum ++;
      }
      count=1;			//countの初期化
    }
  }
  if(count%2==1)	sum++;	//最後の処理
  cout << sum << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<queue>
using namespace std;

const int maxn = 400010;
int N,M,cnt,side[maxn],nxt[maxn],toit[maxn],vis[maxn];
deque <int> ans;

inline void add(int a,int b) { nxt[++cnt] = side[a]; side[a] = cnt; toit[cnt] = b; }
inline void ins(int a,int b) { add(a,b); add(b,a); }

inline int gi()
{
	int ret = 0,f = 1; char ch;
	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');
	if (ch == '-') f = -1,ch = getchar();
	do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');
	return ret*f;
}

inline void dfs1(int now)
{
	if (vis[now]) return;
	vis[now] = true; ans.push_back(now);
	for (int &i = side[now];i;i = nxt[i])
		if (!vis[toit[i]]) { dfs1(toit[i]); break; }
}

inline void dfs2(int now)
{
	if (vis[now]) return;
	vis[now] = true; ans.push_front(now);
	for (int &i = side[now];i;i = nxt[i])
		if (!vis[toit[i]]) { dfs2(toit[i]); break; }
}

int main()
{
	//freopen("B.in","r",stdin);
	//freopen("B.out","w",stdout);
	N = gi(); M = gi();
	for (int i = 1;i <= M;++i) ins(gi(),gi());
	dfs1(1);
	for (int &i = side[1];i;i = nxt[i])
		if (!vis[toit[i]]) { dfs2(toit[i]); break; }
	cout << ans.size() << endl;
	for (int i = 0;i < ans.size();++i)
	{
		printf("%d",ans[i]);
		if (i != ans.size()-1) putchar(' ');
	}
	//fclose(stdin); fclose(stdout);
	return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  ll N,M;
  cin >> N >> M;
  vll A(M+1);
  rep(i,0,N){
    ll K;
    cin >> K;
    rep(j,0,K){
      ll a;
      cin >> a;
      A[a]++;
    }
  }

  ll ans = 0;
  erep(i,1,M){
    if(A[i] == N) ans++;
  }

  print(ans);

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define thekingisborn ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ld  long double
#define f first
#define se second
#define pb push_back
#define maxn 200005
#define mod 1000000007
#define pi 3.14159265359

using namespace std;

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

/*ll power(ll a,ll n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    a = a%mod;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n>>1))%mod)%mod;
    return power((a*a)%mod,n>>1)%mod;
}
ll gcd(ll a,ll b)
{
    if(a%b == 0)return b;
    return gcd(b,a%b);
}*/
/*int root(int x)
{
    while(par[x] != x)
    x = par[x];
    return x;
}
void dsu(int x,int y)
{
  if(root(x) == root(y))return;
  par[root(y)] = root(x);
  return;
}
void dfs(int x)
{
    done[x] = true;
    for(int i=0;i<int(adj[x].size());++i)
    {
        int y = adj[x][i];
        if(!done1[y])
        dfs(y);
    }
}*/
int n;
vector<ll>v(maxn),pre(maxn),suff(maxn),a1(maxn),a2(maxn);
ll ans = 1LL*30000000*mod;
ll posi(ll x,ll y)
{
    if(x<y)return y-x;
    return x-y;
}

int main()
{
    thekingisborn;
    cin >> n;
    for(int i=1;i<=n;++i)
    {
        cin >> v[i];
        pre[i] = pre[i-1]+v[i];
    }
    suff[n]=v[n];
    for(int i=n-1;i>=0;--i)
    suff[i] = suff[i+1]+v[i];

    if(n == 4)
    {
    sort(v.begin()+1,v.begin()+n+1);
    cout << v[4]-v[1];
    return 0;
    }
    a1[2] = 1;
    ll it1 = 1;
    for(int i=3;i<n-1;++i)
    {
        ll d1 = ans;
        int it;
        for(it=it1;it<i;++it)
        {
            ll d2 = posi(pre[it],pre[i]-pre[it]);
            if(d2 >= d1)break;
            d1 = d2;
        }
    a1[i] = it1 = it-1;
    }
    a2[n-1] = n-1;
    it1 = n-1;
    for(int i=n-2;i>=3;--i)
    {
        ll d1 = ans;
        int it;
        for(it=it1;it>=i;--it)
        {
            ll d2 = posi(suff[it+1],suff[i]-suff[it+1]);
            if(d2 >= d1)break;
            d1 = d2;
        }
        it1 = a2[i] = it+1;
    }

    for(int i=2;i<=n-2;++i)
    {
        vector<ll>a;
        a.pb(pre[a1[i]]);
        a.pb(pre[i]-pre[a1[i]]);
        a.pb(suff[i+1]-suff[a2[i+1]+1]);
        a.pb(suff[a2[i+1]+1]);
        sort(a.begin(),a.end());
        ans = min(ans,a[3]-a[0]);
        a.clear();
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 8064
N = int(input())
A = [int(T) for T in input().split()]
SumA = [0]*(N+1)
for TN in range(0,N):
    SumA[TN+1] = SumA[TN]+A[TN]
Sum = 0
Mod = 10**9+7
for TA in range(1,N):
    Sum += (A[TA]*SumA[TA])%Mod
print(Sum%Mod)

Measured memory_bytes: 31412
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 int n,m;
  cin>>n;
  vector<string> s(n);
  rep(i,0,n) cin>>s[i];
  cin>>m;
  vector<string> t(m);
  rep(i,0,m) cin>>t[i];
  ///////////
  int ans=0;
  rep(i,0,n){
    int count=0;
    rep(j,0,n){
      if(s[j]==s[i]) count++; 
    }
    rep(j,0,m){
      if(t[j]==s[i]) count--; 
    }
    ans=max(ans,count);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
string s;
vector<vector<int>> nxt;
vector<int> dp;

int solve(int x) {
  if (x >= (int)s.size())  return (x == (int)s.size()) ? 1e7 : 0;
  int &ret = dp[x];
  if (ret != -1)  return ret;
  ret = 1e7;
  
  for (int i = 0; i < 26; ++i) {
    ret = min(ret, 1 + solve(nxt[x][i] + 1));
  }
  return ret;
}

void print(int x) {
  if (x >= (int)s.size()) return ;
  for (int i = 0; i < 26; ++i) {
    if (dp[x] == 1 + solve(nxt[x][i] + 1)) {
      cout << char(i + 'a');
      print(nxt[x][i] + 1);
      return ;
    }
  }
}

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  cin >> s;
  int n = (int)s.size();

  nxt.assign(n, vector<int> (26, n));
  dp.resize(n, -1);

  for (int i = n - 1; i >= 0; --i) {
    if (i < n - 1)  nxt[i] = nxt[i + 1];
    nxt[i][s[i] - 'a'] = i;
  } 

  solve(0);
  print(0);
  cout << '\n';
}

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


int main()
{
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i, n)
    cin >> a[i];
  ll MOD = 998244353;
  vector<ll> dp(s + 1, 0);
  dp[0] = 1;
  rep(i, n)
    for (int j=s; j>=0; j--)
    {
      if (j + a[i] <= s)
        dp[j+a[i]] = (dp[j+a[i]] + dp[j]) % MOD;
      dp[j] = dp[j] * 2 % MOD;
    }
  cout << dp[s] << endl;
}

Measured memory_bytes: 3652
n = int(input())
a = [int(i) for i in input().split()]
itsumono = 10 ** 9 + 7


g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル
for i in range(2, 100003):
    g1.append((g1[-1] * i) % itsumono)
    inverse.append((-inverse[itsumono % i] * (itsumono // i)) % itsumono)
    g2.append((g2[-1] * inverse[-1]) % itsumono)


ruiseki = [0, a[0]]
for i in range(1, n):
    ruiseki += [ruiseki[-1] + a[i]]

ruiseki2 = [ruiseki[-2] - ruiseki[1]]
for i in range(n - 3):
    ruiseki2 += [ruiseki2[-1] + ruiseki2[0] - (ruiseki[i+2] - ruiseki[1]) - (ruiseki[-2] - ruiseki[n-2-i])]


def sum_(n, ruiseki, i):
    num = 0
    if i == 0: #まだなんも選んでない
        num += (ruiseki[n] - ruiseki[i]) * g1[n - i]
    elif i == 1: #左端か右端が1個抜かれてる奴～ｗｗｗ
        num += (ruiseki[n] - ruiseki[i]) * g1[n - i]
        num += (ruiseki[n-i] - ruiseki[0]) * g1[n - i]

    else: #左端からi番目か右端からi番目が抜かれてる奴～ｗｗｗ
        num += (ruiseki[n] - ruiseki[i]) * g1[n] * g2[n - i + 1] * g1[n - i]
        num += (ruiseki[n - i] - ruiseki[i - i]) * g1[n] * g2[n - i + 1] * g1[n - i]

    #左端と右端のが抜かれてる奴～ｗｗｗ　幅がi
        num += (ruiseki2[i - 2]) * g1[n] * g2[n - i + 2] * g1[n - i] * 2

    return num

ans = 0
for i in range(n):
    ans += sum_(n, ruiseki, i)
print(int(ans) % itsumono)

Measured memory_bytes: 28908
#include<bits/stdc++.h>
using namespace std;
int main(){
  int e;
  while(cin>>e&&e){
    int i,j,a,y,m=1000000000;
    for(i=1;i*i*i<=e;++i);
    a=i-1;
    for(i=0;i<=a;++i){
      int b=e;
      b=b-i*i*i;
      for(j=1;j*j<=b;++j);
      y=(j-1);
      b=b-y*y;
      m=min(m,b+y+i);
    }
    cout<<m<<endl;
  }
  return 0;
}



Measured memory_bytes: 3096
<?php
list($n, $m) = explode(" ", trim(fgets(STDIN)));
$sum = $n*($n-1)/2;
for($i = 0; $i < $m; $i++){
    $data[] =  explode(" ", trim(fgets(STDIN)));
}
$data = array_reverse($data);

$uft = new UFT($n);
$sum = ($n * ($n-1)) / 2;
foreach($data as $row){
    $history[] = $sum;
    $s1 = $uft->size($row[0]);
    $s2 = $uft->size($row[1]);
    $uft->unite($row[0], $row[1]);
    $s3 = $uft->size($row[0]);
    if($s1 != $s3){
        $sum -= $s1 * $s2;
    }
}
echo implode("\n", array_reverse($history));

class UFT{
    public $parent;
    public $size;
    public $rank;
    public function __construct($size){
        for($i = 1; $i <= $size; $i++){
            $this->size[$i] = 1;
            $this->rank[$i] = 1;
            $this->parent[$i] = 0;
        }
    }
    public function dump(){
        o("--------------");
        o($this->parent);
        o($this->size);
        o($this->rank);
    }
    public function getRoot($i){
        if($this->parent[$i] == 0){
            return $i;
        }else{
            return $this->getRoot($this->parent[$i]);
        }
    }
    public function unite($i, $j){
        $rootI = $this->getRoot($j);
        $rootJ = $this->getRoot($i);
        if($rootJ == $rootI)return false;//元から同じグループ
        if($this->rank[$rootI] > $this->rank[$rootJ])list($rootI, $rootJ) = [$rootJ, $rootI];
        $this->parent[$rootI] = $rootJ;
        if($this->rank[$rootI] == $this->rank[$rootJ]){
            $this->rank[$rootJ]++;
        }
        $this->size[$rootJ]+=$this->size[$rootI];
        $this->size[$rootI] = '*';
        $this->rank[$rootI] = '*';
    }
    public function size($i){return $this->size[$this->getRoot($i)];}
    public function isUnion($i, $j){return $this->getRoot($i) == $this->getRoot($j);}
}

Measured memory_bytes: 72684
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    if(2*k-1<=n) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d%d", $A, $B);

for($i=1;$i<1100;$i++){
    $eight = floor($i * 0.08);
    $ten = floor($i * 0.1);
    if($eight == $A && $ten == $B){
        echo $i;
        exit;
    }
}
echo -1;

Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
    int N;cin >> N;
    vector<LL> a(N),b(N),x;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> b[i];
        x.pb(a[i]-b[i]);
    }
    sort(ALL(x));
    LL t=0,k=0,cnt=0;;
    for (int i = 0; i < N; i++) {
        if(x[i]<0){
            t-=x[i];
            cnt++;
        }
        else k+=x[i];
    }
    if(t>k){
        puts("-1");
        return 0;
    }
    for (int i = N-1; i >= 0; i--) {
        if(t<=0){
            cout << N-1-i+cnt << endl;
            return 0;
        }
        t-=x[i];
    }
    return 0;

}



Measured memory_bytes: 2936
import collections
N = int(input())
A = list(map(int, input().split()))

x = 0
y = 0
selection = sorted(list(set(A)))[::-1]
c = collections.Counter(A)
for i in selection:
    if c[i] >= 4:
        if x == 0:
            x = i
        if y == 0:
            y = i
    elif c[i] >= 2:
        if x == 0:
            x = i
        elif y == 0:
            y = i
    if x != 0 and y != 0:
        print(x * y)
        exit()

print(x * y)

Measured memory_bytes: 20900
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long m,n,i,j,x,y,z,a[200000],k=0,cnt=0,sum;
    cin>>n>>x;
    for(i=0;i<n;i++)
    {
        cin>>a[i];

    }
    for(i=1;i<n;i++)
    {
        sum=a[i]+a[i-1];
        if(sum>x)
        {
            cnt=cnt+sum-x;
            a[i]=a[i]-(sum-x);
            if(a[i]<0)
            {
                a[i]=0;

            }
        }
    }
    cout<<cnt<<endl;


}


Measured memory_bytes: 4372
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ) {
    if ( A[j] <= x ) {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

int main() {
  int i, q;

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

  q = partition(0, n - 1);

  for ( i = 0; i < n; i++ ) {
    if ( i ) printf(" ");
    if ( i == q ) printf("[");
    printf("%d", A[i]);
    if (i == q) printf("]");
  }
  printf("\n");

  return 0;
} 


Measured memory_bytes: 2952
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
const int MAXN = 2e5 + 10 , MOD = 1e9 + 7;
int fac[MAXN] , finv[MAXN];

void init(){
	fac[0] = fac[1] = 1;
	for(int i = 2 ; i <= 200000 ; ++ i)
		fac[i] = 1ll * i * fac[i - 1] % MOD;
	finv[0] = finv[1] = 1;
	for(int i = 2 ; i <= 200000 ; ++ i)
		finv[i] = MOD - 1ll * (MOD / i) * finv[MOD % i] % MOD;
	for(int i = 2 ; i <= 200000 ; ++ i)
		finv[i] = 1ll * finv[i - 1] * finv[i] % MOD;
}
int C(int x , int y){
	return 1ll * fac[x] * finv[y] % MOD * finv[x - y] % MOD;
}
int go(int a , int b , int c , int d){
	return C(c + d - a - b , c - a);
}
int main(){
	init();
	int H , W , A , B;
	cin >> H >> W >> A >> B;
	int ans = go(1 , 1 , H , W);
	for(int i = 1 ; i <= B ; ++ i)
		(ans += MOD - 1ll * go(1 , 1 , H - A , i) * go(H - A + 1 , i , H , W) % MOD) %= MOD; 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll n;
	cin >> n;

	ll res = -1;
	for (ll i = 111; i <= 999; i += 111)
	{
		if (i >= n)
		{
			res = i;
			break;
		}
	}

	if (res == -1)
	{
		res = 1111;
	}

	println(res);
}


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

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

ll INF = 1000000000;

int main(){
    int h, w; cin >> h >> w;
    deque <pair<int, int>> d;
    vector <vector<int>> dist(h, vector<int>(w, INF));

    vector <string> A(h);
    rep(i, h){
        cin >> A.at(i);
        for(int j = 0; j < w; j ++){
            if(A.at(i).at(j) == '#'){
                d.push_back(make_pair(i, j));
                dist.at(i).at(j) = 0;
            }
        }
    }

    int ans = 0;
    while(!d.empty()){
        auto v = d.front();
        d.pop_front();
        int y = v.first; int x = v.second;
        
        rep(i, 4){
            int ny = y + dy.at(i);
            int nx = x + dx.at(i);
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(A.at(ny).at(nx) == '#') continue;

            A.at(ny).at(nx) = '#';
            dist.at(ny).at(nx) = dist.at(y).at(x) + 1;
            ans = max(ans, dist.at(ny).at(nx));
            d.push_back(make_pair(ny, nx));
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 17120
#include <iostream>
#include <fstream>
#include <cstring>

using namespace std;
int n,i,j,a,b,fr[30],l,ok,v[100001],s,mini;

int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>v[i];
        s+=v[i];
    }
    if(s%10) cout<<s<<'\n';
    else
    {
        mini=1<<30;
        for(i=1;i<=n;i++) if(v[i]%10 && v[i]<mini) mini=v[i];
        if(mini==1<<30) cout<<0<<'\n';
        else cout<<s-mini<<'\n';
    }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main{
	public static int map[][];
	public static int t=0,s=0;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0)break;
			int data[][]=new int[n][n];
			int num[]=new int[n];
			for(int i=0;i<n;i++){//人数
				num[i]=sc.nextInt();
				for(int j=0;j<num[i];j++){
					data[i][j]=sc.nextInt();
				}
			}
			int know=sc.nextInt();
			int k[]=new int[know];
			for(int i=0;i<know;i++){
				k[i]=sc.nextInt();
			}
			int cnt=0,ans=0,x=0;
			for(int i=0;i<n;i++){
				cnt=0;
				for(int j=0;j<num[i];j++){
					for(int l=0;l<know;l++){
						if(data[i][j]==k[l]){
							cnt++;
						}
					}
				}
				if(cnt==know){
					ans=i+1;x++;
				}else if(ans==0)ans=-1;
			}
			if(x>1)ans=-1;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 62848
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Data.List (unfoldr)


main :: IO ()
main = do
  n <- readLn
  putStrLn $ if solve n then "Yes" else "No"

solve :: Int -> Bool
solve n = n `mod` s n == 0

s :: Int -> Int
s = sum . unfoldr f where
  f 0 = Nothing
  f x = Just (x `mod` 10, x `div` 10)


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

int main(){
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    for(int i=0; i<A; i++) cin >> a[i];
    for(int i=0; i<B; i++) cin >> b[i];
    int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
    for(int i=0; i<M; i++){
        int x, y, c;
        cin >> x >> y >> c;
        int res = a[x-1] + b[y-1] - c;
        ans = min(ans, res);
    }
    cout << ans << endl;
    return 0;
}


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

#define fi first
#define se second
typedef pair<int,int> PII;


int ans, cnt;
string s;

int main() {
    cin >> s;
    ans = s.length();

    for (int i = 0; i < s.size(); i++) {
        cnt += (s[i] == 'S');
        if (cnt && s[i] == 'T') ans -= 2, cnt--;
    }
    cout << ans;
}


Measured memory_bytes: 640
n = int(input())
a = [n]
if n != 2:
    a.append(n - 1)

def div_(N, k):
    while N % k == 0:
        N /= k
    if N % k == 1:
        a.append(k)

for k in range(2, int(n ** 0.5) + 1):
    if n % k == 0:
        div_(n,k)
        if k != n / k:
            div_(n, n // k)

    if (n - 1) % k == 0:
        a.append(k)
        if k != (n - 1) / k:
            a.append((n - 1) // k)

print(len(a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
int main(){
	int n,x;
	cin>>n>>x;
	if(x==1 || x==2*n-1){
		cout<<"No";
		return 0;
	}
	else{
		cout<<"Yes"<<endl;
		if(n==2){
			cout<<1<<endl<<2<<endl<<3<<endl;
			return 0;
		}
		else{
			if(x==2){
				for(int i=5;i<=n+2;i++){
					cout<<i<<endl;
				}
				cout<<4<<endl<<2<<endl<<1<<endl<<3<<endl;
				for(int i=n+3;i<=2*n-1;i++){
					cout<<i<<endl;
				}
				return 0;
			}
			else{
				int cur = 1;
				for(int i=1;i<=n-2;i++){
					if(cur<x-2 || cur>x+1){
						cout<<cur<<endl;
						cur++;
					}
					else{
						cur=x+2;
						cout<<cur<<endl;
						cur++;
					}
				}
				cout<<x-2<<endl<<x<<endl<<x+1<<endl<<x-1<<endl;
				for(int i=n+3;i<=2*n-1;i++){
					if(cur<x-2 || cur>x+1){
						cout<<cur<<endl;
						cur++;
					}
					else{
						cur=x+2;
						cout<<cur<<endl;
						cur++;
					}
				}
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

const int MAX_T = 100001;

int in[MAX_T];
int out[MAX_T];

int main()
{
	int N,T,l,r,cnt=0,max=0;
	scanf("%d",&N);
	scanf("%d",&T);
	fill(in,in+T+1,0);
	fill(out,out+T+1,0);
	for(int i=0;i<N;i++){
		scanf("%d",&l);
		scanf("%d",&r);
		in[l]++;
		out[r]++;
	}
	for(int i=0;i<=T;i++){
		if(in[i] > 0){
			cnt += in[i];
		}
		if(out[i] > 0){
			cnt -= out[i];
		}
		if(max < cnt){
			max = cnt;
		}
	}
	cout << max << "\n";
}

Measured memory_bytes: 3932