akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <limits>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;



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

  ll n;
  std::cin>>n;

  std::vector<std::vector<ll>> graph(n),graph_inv(n);

  rep(i,0,n){
    ll a;
    std::cin>>a;
    a--;
    graph[a].push_back(i);
    graph_inv[i].push_back(a);
  }

  std::vector<ll> a(n,-1),out(n,-1);

  std::queue<ll> que;

  rep(i,0,n){
    out[i]=graph[i].size();
    if(out[i]==0)que.push(i);
  }

  while(!que.empty()){
    ll e=que.front();que.pop();

    std::set<ll> used;
    for(ll next:graph[e])used.insert(a[next]);

    ll num=0;
    while(used.find(num)!=used.end())num++;

    a[e]=num;

    for(ll par:graph_inv[e]){
      out[par]--;
      if(out[par]==0)que.push(par);
    }
  }

  ll base=0;
  while(out[base]==0)base++;

  ll min[2];
  {
    std::set<ll> used;
    for(ll next:graph[base])used.insert(a[next]);

    min[0]=0;
    while(used.find(min[0])!=used.end())min[0]++;

    min[1]=min[0]+1;
    while(used.find(min[1])!=used.end())min[1]++;
  }

  rep(i,0,2){
    std::vector<ll> a2=a,out2=out;

    a2[base]=min[i];

    ll now=graph_inv[base][0];

    while(now!=base){
      std::set<ll> used;
      for(ll next:graph[now])used.insert(a2[next]);

      ll num=0;
      while(used.find(num)!=used.end())num++;

      a2[now]=num;

      now=graph_inv[now][0];
    }

    std::set<ll> used;
    for(ll next:graph[base])used.insert(a2[next]);

    ll num=0;
    while(used.find(num)!=used.end())num++;

    if(num==a2[base]){
      std::cout<<"POSSIBLE\n";
      return 0;
    }
  }

  std::cout<<"IMPOSSIBLE\n";

  return 0;
}

Measured memory_bytes: 27264
$n, $m = gets.split.map &:to_i
$as = gets.split.map &:to_i

$as.sort!

$as_expand = Array.new(10**5 + 1, 0)
$as.each{ |a|
	$as_expand[a] += 1
}

$sum_tail = Array.new(10**5 * 2 + 1, 0)
$count_tail = Array.new(10**5 * 2 + 1, 0)

(10**5).downto(0){ |i|
	if $as_expand[i] != 0 then
		$count_tail[i] = $count_tail[i + 1] + $as_expand[i]
		$sum_tail[i] = $sum_tail[i + 1] + i * $as_expand[i]
	else
		$count_tail[i] = $count_tail[i + 1] 
		$sum_tail[i] = $sum_tail[i + 1]
	end
}

# 握手による幸福度向上値をxとし、(x以上の組み合わせの数)>=mとなるxを2項探索で探す

def calc(x, is_pruned)
	count = 0

	$as.each_with_index{ |a,i|
		if x > a then
			count += $count_tail[x - a]
		else
			count += $n
		end
		
		# 探索中はM以上になったら即打ち切り
		if is_pruned && count >= $m then
			break
		end
	}

	count
end

def calc_sum(x)
	sum = 0

	$as.each_with_index{ |a, i|
		if x > a then
			sum += $sum_tail[x - a] + a * $count_tail[x - a]
		else
			sum += $sum_tail[0] + a * $n
		end
	}

	sum
end


min = $as[0] * 2
max = $as[-1] * 2
current = (min + max) / 2
result = nil

while min != max 
	result = calc(current, true)
	
	if result >= $m then
		if current != min then
			min = current
		else
			break
		end
	else
		max = current
	end

	current = (min + max) / 2
end

# 取り直し
result = calc(current, false)

score = calc_sum(current)

if result != $m then
	score -= current * (result - $m)
end

puts score


Measured memory_bytes: 12168
#include <bits/stdc++.h>
using namespace std;
const int n=1e5+10;
bitset<n> isprime;
vector<int>answer;
//here are different comments
//to test the expirement
//oh wow hi
void sieve()
{
    isprime[0]=isprime[1]=0;
    for(int p=2; p<=n; ++p)
        if(isprime[p])
            for(int m=2*p; m<n; m+=p)
                isprime[m]=0;

}


int the2017ers[n];
void is2017()
{
    int sum=0;
    for (int p=1; p<=n; p++)
    {

        sum+=(isprime[p]&&isprime[(p+1)/2]);
        the2017ers[p]=sum;

    }

}

int main()
{

    isprime.set();
    sieve();
    is2017();
    int tc,l,r;
    cin>>tc;
    while(tc--)
    {
        cin>>l>>r;
        cout<<the2017ers[r]-the2017ers[l-1]<<endl;
    }


    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

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

    ll a, b;
    cin >> a >> b;

    ll S = a+b;

    ll X=0;
    for(int i=0; i<N-2; i++){
        ll x;
        cin >> x;
        X^=x;
    }

    ll z=(S-X)/2;
    if(S<X || (S-X)%2){
        cout << -1 << endl;
        return 0;
    }else if(((~z)&X)==X){
        ll ans=z;
        for(ll i=(1LL<<50); i>0; i>>=1){
            //cout << (ans+(i&X)) << endl;
            if((ans+(i&X))<=a){
                ans+=i&X;
            }
        }
        if(ans>0 && a-ans>=0){
            cout << a-ans << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3568
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:128777216")

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <sstream>

#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>

#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <string.h>

#include <memory.h>
#include <cassert>
#include <time.h>
#include <functional>

using namespace std;

#define forn(i,n) for (int i = 0; i < (int)(n); i++)
#define fornd(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define forab(i,a,b) for (int i = (int)(a); i <= (int)(b); i++)
#define forabd(i, b, a) for (int i = (int)(b); i >= (int)(a); i--)
#define forit(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)

#define _(a, val) memset (a, val, sizeof (a))
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long lint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vii;

const lint LINF = 1000000000000000000LL;
const int INF = 1000000000;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;

#ifdef MY_DEBUG
#define dbgx( x ) { cerr << #x << " = " << x << endl; }
#define dbg( ... ) { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#else
#define dbgx( x ) {  } 
#define dbg( ... ) {  } 
#endif

void prepare(string s) {
#ifdef MY_DEBUG
  freopen("input.txt", "r", stdin);
  //freopen ("output.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen ("output.txt", "w", stdout);
#endif
}

map<string, int> m;

void read() {
  int n;
  scanf("%d", &n);
  forn(i, n) {
    string s;
    cin >> s;
    m[s]++;
  }
  scanf("%d", &n);
  forn(i, n) {
    string s;
    cin >> s;
    m[s]--;
  }
  int ans = 0;
  for (auto s : m) {
    ans = max(ans, s.second);
  }
  printf("%d\n", ans);
}

void solve() {

}

int main() {
  prepare("");

  read();
  solve();
  dbg("Clock = %.3f\n", clock() / (double)CLOCKS_PER_SEC);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[200010];
int main()
{
	int n, m, x;
	
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		a[x]++;
	}
	sort(a + 1, a + n + 1);
	int ans = n;
	for (int i = n; i > n - m; i--) {
		ans -= a[i];
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define M 55
#define N 1005
#define ll long long
#define oo 1000000000
#define mod 5557
using namespace std;
int ned,n,m,a,b,c,d;
ll st,ed;
int main(){
	int i,j;
	cin>>n>>a>>b>>c>>d;
	m=n-1;
	ned=b-a;
	for(i=0;i<=n;i++){//jia
		j=m-i;
		st=1LL*i*c-1LL*j*d;
		ed=1LL*i*d-1LL*j*c;
		//printf("%lld %lld\n",st,ed); 
		if(st<=ned&&ned<=ed){
			break;
		}
	}
	if(i!=n+1){
		puts("YES");
		return 0;
	}else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int mod = 1000000007;
int fail(){
  cout << 0 << endl;
  return 0;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int m = (n+1)/2;
  vector<int> v(m);
  rep(i,n){
    if((n&1)==(a[i]&1)) return fail();
    int j = a[i]/2;
    if(j>=m || v[j]==2) return fail();
    v[j]++;
  }
  if((n&1)&&v[0]>1) return fail();
  int ans = 1;
  rep(i,n/2) ans = ans*2%mod;
  cout << ans << endl;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
	ll a, b; cin >> a >> b;
	ll cnt = 0;
	while (a < b)
	{
		cnt++;
		a *= 2LL;
	}
	if (a == b) cnt++;
	cout << cnt;
}

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int a[3];
  rep(i,3) cin >> a[i];
  sort(a,a+3);
  int cnt = 0;
  cnt +=a[2] -a[1];
  if((a[1]-a[0]) %2 == 0)
  {
    cnt += (a[1] -a[0])/2;
  }
  else{
    cnt += (a[1]-a[0] +1)/2 + 1;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 100

#define W 1
#define G 2
#define B 3
#define MY_NULL -1

int a[N+1][N+1]={0};
int d[N+1]={0};
int f[N+1]={0};
int color[N+1]={0};
int stack[N+1]={0};
int top=0;
int time=0,n=0;

void dfs(void);
void visit(int);
int next(int);
void push(int);
int pop(void);

int main(){
  int u,k,v,i,j;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d %d",&u,&k);
    for(j=0; j<k; j++){
      scanf("%d",&v);
      a[u][v]=1;
    }
  }

  dfs();
  
  for(i=1; i<=n; i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }
  
  return 0;
}

void dfs(void){
  int i;
  for(i=1; i<=n; i++){
    color[i]=W;
  }
  time=0;
  for(i=1; i<=n; i++){
    //printf("DEBUG1\n");
    if(color[i]==W){
      visit(i);
    }
  }
}

void visit(int r){
  int u,v,i;
  int j;
  push(r);
  color[r]=G;
  d[r]=++time;
  while(top>0){
    //printf("DEBUG2\n");
    u=stack[top-1];
    v=next(u);
    //printf("u=%d,v=%d\n",u,v);
    //printf("top=%d, ",top);
    //for(j=0; j<=top; j++) printf("%d ",stack[j]);
    //printf("\n");
    if(v!=MY_NULL){
      //printf("DEBUG3\n");
      if(color[v]==W){
	//printf("DEBUG4\n");
	push(v);
	color[v]=G;
	d[v]=++time;
      }
    }else{
      pop();
      color[u]=B;
      f[u]=++time;
    }
  }
}

int next(int u){
  int i;
  for(i=1; i<=n; i++){
    if(a[u][i]==1){
      /*if(color[i]!=W) return MY_NULL;
	else return i;*/
      if(color[i]==W) return i;
    }
  }
  return MY_NULL;
}

void push(int n){
  stack[top]=n;
  top++;
}

int pop(void){
  int n;
  top--;
  n=stack[top];
  stack[top]=0;
  return n;
}



Measured memory_bytes: 2104
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A1[] = new int[N];
		int A2[] = new int[N];
		for(int i = 0; i < N; i++) {
			A1[i] = sc.nextInt();
		}
		for(int i = 0; i < N; i++) {
			A2[i] = sc.nextInt();
		}
		
		int sum_A1[] = new int[N];
		int sum_A2[] = new int[N];
		sum_A1[0] = A1[0];
		for(int i = 1; i < N; i++) {
			sum_A1[i] = sum_A1[i - 1] + A1[i];
		}
		sum_A2[N - 1] = A2[N - 1];
		for(int i = N - 2; i >= 0; i--) {
			sum_A2[i] = sum_A2[i + 1] + A2[i];
		}
		
		int ans = 0;
		for(int i = 0; i < N; i++) {
			ans = Math.max(ans, sum_A1[i] + sum_A2[i]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23380
#include <stdio.h>

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
	int64_t N;
	std::cin >> N;
	std::vector<int64_t> A(N);

	for (int64_t x = 1; x <= 100; ++x)
	{
		for (int64_t y = 1; y <= 100; ++y)
		{
			for (int64_t z = 1; z <= 100; ++z)
			{
				int64_t v = x * x + y * y + z * z + x * y + y * z + z * x;
				if (v <= N) {
					++A[v - 1];
				}
			}
		}
	}

	for (int64_t n = 0; n < N; ++n)
	{
		std::cout << A[n] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

int main() {
    string s;
    cin >> s;
    int w;
    cin >> w;
    int tmp_num = 0;
    while(1) {
        if ( tmp_num > s.length() - 1 ) {
            break;
        } 
        cout << s[tmp_num];
        tmp_num += w;
    }
    cout << endl;
    return 0;
}


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

using namespace std;

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

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

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	cout << fixed << setprecision(10);
	double c = m * 0.5 + h * 30, d = m * 6;
	double arg = c - d;
	if (arg < 0) arg += 360;
	arg = arg * M_PI / 180;
	cout << sqrt(b * b + a * a - 2 * a * b * cos(arg)) << endl;
    
    return 0;
}


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

template<typename T>
bool chmax(T &a, T b){
  if(a < b){
    a=b;
    return true;
  }
  return false;
}


int main(){
  int N; cin >> N;
  vector<vector<int>> act(N, vector<int>(3)); 
  for(int i=0;i<N;i++){
    cin >> act[i][0] >> act[i][1] >> act[i][2];
  }
  vector<vector<int>> dp(N+1, vector<int>(3, 0));
  for(int i=0;i<N;i++){
    //case A
    chmax(dp[i+1][0], dp[i][1]+act[i][0]);
    chmax(dp[i+1][0], dp[i][2]+act[i][0]);
    // case B
    chmax(dp[i+1][1], dp[i][0]+act[i][1]);
    chmax(dp[i+1][1], dp[i][2]+act[i][1]);
    // case C
    chmax(dp[i+1][2], dp[i][0]+act[i][2]);
    chmax(dp[i+1][2], dp[i][1]+act[i][2]);    
  }
  int res=0;
  for(int i=0;i<3;i++) chmax(res, dp[N][i]);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 11136
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll X, Y;
    cin >> X >> Y;
    rep(i, 150){
        rep(j, 150){
            if(i + j == X && 2*i + 4*j == Y){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
}

Measured memory_bytes: 3620
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    string s;cin>>s;
    int x=0;
    int maxm=-1999999;
    for(int i=0;i<n;i++){
        if(s[i]=='I')
            x++;
        else
            x--;
        chmax(maxm,x);
    }
    chmax(maxm,0);
    cout<<maxm<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 384
#include<stdio.h>
int main (void)
{
    int a;
    int b;
    scanf("%d %d",&a,&b);
    if(a > 12)
        printf("%d",b);
    else if(13> a && a > 5)
        printf("%d",b/2);
    else
        printf("%d",0);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

void Main(){
	int n,m; cin >> n >> m;
	UnionFind uf(n);
	Rep(m){
		int a,b; cin >> a >> b;
		a--; b--;
		uf.unite(a,b);
	}
	int ans = 0;
	rep(i,n){
		ans = max(ans, uf.size(i));
	}
	cout << ans << endl;
}


Measured memory_bytes: 3988
#include<stdio.h>
 int main(void)
 {
     int A,B,C,D;
     int S=0,T=0;

     scanf("%d%d%d%d",&A,&B,&C,&D);

     if(A>B) S=B;
     else S=A;

     if(C>D) T=D;
     else T=C;

     printf("%d\n",S+T);
     return 0;
 }


Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
  if a[i]+a[i+1]>x: #xを上回る時のみ操作を行う
    temp=a[i]+a[i+1]-x #減らさなきゃいけない個数
    ans+=temp
    if a[i+1]>=temp: #減らすのは出来るだけ右側
      a[i+1]-=temp
    else:
      a[i+1]=0
print(ans)

Measured memory_bytes: 14252
#include<iostream>
using namespace std;
int main(){
    int card[4][13],n,m;
    char a;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>m;
        if(a=='S') card[0][m-1]='true';
        if(a=='H') card[1][m-1]='true';
        if(a=='C') card[2][m-1]='true';
        if(a=='D') card[3][m-1]='true';
        
    }
    for(int j=0;j<4;j++){
        for(int k=0;k<13;k++){
            if(card[j][k]!='true' && j==0){
                a='S';
                cout<<a<<' '<<k+1<<endl;
            }else if(card[j][k]!='true' && j==1){
                a='H';
                cout<<a<<' '<<k+1<<endl;
            }else if(card[j][k]!='true' && j==2){
                a='C';
                cout<<a<<' '<<k+1<<endl;
            }else if(card[j][k]!='true' && j==3){
                a='D';
                cout<<a<<' '<<k+1<<endl;
            }
        }
    }return 0;
}


Measured memory_bytes: 3040
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    long x;
  	int cnt=0;
    vector <int> N;
    //int min = INF;
    int max = 0;
  	long a;
    cin >> x;
    a = 100;
    while(1){
        cnt++;
      	//cout << a <<endl;
        if(a*1.01 >= x){
          	//cout << a <<endl;
            cout << cnt << endl;
            return 0;
        }
        a = a*1.01;
    }
  return 0;
}

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

using namespace std;

#define ll long long
#define endl "\n"

int main() {
  ll n;
  cin >> n;
  ll a[n], b[n];
  for (ll i = 0; i < n; ++i)
    cin >> a[i], b[i] = a[i];
  sort(b, b + n);
  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    if (a[i] != b[i])
      ++ans;
  }
  if (ans > 2) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>

using namespace std;

#define D(x) x
#define REP(i,a,b) for (int i = (a); i < (b); ++i)
#define REPR(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;

bool solve() {
    int m = 0;
    int N; cin >> N;
    VI deg(N,0);
    REP(i,0,N) {
        int a;
        cin >> a;
        m = max(m,a);
        deg[a]++;
    }

    deg[m] -= 2;

    for (int x = m-1; x >= m/2 + 1; x--) {
        deg[x] -= 2;
    }

    if (m % 2 == 0)
        deg[m/2]--;

    REP(i,0,(m+1)/2+1) {
        if (deg[i] != 0)
            return false;
    }

    REP(i,m/2+1, m+1) {
        if (deg[i] < 0)
            return false;
    }

    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(12) << fixed;

    if (solve())
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;
	return 0;
}


Measured memory_bytes: 384
import sys
from math import ceil
def input(): return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    """
    変数変換して格子点を数え上げようとして爆死。。。
    素直に問題文からa, b. cは2Kの倍数と分かるので、
    K:odd　→　a, b, cはKの倍数であり、かつこれは必要十分
    K:even →　a, b, cはK//2の倍数であり、必要十分にするには
    　　　　　 a, b, c = 0 (mod K) or a, b, c = K//2 (mod K)
    """
    if K % 2 != 0:
        val1 = (N // K) * (N // K - 1) * (N // K - 2)
        val2 = (N // K) * (N // K - 1) * 3
        val3 = N // K
        print(val1 + val2 + val3)
    else:
        val1 = (N // K) * (N // K - 1) * (N // K - 2) 
        val2 = (N // K) * (N // K - 1) * 3
        val3 = N // K
        # a, b, c = K//2 (mod K)の場合、N-K//2で=0 (mod K)として扱える。
        # ただしそのときa=0も許容される（本来それはK//2を意味するから）ことに注意
        N -= K // 2
        val4 = (N // K + 1) * (N // K) * (N // K - 1)
        val5 = (N // K + 1) * (N // K) * 3
        val6 = N // K + 1
        print(val1 + val2 + val3 + val4 + val5 + val6)


if __name__ == "__main__":
    main()


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

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

int main(int argc, char const *argv[])
{
	int a,d,n;
	while(cin>>a>>d>>n,a)
	{
		if(pcheck(a)) --n;
		while(n>0)
		{
			a+=d;
			if(pcheck(a)) --n;
		}
		cout<<a<<endl;
	}
	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
const ll mod = 1000000007;
int main()
{
  int a, b;
  cin >> a >> b;
  int ans;
  if (b%a==0) ans = a+b;
  else ans = b-a;
  cout << ans << endl;
  return 0;
}

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

int n,m,l=1,r;

struct point{double x,y;}t,w,q[N],cnt;
point operator +(point a,point b){
	return (point){a.x+b.x,a.y+b.y};
}
point operator -(point a,point b){
	return (point){a.x-b.x,a.y-b.y};
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();m=read();
	for (int i=1;i<=n;i++){
		t.y=read();t.x=read();t.y*=t.x;cnt=cnt+t;
		while (cnt.x>m+1e-9){
			if (q[l].x<=cnt.x-m) cnt=cnt-q[l++];
			else {
				w.x=cnt.x-m;w.y=w.x*q[l].y/q[l].x;
				q[l]=q[l]-w;cnt=cnt-w;
			}
		}
		printf("%.10lf\n",cnt.y/cnt.x);
		while (l<=r&&q[r].y/q[r].x>=t.y/t.x) t=t+q[r--];
		q[++r]=t;
	}
	return 0;
}

Measured memory_bytes: 18688
#include <stdio.h>
int main(){
  int N,i,j,k,l,sum,a,b,r,x;
  scanf("%d",&N);
  sum=0;
  for(i=1;i<=N;i++){
    for(j=i;j<=N;j++){
      for(k=j;k<=N;k++){
        if(i==k) x=1;
        else if(i==j || j==k) x=3;
        else x=6;
        a=j;
        b=i;
        r=a%b;
        while(r!=0){
          a=b;
          b=r;
          r=a%b;
        }
        a=k;
        r=a%b;
        while(r!=0){
          a=b;
          b=r;
          r=a%b;
        }
        sum=sum+b*x;
      }
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 1732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;

        static void SolveA()
        {
            int n = ReadAndParseInt();
            var a = ReadAndParseIntArr();
            var dic = new Dictionary<int, int>();
            
            foreach(int len in a)
            {
                if( dic.ContainsKey(len))
                {
                    dic[len]++;
                }
                else
                {
                    dic.Add(len, 1);
                }
            }
            var validBars = new List<long>();
            foreach (var pair in dic)
            {
                if( pair.Value >= 4)
                {
                    validBars.Add(pair.Key);
                    validBars.Add(pair.Key);
                }else if( pair.Value >= 2)
                {
                    validBars.Add(pair.Key);
                }
            }
            if( validBars.Count <= 1)
            {
                Console.WriteLine(0);
                return;
            }

            validBars.Sort();
            validBars.Reverse();
            long ans = validBars[0] * validBars[1];
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 22752
# coding: utf-8
# ?????????????????¨????????????
class Dice(object):
	def __init__(self):
		# ????????¶???
		self.dice = (2, 5), (3, 4), (1, 6) # x, y, z
		self.ax = [[0, False], [1, False], [2, False]]
		self.axmap = [0, 1, 2]
		self.mm = {"N": (0, 2), "S": (2, 0), "E": (1, 2), "W": (2, 1), "R": (0, 1), "L": (1, 0)}

	def rotate(self, dir):
		def rot(k, r):
			t = self.axmap[r]
			self.axmap[k], self.axmap[r] = t, self.axmap[k]
			self.ax[t][1] = not self.ax[t][1]

		rot(*self.mm[dir])

	def front(self): return self.value(0, True)
	def rear(self): return self.value(0, False)
	def right(self): return self.value(1, True)
	def left(self): return self.value(1, False)
	def top(self): return self.value(2, True)
	def bottom(self): return self.value(2, False)
	def value(self, ax, d):
		a = self.ax[self.axmap[ax]]
		return self.dice[a[0]][a[1] if d else not a[1]]

if __name__=="__main__":
	dice = Dice()
	labels = input().split()
	q = int(input())
	def tf(p, f, d):
		for _ in range(4):
			if p==f(): break
			dice.rotate(d)

	for _ in range(q):
		a, b = input().split()
		p = labels.index(a) + 1
		f = dice.top
		tf(p, f, "N")
		if p!=f(): tf(p, f, "E")
		
		p = labels.index(b) + 1
		f = dice.front
		tf(p, f, "R")

		print(labels[dice.right()-1])

Measured memory_bytes: 7752
#include<iostream>
#include<string.h>
using namespace std;
int main(){
	int N,K,num[102]={0};
	cin>>N>>K;//b 机器人在  K  点 
	for(int i=0;i<N;i++){
		cin>>num[i];
	}
	int sum=0;
	for(int i=0;i<N;i++){
		//遍历判断  n  个  点 
		if (abs(num[i]-0)<abs(num[i]-K)){
			sum=sum+abs(num[i]-0)*2;
		}else{
			sum=sum+abs(num[i]-K)*2;
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

template<class like_bool> inline void YES(like_bool condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class like_bool> inline void Yes(like_bool condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class like_bool> inline void POSS(like_bool condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class like_bool> inline void Poss(like_bool condition){ if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class like_bool> inline void First(like_bool condition){ if(condition)cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    string day[7] = {"sat", "sun", "mon", "tue", "wed", "thu", "fri"};
    int X;
    cin >> X;
    cout << day[(X + 5) % 7] << endl;
}



Measured memory_bytes: 3204
/*
 * Matheus Oliveira
 * 09:02:47 17/05/2020
 * b.cpp
*/

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

#define EPS
#define INF
#define MAXN 10100
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define sc(x) scanf("%d", &x);
#define sc2(x, y) scanf("%d %d", &x, &y);
#define sc3(x, y, z) scanf("%d %d %d", &x, &y, &z);
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, bg, ed) printf("%s: ", #x); for(int i = bg; i < ed; i++) printf("%d%c", x[i], (i == ed-1) ? '\n' : ' ');

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

char inp[MAXN];

int main() {
	int sz, k;

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

	scanf("%s", inp);
	sz = strlen(inp);
	
	for(int i = 0; i < min(sz, k); i++) printf("%c", inp[i]);
	if(sz > k) printf("...");
	printf("\n");

	return 0;
}

Measured memory_bytes: 3724
#include <iostream>

using namespace std;

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

   int tests[testMany];
   int totalTime = 0;

   for(int i = 0; i < testMany; i++) {
      cin >> tests[i];
      totalTime += tests[i];
   }

   int drinkMany;
   cin >> drinkMany;

   int drinks[drinkMany][2];

   for (int d = 0; d < drinkMany; d++) {
      cin >> drinks[d][0]; // テスト番号
      cin >> drinks[d][1]; // テスト時間の更新値
   }

   for (int d = 0; d < drinkMany; d++) {
      int testNum = drinks[d][0] - 1;
      int newTime = drinks[d][1];
      int newTotalTime = totalTime - tests[testNum] + newTime;
      cout << newTotalTime << endl;
   }
}

Measured memory_bytes: 256
def f(x):
    return x*(x+1)//2


s = input()
ans = 0
if len(set(s)) == 1:
    ss = len(s)
    ans = ss*(ss+1)//2
    print(ans)
    exit()

ss = s.replace('><' , '> <')
lst = ss.split()

for l in lst:
    a = l.count('<')
    b = l.count('>')
    
    if a == 0:
        ans += f(b)
    elif b == 0:
        ans += f(a)
    else:
        mn = min(a,b)
        mx = max(a,b)
        ans += f(mx) + f(mn-1)
print(ans)

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

template<typename T> class BinaryIndexedTree {
  vector<T> vec;
  const ll n, mod;

public:
  BinaryIndexedTree(T _n, ll mod) : vec(_n + 1), n(_n), mod(mod) {}

  T query(ll x) {
    T ret = 0;
    for(ll i = x; i > 0; i -= i & (-i)) (ret += vec[i]) %= mod;
    return ret;
  }

  void update(ll x, T k) {
    for(ll i = x; i <= n; i += i & (-i)) (vec[i] += k) %= mod;
  }
};

int main(void) {
  ll A, B, P;
  while(cin >> A >> B >> P, B++, A && B && P) {
    vector<pair<string, ll>> s(B - A);
    REP(i, 0, B - A) s[i] = pair<string, ll>(to_string(i + A), i);
    sort(s.begin(), s.end());

    ll ans = 0;
    BinaryIndexedTree<ll> bit(B - A + 1, P);
    bit.update(1, 1);
    REP(i, 0, B - A) {
      ll x = s[i].second + 2;
      bit.update(x, bit.query(x));
    }
    cout << (bit.query(B - A + 1) - 1 + P) % P << endl;
  }
}


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

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

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



Measured memory_bytes: 3116
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const ll inf=998244353;

inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
ll num[105];
int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> num[i];
    }
    sort(num,num+n);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(num[i]==num[j]||num[j]==num[k]||num[i]==num[k])continue;
                if(num[i]+num[j]>num[k])
                    ans++;
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3636
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define fi first
#define se second

using namespace std;
using ll = long long;
using namespace __gnu_pbds;


template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e5 + 10 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7;

ll a[N];

void solve() {
    int n , k;
    cin >> n >> k;
    for(int i = 1; i <= n; i ++) {
        cin >> a[i];
        if(i > k) {
            if(a[i] > a[i-k]) {
                cout << "Yes\n";
            }
            else {
                cout << "No\n";
            }
        }
    }

}
/*
*/
main() {
    ios;
    int tt = 1;
   // cin >> tt;
    while(tt --) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long int
using namespace std;

bool isParindrome(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}

int main(void) {
  string s;
  cin >> s;
  
  bool ans = true;
  if (!isParindrome(s)) ans = false;
  if (!isParindrome(s.substr(0,s.size()/2))) ans = false;
  cout << (ans? "Yes" : "No") << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#!/mnt/c/Users/moiki/bash/env/bin/python
N,K = map(int, input().split())
X = list(map(int, input().split()))

if 0 in X:
    K -= 1
    if K == 0:
        print(0)
        exit(0)

minus = list(filter(lambda x: x<0, X))
minus = list(map(lambda x: abs(x), minus))
minus = list(reversed(minus))

pluss = list(filter(lambda x: x>0, X))

ans = 10**11

for n_left in range(0, K+1): 
    n_right = K - n_left
    i_right = n_right - 1
    i_left  = n_left - 1

    if i_right >= len(pluss):
        continue
    if i_left >= len(minus) :
        continue

    tmp = 0
    if i_left >= 0:
        tmp += 2 * minus[i_left]
    if i_right >= 0:
        tmp += pluss[i_right]
    ans = min(ans, tmp)

for n_right in range(0, K+1): 
    i_right = n_right - 1
    n_left = K - n_right
    i_left = n_left - 1
    if i_right >= len(pluss):
        continue
    if i_left >= len(minus) :
        continue
    tmp = 0
    if i_right >= 0:
        tmp += 2 * pluss[i_right]
    if i_left >= 0:
        tmp += minus[i_left]
    ans = min(ans, tmp)

print(ans)
    


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

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;
    multiset<int> st;
    st.insert(a[0]);
    st.insert(-3);
    for(int i=1;i<n;i++){
        
        auto itr = st.lower_bound(a[i]);
        itr--;
        if(*itr<0 ||  *itr >= a[i]){
            //cerr<<*itr<<" "<<a[i]<<endl;
            st.insert(a[i]);
        }
        else {
            st.erase(itr);
           
            st.insert(a[i]);
        }
    }
    cout<<st.size()-1<<endl;
    
    
}

Measured memory_bytes: 5760
import java.io.*;
import java.util.BitSet;
import java.util.StringTokenizer;

public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter pw =new PrintWriter(new OutputStreamWriter(System.out));
static StringTokenizer st;
static BitSet bs;
static int TC,N,M;
    public static void main(String[] args) throws IOException {
	// write your code here
        st= new StringTokenizer(br.readLine());
        N = Integer.parseInt(st.nextToken());
        M = Integer.parseInt(st.nextToken());
pw.println(N==M?"Yes":"No");pw.flush();
    }
}


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

int main()
{
  int N,i,j,v,count=0,flag;
  int *A;

  scanf("%d",&N);
  if(N<1 || N>100) exit(2);
  A=(int *)malloc(sizeof(int)*N);

  for(i=0;i<N;i++)
    {
      scanf("%d",&A[i]);
      if(A[i]<0 || A[i]>100) exit(1);
    }

  flag=1;
  while(flag)
    {
      flag=0;
      for(j=N-1;j>=1;j--)
	{
	  if(A[j]<A[j-1])
	    {
	      v=A[j];
	      A[j]=A[j-1];
	      A[j-1]=v;
	      flag=1;
	      count++;
	    }
	}
    }

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

  printf("%d\n",count);


  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
int main(void){
    // Your code here!
    string str;
    cin>>str;
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        string o;
        cin>>o;
        int A,B;
        cin>>A>>B;
        string c;
        if(o=="print"){
            cout<<str.substr(A,B-A+1)<<endl;
        }
        else if(o=="reverse"){
            c=str.substr(A,B-A+1);
            reverse(c.begin(),c.end());
            str=str.erase(A,B-A+1);
            str=str.insert(A,c);

        }
        else if(o=="replace"){
            cin>>c;
            str=str.substr(0,A)+c+str.substr(B+1,str.size()-A-1);
        }
    }
}



Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int num=n;
		int s=0;
		while(num!=0) {
			s+=num%10;
			num/=10;
		}
		System.out.println(n%s==0?"Yes":"No");
	}
}

Measured memory_bytes: 22228
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
using namespace std;
#pragma warning(disable : 4996)

long double calc_dist(pair<long double, long double> a, pair<long double, long double> b) {
	return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second));
}

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)a[i] = i;
	vector<pair<long double, long double>> points(n);
	long double ans = 0;
	long double over = 1;

	for (int i = 0; i < n; i++) {
		over *= (i + 1);
		cin >> points[i].first >> points[i].second;
	}
	do {
		for (int i = 1; i < n; i++) {
			ans += calc_dist(points[a[i]], points[a[i - 1]]);
		}
	} while (next_permutation(a.begin(), a.end()));
	cout << fixed << setprecision(10) << ans / over;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
ca = Counter(A)
ca = sorted(ca.items(), key=lambda x:-x[0])
cnt = 0
m = []
for k, v in ca:
  if 3 >= v >= 2:
    cnt += 1
    m += [k]
  elif v >= 4:
    cnt += 2
    m += [k, k]
  if cnt >= 2:
    break

if len(m) <= 1:
  print(0)
  exit()
print(m[0]*m[1])

Measured memory_bytes: 107924