akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int a, b, c, d, e, n, m, k;
string s, t, r;
char c1, c2, c3;

int A[200005];
int B[200005];
int C[200005];

int main() {
	cin >>n;
	for (int i=0 ; i<n ; i++) {
		scanf("%d", A+i);
	}
	int sol = 0;
	sort(A, A+n);
	for (int i=0 ; i<n ; i++) {
		for (int j=i+1 ; j<n ; j++) {
			for (int k=j+1 ; k<n ; k++) {
				if (A[i]+A[j] > A[k] and A[j]>A[i] and A[k]>A[j]) sol++;
			}
		}
	}
	cout <<sol<<endl;
	return 0;
}

Measured memory_bytes: 3772
#include<stdio.h>
int main(void){
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    if((x-a)*(x-a)>(x-b)*(x-b)){
        printf("B\n");
    }
    else{
        printf("A\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
  int n,m;
  cin >> n >> m;
  if(n>=m){
    rep(i,n){
      cout << m;
    } 
  }else{
    rep(i,m){
      cout << n;
    }    
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
char str[]="RGBY";
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int a=((m+i+j)/k)%2,b=((m+i-j)/k)%2;
			printf("%c",str[a*2+b]);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pl pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007


int main() {
	FASTIO;
    ll t=1, i ,j, k, l;
    // cin>>t;
    W(t--) {
        ll n;
        cin>>n;
        ll a[n], res[n];
        FOR(i,n) cin>>a[i];
        res[0]=0; res[1]=abs(a[1]-a[0]);
        For(i,2,n) res[i]=min(res[i-1]+abs(a[i]-a[i-1]),res[i-2]+abs(a[i]-a[i-2]));
        pr(res[n-1]);
        nl;
    }
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long

signed main() {
  int d;
  cin >> d;
  vector<pair<int,int>> c(26);
  vector<int> cc(26);
  vector<int> dd(26);
  vector<int> t;
  rep(i,26) {
    int x;
    cin >> x;
    c[i] = {-x,i};
    cc[i]=x;
  }
  sort(c.begin(),c.end());
  
  vector<vector<int>> s(d);
  int ans = 0;
  rep(i,d) {
    int ma = 0;
    rep(j,26) {
      int num;
      cin >> num;
      ma = max(ma,num+cc[j]);
      if(ma==num+cc[j]) ans = j+1;
      s[i].push_back(num);
    }
    rep(j,26) {
      if(ans-1!=j) cc[j]+=dd[j];
      else cc[j]=dd[j];
    }
    //sort(s.begin(),s.end());
    //cout << ans << endl;
  }
  
  int cnt = 0;
  rep(i,d) {
    t.push_back(c[cnt].second+1);
    cnt++;
    cnt%=26;
  }

  // cnt=0;
  // while(cnt<5) {
  // rep(i,d/13) {
  //   FOR(j,i*13+1,i*13+12) {
  //     if(j+13+cnt>=360) break;

  //     if(s[j][t[j]-1]<s[j+13+cnt][t[j+13+cnt]-1]+3000) {
  //       swap(t[j],t[j+1]);
  //     }
  //   }
  // }
  // cnt++;
  // }

  rep(i,d) {
    cout << t[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3748
#include <stdio.h>

typedef struct Number
{
    int value;
    int changes;
} Number;

#define MAX_VALUE 100000

void GetBest(int *count, int total, Number *first, Number *second)
{
    *first = (Number){.value = 1, .changes = total - count[1]};
    *second = (Number){.value = -1, .changes = total + 1};

    for (int i = 2; i <= MAX_VALUE; i += 1) {
        Number new_num = {.value = i, .changes = total - count[i]};
        if (new_num.changes < first->changes) {
            *second = *first;
            *first = new_num;
        } else if (new_num.changes < second->changes) {
            *second = new_num;
        }
    }
}

int Min(int a, int b) { return a < b ? a : b; }

int count[2][MAX_VALUE + 1];

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

    for (int i = 0; i < n; i += 1) {
        int num;
        scanf("%d", &num);
        count[i % 2][num] += 1;
    }

    Number even1, even2;
    GetBest(count[0], (n + 1) / 2, &even1, &even2);

    Number odd1, odd2;
    GetBest(count[1], n / 2, &odd1, &odd2);

    int res = even1.changes + odd1.changes;
    if (even1.value == odd1.value) {
        res = Min(even2.changes + odd1.changes,
                  even1.changes + odd2.changes);
    }

    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 896
#include"bits/stdc++.h"
using namespace std;

int main() {
	string num;
	cin >> num;
	long long sum = 0;
	int a = num.size();

	for (int bit = 0; bit < (1 << a - 1); bit++) {
		long long tmp = 0;
		for (int i = 0; i < a-1; i++)
		{
			tmp *= 10;
			tmp += num.at(i) - '0';
			if ((bit >> i) & 1) {
				sum += tmp;
				tmp = 0;
			}
		}
		tmp *= 10;
		tmp += num.at(a-1) - '0';
		sum += tmp;
	}
	cout << sum << endl;
}

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

int Sixteen(char ten){
	if(ten == 'A') return 10;
	if(ten == 'B') return 11;
	if(ten == 'C') return 12;
	if(ten == 'D') return 13;
	if(ten == 'E') return 14;
	if(ten == 'F') return 15;
}

int main() {
	char x,y;
	cin >> x >> y;
	
	int n = Sixteen(x);
	int m = Sixteen(y);

	if (n==m) cout << "=" << endl;
	if (n<m) cout << "<" << endl;
	if (n>m) cout << ">" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
bool vis[10];
bool check(int n)
{
	while(n)
	{
		if(vis[n%10])
			return 0;
		n/=10;
	}
	return 1;
}
int main()
{
	int n,m,x;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d",&x);
		vis[x]=1;
	}
	for(int i=n;;i++)
		if(check(i))
		{
			printf("%d\n",i);
			return 0;
		}
}

Measured memory_bytes: 128
k, n = map(float, input().split())
m = list(map(float, input().split()))
half_k = k / 2
min = float(1000000)
for i in range(int(n)):
    first = m[i]
    last = m[i-1]
    len = last - first
    if len < 0:
        len = len + k
    if min > len:
        min = len
print(int(min))


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    int N, L;
  	cin >> N >> L;
  	
    int ans = 0;
    int min_i = INF;
  	int min_i_abs = INF;
  	for(int i=1; i<=N; i++){
    	ans += L + i - 1;
      	if(abs(L+i-1) < min_i_abs){
        	min_i_abs = abs(L+i-1);
        	min_i = L+i-1;
        }
    }
  	cout << ans - min_i << endl;
    return 0;
}

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

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

    int n; cin>>n;
    vector<int> a(10005, 0);
    for(int x = 1, p; x<=100; x++){
        for(int y = 1; y<=100; y++){
            for(int z = 1; z<=100; z++){
                p = (x+y+z)*(x+y+z) - (x*y + y*z + z*x);
                if(p<=10004) a[p]++; 
            }
        }
    }

    for(int i = 1; i<=n; i++) cout<<a[i]<<"\n";
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#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 ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int n;
    cin >> n;
    int sum = 0;
    REPR(i,n) if(IN( 1, i, 10 )||IN( 100, i, 1000 )||IN( 10000, i, 100000 )) sum++;
    cout << sum << endl;
    return 0;
}

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

#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;

string s;
void input() { cin >> s; }
void solve() { cout << s << ((s.back() == 's') ? "es" : "s") << endl; }

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

Measured memory_bytes: 3656
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    a = LI()
    ans = 0
    for i in a:
        ans ^= i
    if not ans:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n,m = LI()

    return

#C
def C():
    n = I()
    p = [(1<<i) for i in range(100)]
    if n in p:
        print("No")
        quit()
    if n+1 in p:
        print("Yes")
        for i in range(1,2*n):
            print(i,i+1)
        quit()
    ans = []
    for i in range(1,3):
        ans.append((i,i+1))
    ans.append((3,n+1))
    for i in range(1,3):
        ans.append((i+n,i+n+1))
    u = 1
    d = 1
    for i in range(2,n//2+n%2):
        ans.append((u,2*i))
        ans.append((d,2*i+1))
        ans.append((2*i,2*i+n+1))
        ans.append((2*i+1,2*i+n))
        u = 2*i+n+1
        d = 2*i+n

    if n%2:
        print("Yes")
        for i,j in ans:
            print(i,j)
    else:
        ans.append((n-1,n))
        for i in range(n):
            if p[i]&n:
                break
        ans.append((p[i+1]-2,2*n))
        print("Yes")
        for i,j in ans:
            print(i,j)
    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 58864
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#define MX 400005

using namespace std;

int v[MX],rud[MX];
int num[MX];
vector<int>son[MX];
int may[MX][2];
int n;

void input()
{
	int f;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&f);
		v[i]=f;
		rud[f]++;
	}
}

int mex(int y)
{
	sort(son[y].begin(),son[y].end());
	if(!son[y].size())return 0;
	else if(son[y][0]!=0)return 0;
	else
	{
		int p=1;
		while(p<son[y].size()&&son[y][p]-son[y][p-1]<=1)p++;
		return son[y][p-1]+1;
	}
}

int stk[MX],top;
void topo()
{
	int x,y;
	for(int i=1;i<=n;i++)if(!rud[i])stk[++top]=i;
	while(top)
	{
		x=stk[top--];
		y=v[x];
		rud[y]--;
		son[y].push_back(num[x]);
		if(!rud[y])
		{
			num[y]=mex(y);
			stk[++top]=y;
		}
	}
}

int work()
{
	int x=0,siz=0,num;
	for(int i=1;i<=n;i++)
	{
		if(rud[i])
		{
			x=i,siz++;
			//for(int j=0;j<son[i].size();j++)cout<<son[i][j]<<" ";cout<<endl;
			//cout<<"fuck:";
			may[i][0]=mex(i);//cout<<endl;
			son[i].push_back(may[i][0]);
			//for(int j=0;j<son[i].size();j++)cout<<son[i][j]<<" ";cout<<endl;
			may[i][1]=mex(i);
			//cout<<i<<" : "<<may[i][0]<<" "<<may[i][1]<<endl;
		}
	}
	num=may[x][0];
	for(int i=1;i<=siz;i++)
	{
		x=v[x];
		if(num==may[x][0])num=may[x][1];
		else num=may[x][0];
	}
	if(num==may[x][0])return 1;
	num=may[x][1];
	for(int i=1;i<=siz;i++)
	{
		x=v[x];
		if(num==may[x][0])num=may[x][1];
		else num=may[x][0];
	}
	if(num==may[x][1])return 1;
	return 0;
}

int main()
{
	input();
	topo();
	if(work())printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 22528
#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll z = *x;
  *x = *y;
  *y = z;
}
void print(vector<ll> vec){
  ll length = (ll)vec.size();
  rep(i,length){
    if(i != 0){cout << " ";}
    cout << vec[i];
  }
  cout << endl;
}

int main(){
  string str;
  cin >> str;
  if(str == "Sunny"){
    str = "Cloudy";
  }else if(str == "Cloudy"){
    str = "Rainy";
  }else{
    str = "Sunny";
  }
  cout << str;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    X,Y,H=[0]*n,[0]*n,[0]*n
    for i in range(n):
        X[i],Y[i],H[i]=map(int,input().split())

    def check(x0,y0):
        # H[i]が0でない値に対して、x0,y0から高さをfixする
        for i in range(n):
            if(H[i]==0): continue
            h=H[i]+abs(X[i]-x0)+abs(Y[i]-y0)
            break
        # この h に対して、残りが整合しているかcheck
        for i in range(n):
            if(H[i]!=max(0,h-abs(X[i]-x0)-abs(Y[i]-y0))):
                return False
        return x0,y0,h

    from itertools import product
    for x0,y0 in product(range(101),repeat=2):
        A=check(x0,y0)
        if(A):
            print(*A)
            return
resolve()

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

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

    int current = 1, ans = 0;
    for (int i = 0; i < N; ++i) {
        if (a[i] != current) ++ans;
        else ++current;
    }

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


Measured memory_bytes: 1024
s = str(input())
q = int(input())
inv = False
head = ''
tail = ''
 
for i in range(q):
    a = input()
    if a == '1':
        inv = not inv
        continue
    a = a.split()
    if (a[1] == '1')^inv:
        head += a[2]
    else:
        tail += a[2]
#s = head + s + tail
if inv:
    print(tail[::-1]+s[::-1] + head)
else:
    print(head[::-1]+s+tail)

Measured memory_bytes: 4468
res1000=-1
res5000=-1
res10000=-1
n,y=map(int,input().split())
for x in range(n+1):
    for j in range(n+1):
        z=n-x-j
        if z>=0 and  y==10000*x+5000*j+1000*z:
            res10000=x
            res5000=j
            res1000=z
print(res10000,res5000,res1000)

Measured memory_bytes: 3060
#include <cstdio>

int N, M, D;
char S[110][110];

int main()
{
	scanf("%d%d%d", &N, &M, &D);
	for (int i = 0; i < N; ++i) {
		scanf("%s", S[i]);
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= M - D; ++j) {
			bool isok = true;
			for (int k = 0; k < D; ++k) {
				if (S[i][j + k] == '#') isok = false;
			}
			if (isok) ++ans;
		}
	}
	for (int i = 0; i <= N - D; ++i) {
		for (int j = 0; j < M; ++j) {
			bool isok = true;
			for (int k = 0; k < D; ++k) {
				if (S[i + k][j] == '#') isok = false;
			}
			if (isok) ++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)

/*
*/

ll s,X=1e9,Y,x,y,xy;

void init(){
	cin>>s;
}

int main(void){
	init();
	Y = (s+X-1)/X;
	xy = X*Y-s;
	cerr<<xy<<endl;
	reg(i,1,xy){
		if(i*i>xy)break;
		if(xy%i==0){
			if(xy/i<=1e9){
				x = xy/i;
				y = i;
				break;
			}
		}
	}
	if(X<x || Y<y)cerr<<"だめ"<<endl;
	if(2*X*Y-x*Y-y*X-(X-x)*(Y-y)!=s)cerr<<"だめ"<<endl;
	cout<<"0 0 "<<X<<" "<<y<<" "<<x<<" "<<Y<<endl;
	return 0;
}

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

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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int N,K;
  string S;
  cin >> N >> K >> S;
  vector<int> v;
  int cnt = 0;
  for(int i = 0; i < N; i++) {
    if(S[i]=='1')cnt++;
    if(S[i]=='0')cnt--;
    if(i==N-1)v.push_back(cnt);
    else if(S[i]!=S[i+1]){
        v.push_back(cnt);
        cnt=0;
    }
  }
  int ans = 0;
  if(S[0]=='1'){
    int k = 0;
    for(int i = 0; i <= min(2*K,(int)v.size()-1); i++) {
      k+=abs(v[i]);
    }
    chmax(ans,k);
    for(int i = 0; 2*i+2*K+1<(int)v.size();i++){
      if(2*i+2*K+2<(int)v.size()){
        k-=v.at(2*i)-v.at(2*i+1);
        k+=(-v.at(2*K+2*i+1))+v.at(2*K+2*i+2);
        chmax(ans,k);
      }
      else if(2*i+2*K+2==(int)v.size()){
        k-=v.at(2*i)-v.at(2*i+1);
        k+=(-v.at(2*K+2*i+1));
        chmax(ans,k);
      }
    }
  }
  else {
    int k = 0;
    for(int i = 0; i < min(2*K,(int)v.size()); i++) {
      k+=abs(v.at(i));
    }
    chmax(ans,k);
    v.erase(v.begin());
    k=0;
    for(int i = 0; i <= min(2*K,(int)v.size()-1); i++) {
      k+=abs(v.at(i));
    }
    chmax(ans,k);
    for(int i = 0; 2*i+2*K+2<(int)v.size();i++){
      k-=v.at(2*i)-v.at(2*i+1);
      k+=(-v.at(2*K+2*i+1))+v.at(2*K+2*i+2);
      chmax(ans,k);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1020
fun main(args: Array<String>){
    var s = readLine()!!
    s = s.replace("BC", "D") + "Z"

    val count = LongArray(s.length + 1)
    val inv = LongArray(s.length + 1)
    var ans = 0L
    for(i in s.indices){
        if(s[i] == 'D'){
            count[i + 1] = count[i]
            inv[i + 1] = inv[i] + count[i]
        }else if(s[i] == 'A'){
            count[i + 1] = count[i] + 1
            inv[i + 1] = inv[i]
        }else{
            count[i + 1] = 0
            ans += inv[i]
            inv[i + 1] = 0
        }
    }
    println(ans)
}

Measured memory_bytes: 45860
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define N 100010
using namespace std;
struct node{
	int x,y,id;
	void read(int D){int a,b;scanf("%d%d",&a,&b);x=a+b,y=a-b;id=D;}
	node(int X=0,int Y=0):x(X),y(Y){}
	node operator +(const node a)const{return node(x+a.x,y+a.y);}
	node operator -(const node a)const{return node(x-a.x,y-a.y);}
	bool operator <(const node a)const{return x==a.x?y<a.y:x<a.x;}
}p[N];
int nxt[N*10],to[N*10],head[N],cnt;
void add(int u,int v)
{
	nxt[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
}
int n,in[N];
void work(int xlen,int ylen)
{
	sort(p+1,p+n+1);
	int l=1,r=0,lst=1;
	for(int i=1;i<=n;i++)
	{
		while(l<n && p[l]<p[i]+node(-xlen,-ylen))l++;
		while(r<n && p[r+1]<p[i]+node(-xlen,ylen+1))r++;
		in[p[i].id]+=r-l+1;
		lst=max(lst,l);
		while(lst<=r)
		{
			add(p[i].id,p[lst].id);
			add(p[lst].id,p[i].id);
			lst++;
		}
		lst--;
	}
}
bool vis[N];
long long dfs(int u)
{
	vis[u]=true;
	long long ans=in[u];
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(vis[v]) continue;
		ans+=dfs(v);
	}
	return ans;
}
int main()
{
	int a,b;
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n;i++) p[i].read(i);
	int dis=max(abs(p[a].x-p[b].x),abs(p[a].y-p[b].y));
	work(dis,dis);
	for(int i=1;i<=n;i++) swap(p[i].x,p[i].y);
	work(dis,dis-1);
	printf("%lld\n",dfs(a));
	return 0;
}


Measured memory_bytes: 12416
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	An := make([]int, N)
	divsm := make(map[int]int)
	divsp := make(map[int]int)
	for i := range An {
		An[i] = nextInt()
		divsm[i+1-An[i]]++
		divsp[i+1+An[i]]++
	}
	var ans int
	for k, m := range divsm {
		if p, e := divsp[k]; e {
			ans += m * p
		}
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}

// ここから拝借
// https://shoman.hatenablog.com/entry/2020/02/25/185456
// Stackは[]intのエイリアス
type Stack []int

// Push adds an element
func (s *Stack) Push(v int) {
	*s = append(*s, v)
}

// Pop removes the top element and return it
func (s *Stack) Pop() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	v := (*s)[len(*s)-1]
	*s = (*s)[:len(*s)-1]
	return v, nil
}

// Peek returns the top value
func (s *Stack) Peek() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	return (*s)[len(*s)-1], nil
}

// Size returns the length of stack
func (s *Stack) Size() int {
	return len(*s)
}

// Empty returns true when stack is empty
func (s *Stack) Empty() bool {
	return s.Size() == 0
}

// NewStack generates stack
func NewStack() *Stack {
	s := new(Stack)
	return s
}


Measured memory_bytes: 25216
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

struct Edge {
  ll u, v, w;
};

const ll MAX_N = 100000;
ll N;
vector<Edge> tree[MAX_N];

ll d[MAX_N];
bool visited[MAX_N];

void dfs(ll u) {
  for (ll i = 0; i < (ll)tree[u].size(); i++) {
    Edge e = tree[u][i];
    ll v = e.v;
    ll w = e.w;
    if (visited[v]) continue;
    d[v] = d[u] + w;
    visited[v] = true;
    dfs(v);
  }
}

int main(void) {
  cin >> N;
  for (ll i = 0; i < N - 1; i++) {
    ll u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    tree[u].push_back((Edge){u, v, w});
    tree[v].push_back((Edge){v, u, w});
  }

  d[0] = 0;
  visited[0] = true;
  dfs(0);
  
  for (ll u = 0; u < N; u++) {
    cout << d[u] % 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 11776
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

struct book {
  int price;
  vector<int> scores;
};

int main() {
  int n, m, x;
  cin >> n >> m >> x;

  vector<book> books(n);

  for (int i = 0; i < n; i++) {
    cin >> books.at(i).price;
    books.at(i).scores.resize(m);

    for (int j = 0; j < m; j++) {
      cin >> books.at(i).scores.at(j);
    }
  }
  int lowest = INT32_MAX;
  bool found = false;
  for (int i = 0; i < (1 << n); i++) {
    bitset<12> b(i);
    int sumPrice = 0;
    vector<int> sumScores(m);

    for (int j = 0; j < n; j++) {
      if (b[j]) {
        sumPrice += books.at(j).price;
        for (int k = 0; k < m; k++) {
          sumScores.at(k) += books.at(j).scores.at(k);
        }
      }
    }

    // validation
    bool allOk = true;
    for (int k = 0; k < m; k++) {
      if (sumScores.at(k) < x) {
        allOk = false;
        break;
      }
    }

    if (allOk) {
      lowest = min(lowest, sumPrice);
      found = true;
    }
  }

  if (found) {
    cout << lowest << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 3628
import itertools
import math

N = int(input())
town = [list(map(int,input().split())) for _ in range(N)]

S = 0
for P in itertools.permutations(range(N)):
    for i in range(N-1):
        s, t = P[i+1], P[i]
        S += math.sqrt((town[s][0]-town[t][0]) ** 2 + (town[s][1]-town[t][1]) ** 2)

for i in range(1,N+1):
    S /= i

print(S)

Measured memory_bytes: 90896
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int b[100005];
int main()
{
    scanf("%d",&n);
    long long sum = 0;
    for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
    for(int i = 1;i <= n;i++) {scanf("%d",&b[i]);a[i] -= b[i];sum += a[i];}
    if(sum < 0){
        puts("-1");return 0;
    }
    sort(a + 1 , a + n + 1);
    sum = 0;
    int ans = 0;
    for(int i = 1;i <= n && a[i] < 0;i++) {sum += a[i];ans++;}
    for(int i = n;i >= 1 && sum < 0;i--){
        ans++;sum += a[i];
    }
    cout << ans;
    return 0;
}


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

#define 	ll				long long int
#define 	vi				vector<int>
#define		rep(i,n) 		for(i=0;i<n;i++)
#define		repe(i,I1,I2) 	for(i=I1;i<I2;i++)
#define		pb  			push_back
#define		mp  			make_pair
#define		endl			'\n'
#define 	mod				1000000007


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,k,t,c=0,i,a,b;
	t=1;
	//cin>>t;
	string s;
	while(t--)
	{
		cin>>a>>b>>k;
		rep(i,k)
		{
			if(i%2)
			{
				b-=(b%2);
				a+=(b/2);
				b/=2;
			}
			else
			{
				a-=(a%2);
				b+=(a/2);
				a/=2;
			}
		}
		cout<<a<<" "<<b;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main() {
	int n; cin >> n;
	vector<P> a(n);
	rep(i, 0, n) cin >> a[i].first >> a[i].second;
	rep(i, 0, n) {
		int idx = 0;
		double b[201];
		rep(j, 0, n) {
			if (i == j) continue;
			b[idx++] = atan2(a[j].second - a[i].second, a[j].first - a[i].first);
		}
		sort(b, b + idx);
		rep(j, 0, idx) b[j + idx] = b[j] + 2 * M_PI;
		double ans = 0;
		rep(j, 0, idx) ans = max(ans, M_PI - b[j + idx - 1] + b[j]);
		printf("%.12f\n", ans/2/M_PI);
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
// using namespace atcoder;

const ll mod=1000000007;//998244353;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

vector<vector<ll>> bunkai(ll a){
  if(a<=0) return {};
  if(a==1) return {{1,1}};
  vector<ll> f;
  ll b=a;
  for(ll i=2;i*i<=a;i++){
    if(b%i==0){
      f.push_back(i);
      b=b/i;
      i--;
    }
  if(b==1)break;
  }
  if(b!=1)f.push_back(b);

  vector<vector<ll>> u;
  ll p=f[0];
  ll c=1;
  for(ll i=1;i<f.size();i++){
    if(f[i]==p)c++;
    else{
      u.push_back({p,c});
      p=f[i];
      c=1;
    }
  }
  u.push_back({p,c});

  return u;
}

vector<ll> yakusu(ll a){
  if(a<=0)a=-a;
  if(a==1) return {1};
  vector<ll> f={1,a};
  for(ll i=2;i*i<=a;i++){
    if(a%i==0 && i*i!=a){
      f.push_back(i);
      f.push_back(a/i);
    }
    if(i*i==a)f.push_back(i);
  }
  sort(f.begin(),f.end());

  return f;
}

int main(){

  ll n;
  cin >> n;
  vec f=yakusu(n);


  set<ll> s;

  ll ans=0;
  for(ll i=1;i<f.size();i++){
    ll a=f[i];
    ll m=n;
    //cout << m << a << endl;
    while(m%a==0)m/=a;
    if(m%a==1)s.insert(a);
  }

  //cout << s.size() << endl;

  for(ll i=1;i*i<=n;i++){
    if(n%i==1){
      s.insert(i);
      s.insert((n-1)/i);
    }
  }
  if(n!=2)s.insert(n-1);

  cout << s.size() << endl;

  return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    vector<int> niz(n);
    for (int i = 0; i < n; i++)
        cin >> niz[i];

    int cnt = 0;
    for (int i = 0; i < n - 2; i++)
    {
        for (int j = i + 1; j < n - 1; j++)
        {
            for (int k = j + 1; k < n; k++)
            {
                int a = niz[i], b = niz[j], c = niz[k];
                if (a == b || a == c || b == c)
                    continue;
                if (a + b > c && a + c > b && b + c > a)
                    cnt++;
            }
        }
    }
    cout << cnt;
}

Measured memory_bytes: 3596
N = int(input())
data = []

div_list = []
for i in range(5):
    data.append(int(input()))
    if N%data[i] == 0:
        div_list.append(int(N/data[i]))
    else:
        div_list.append(int(N/data[i])+1)
count = max(div_list)+4
print(count)

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

int n, k;
long long int T[100000];
long long sum;
long long l;

int check(long long p) {
	int m = 0;
	for (int i = 0; i < k; i++) {
		long long s = 0;
		while (s + T[m] <= p) {
			s += T[m];
			m++;
			if (m >= n) {
				return n;
			}
		}
	}
	return m;
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> T[i];
		sum += T[i];
	}
	l = sum / k;
	while (check(l) != n) {
		l++;
	}
	cout << l << endl;
	return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(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)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );

  int n;cin>>n;
  vi l(n);
  rep(i,n)cin>>l[i];
  rvisort(l);
  int max=l[0];
  int other=vtotal(l)-max;
  string ans="No";
  if(max<other)ans="Yes";
  
  cout(ans);

  return 0;
}

Measured memory_bytes: 125568
#include<stdio.h>
int main()
{
	int a,r;
	scanf("%d",&a);
	while(a!=0)
	{
	    r=a%10;
	    a/=10;
	    if(r==7)
	    {
	        break;
	    }
	}
	if(r==7){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 1640
#Beginner COnetst 145 /2019/11/16
#Probrem A
import math
DEBUG = 0

def dist(pi,pj):
    if DEBUG:print(pi,pj)
    dx = pi[0] - pj[0]
    dy = pi[1] - pj[1]
    tmp = dx*dx + dy*dy
    result = math.sqrt(tmp)
    if DEBUG:print(result)
    return result

def sum(n,pos):
    total = 0
    for i in range(n-1):
        for j in range(i+1,n):
            if DEBUG:print(i,j)
            total += dist(pos[i],pos[j])
    return total

def calc(n,pos):
    return sum(n,pos)*2/n

n = int(input())
pos = [ [0,0] for i in range(n)]
for i in range(n):
    pos[i] = list(map(int, input().split()))
    if DEBUG:print(pos[i])
print(calc(n,pos))


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

using namespace std;

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

	string s;
	cin >> s;

	string start = "", end = "";
	bool rev = false;
	
	int q;
	cin >> q;
	while(q--){
		int t;
		cin >> t;

		if(t == 1){
			rev ^= true;
			continue;
		}

		int f;
		cin >> f;

		char c;
		cin >> c;

		if((f == 1) ^ rev)
			start += c;
		else
			end += c; 
	}

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

	string ans = start + s + end;
	if(rev)
		reverse(ans.begin(), ans.end());

	cout << ans << "\n";
}

Measured memory_bytes: 1300
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;

int main()
{
    int n;
    cin >> n;
    double f = 1;
    for(int i = 1; i <= n; i++) f *= i;
    double x[10], y[10];
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
    int a[10];
    double ans = 0;
    for(int i = 0; i < n; i++) a[i] = i;
    do{
        double now = 0;
        for(int i = 0; i < n - 1; i++){
            now += sqrt((x[a[i]] - x[a[(i + 1) % n]]) * (x[a[i]] - x[a[(i + 1) % n]]) + 
                        (y[a[i]] - y[a[(i + 1) % n]]) * (y[a[i]] - y[a[(i + 1) % n]]));
        }
        ans += now / f;
    }while(next_permutation(a, a + n));
    cout << fixed << setprecision(15) << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n, t;
	static int[] stair;
	public static void main(String[] args) {
		while(read()){
			
		}
	}
	
	static boolean read(){
		if(!sc.hasNext())return false;
		n = sc.nextInt();
		for(int i = 0; i < n; i++){
			t = sc.nextInt();
			stair = new int[t];
			for(int j = 0; j < stair.length; j++){
				stair[j] = sc.nextInt();
			}
			solve();
		}
		return true;
	}
	
	static void solve(){
		int min = 0, max = 0;
		for(int i = 0; i < stair.length-1; i++){
			max = Math.max(max, stair[i+1]-stair[i]);
			min = Math.max(min, stair[i]-stair[i+1]);
		}
		System.out.println(max + " " + min);
	}

}

Measured memory_bytes: 12000
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

r = INT()
print(2 * r * pi)

Measured memory_bytes: 68288
import math


def readints():
    return list(map(int, input().split()))


n = int(input())
a = readints()
x = 0
y = 0
for i in range(n):
    if a[i] % 2 == 0:
        x += 1
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            y += 1
if x == y:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        long[] arr = new long[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        long min = Integer.MAX_VALUE;
        for(int i = 0; i+K-1 < N; i++) {
            long tmp = arr[i+K-1] - arr[i];
            min = Math.min(min, tmp);
        }
        System.out.println(min);
    }
}


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

const int MAXN = 1e5 + 10, MAXM = 1e5 + 10;

int n, m;

int cnt, head[MAXN];
struct edge { int nxt, to; } e[MAXM];
void add(int u, int v) { e[++cnt].to = v, e[cnt].nxt = head[u], head[u] = cnt; }

int in[MAXN];
queue<int> q;

int f[MAXN];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1, u, v; i <= m; ++i) {
        scanf("%d %d", &u, &v);
        add(u, v); in[v] ++;
    }
    for (int i = 1; i <= n; ++i) if (!in[i]) q.push(i);
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int i = head[u], v; i; i = e[i].nxt) {
            v = e[i].to;
            f[v] = max(f[v], f[u] + 1);
            if (!(-- in[v])) q.push(v);
        }
    }
    int fans = 0;
    for (int i = 1; i <= n; ++i) fans = max(fans, f[i]);
    printf("%d\n", fans);
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  vector<int> ans(100);
  for(int i = 0;i < N;i++) {
    cin >> X.at(i);
  }
  for(int i = 0;i < 100;i++) {
    for(int j = 0; j < N;j++) {
      ans.at(i) += ( i - X.at(j)) * ( i - X.at(j));
    }
  }
  sort(ans.begin(),ans.end());
  cout << ans.at(0) << endl;
}
    

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


// Main Code
int main()
{
	int n, k;
	cin>>n>>k;
	string s;
	cin>>s;
	int j =0;
	vector<pair<ll, ll>> vp;
	for(int i=0; i<n; i = j)
	{
		while(s[i] == s[j]) j++;
		vp.pb({s[i]-'0', j-i});
	}
	ll len = 0;
	ll ans = 0;
	ll lst = 0;
	for(auto x: vp)
	{
		len += x.s;
		if(x.f == 0) k--;
		while(k < 0)
		{
			if(vp[lst].f == 0) k++;
			len -= vp[lst].s;
			lst++;
		}
		chmax(ans, len);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2548
#include<stdio.h>
#include <string.h>

int Nmem,act;
int cou=1;
int memo[1000001];
int num,fish;
int maxmemo[2]={0};
int scanset[100001];

int maxset(int num,int n)
{
    maxmemo[0]=num;
    maxmemo[1]=memo[num];
    return 0;
}

int main()
{
    maxmemo[0]=1000001;
    for(int i=0;i<1000001;i++)
    {
        memo[i]=-1;
    }
    scanf("%d%d",&Nmem,&act);
    for(int i=0;i<act;i++)
    {
        scanf("%d%d",&num,&fish);
        if(memo[num]==-1)
        {
            scanset[cou]=num;
            cou++;
            memo[num]++;
        }
        memo[num]=memo[num]+fish;
        if(fish>0)
        {
            if(maxmemo[1]<=memo[num])
            {
                if(memo[num]==maxmemo[1]&&num>maxmemo[0]){}
                else maxset(num,0);
            }
            printf("%d %d\n",maxmemo[0],maxmemo[1]);
        }
        else if(fish<0)
        {
            for(int i=0;i<2;i++)
            {
                maxmemo[0]=1000001;
                maxmemo[1]=0;
            }
            for(int i=0;i<cou;i++)
            {
                if(memo[scanset[i]]>=maxmemo[1])
                {
                    if(memo[scanset[i]]==maxmemo[1]&&scanset[i]>maxmemo[0]){}
                    else maxset(scanset[i],0);
                }
            }
            printf("%d %d\n",maxmemo[0],maxmemo[1]);
        }
    }
    return 0;
}

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

int main() {
    ll x, y;
    cin >> x >> y;

    if(x==y){
        cout << 0 << endl;
        return 0;
    }

    if(x==0){
        if(y<0) {cout << -y+1LL << endl; return 0;}
        else {cout << y << endl; return 0;}
    }

    if(y==0){
        if(x<0) {cout << -x << endl; return 0;}
        if(x>0) {cout << x+1LL << endl; return 0;}
    }


    if(x < 0 && y < x){
        cout << (x-y) + 2LL << endl;
    }
    else if(x < 0 && y < 0){
        cout << (y-x) << endl;
    }
    else if(x < 0 && y > 0 && -x <= y){
        cout << y + x + 1LL<< endl;
    }
    else if(x < 0 && y > 0 && -x >= y){
        cout << -x - y + 1LL << endl;
    }
    
    if(x > 0 && y > x){
        cout << y - x << endl;
    }
    else if(x > 0 && 0 < y){
        cout << x - y + 2LL << endl;
    }
    else if(x > 0 && y < 0 && -y >= x){
        cout << -y - x + 1LL << endl;
    }
    else if(x > 0 && y < 0 && -y <= x){
        cout << x + y + 1LL << endl;
    }   
}

Measured memory_bytes: 256
//============================================================================
// Name        : abc131_e.cpp
// Author      : abb
// Version     :
// Copyright   : [My copyright notice]
// Description : Hello World in C++, Ansi-style
//============================================================================

/*
 E - Friendships

 実行時間制限: 2 sec / メモリ制限: 1024 MB

 配点 : 500 点

 問題文
 以下の条件を満たす N 頂点の無向グラフは存在するでしょうか？

 ・グラフは単純かつ連結である。
 ・各頂点には 1, 2, ..., N の番号が付けられている。
 ・グラフの辺数を M としたとき、各辺には 1, 2, ..., M の番号が付けられていて、辺 i は頂点 u_i と頂点 v_i をつなぐ長さ 1 の辺である。
 ・最短距離が 2 であるような頂点対 (i, j) (i < j) が、ちょうど K 個存在する。

 条件を満たすグラフが存在するならば 1 つ構築してください。

 制約

 ・入力は全て整数である。
 ・2 <= N <= 100
 ・0 <= K <= \frac{N(N - 1)}{2}


 */

#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

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

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

/**
 * エントリポイント．
 * @return 0.
 */
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;

	int relative_pair_count = (n - 1) * (n - 2) / 2;
	// 最短距離 2 の頂点対は最大で relative_pair_count 個しか作れない
	if (relative_pair_count < k) {
		cout << "-1" << endl;
		return 0;
	}

	// 頂点の番号は [1, n] で採番する
	vector<pair<int, int>> edges;
	rep(i, 2, n)
	{
		// 頂点 1 と i を結ぶエッジを追加する
		edges.emplace_back(1, i);
	}

	rep(u, 2, n - 1)
	{
		rep(v, u + 1, n)
		{
			if (relative_pair_count > k) {
				edges.emplace_back(u, v);
				--relative_pair_count;
			} else {
				break;
			}
		}
	}

	cout << ((int) edges.size()) << endl;
	for (pair<int, int> edge : edges) {
		cout << edge.first << " " << edge.second << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stack>
#include<cstdlib>
#include<string>

using namespace std;

int main(){
	stack<int> st;
	int num1,num2;
	while (true){
		string c;
		cin >> c;
		if (cin.eof()) break;
		if (c == "+"){
			num1 = st.top();
			st.pop();
			num2 = st.top();
			st.pop();
			st.push(num1+num2);
		}else if (c == "-"){
			num1 = st.top();
			st.pop();
			num2 = st.top();
			st.pop();
			st.push(num2-num1);
		}else if (c == "*"){
			num1 = st.top();
			st.pop();
			num2 = st.top();
			st.pop();
			st.push(num1*num2);
		}else{
			st.push(stoi(c));
		}
		

	}
	cout << st.top() << endl;
return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

int main( int argc, char *argv[] ) {
	int x;
	cin >> x;
	if ( x == 3 || x == 5 || x == 7 )
		cout << "YES" << "\n";
	else
		cout << "NO" << "\n";

	return 0;
}


Measured memory_bytes: 256
A,B,C,D,E,F=map(int,input().split())
weight=100*A
suger=0
c=0
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        for k in range((i*A+j*B)*E//C+1):
            for l in range((i*A+j*B)*E//D+1):
                if 100*(i*A+j*B)+k*C+l*D<=F and k*C+l*D<=(i*A+j*B)*E and (i*i+j*j+k*k+l*l)!=0 and (k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)>c:
                    c=(k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)
                    weight=100*(i*A+j*B)+k*C+l*D
                    suger=k*C+l*D


print("{} {}".format(weight,suger))


Measured memory_bytes: 68244
x1, y1, x2, y2 = map(int, input().split(' '))

x12 = x2 - x1
y12 = y2 - y1

x3 = x2 - y12
y3 = y2 + x12

x4 = x3 - x12
y4 = y3 - y12

print(str(x3) + " " + str(y3) + " " + str(x4) + " " + str(y4))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int k;
set<ll> st;
string s;
void solve(int idx, ll num) {
	st.insert(num);
	if (sz(st) > k)
		st.erase(*st.rbegin());
	if (idx == 0)
		return;
	for (int d = -1; d <= 1; d++) {
		int cur = s.back() + d;
		if (0 <= cur && cur < 10) {
			s.push_back(cur);
			solve(idx - 1, num * 10 + cur);
			s.pop_back();
		}
	}
}
int main() {
	run();
	cin >> k;
	for (int i = 1; i < 10; i++) {
		s.push_back(i);
		solve(10, i);
		s.pop_back();
	}
	cout << *st.rbegin() << endl;
}


Measured memory_bytes: 4992