akhauriyash/Code-Regression huggingface dataset:
/**
 * Motto:   To Become Better Than Me
 * Author: cherry0697
 **/

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

#define rep(i,n) for(i=0;i<n;i++)
#define repc(i,a,n) for(i=a;i<n;i++)
#define repa(i,a,n) for(i=a;i<=n;i++)
#define repb(i,a,n) for(i=a;i>=n;i--)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define all(x) x.begin(),x.end()
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef vector <long long int> vi;

void solve()
{
  ll n;
  cin>>n;

  ll r[n],g[n],b[n],i,j;

  r[n-1]=0;
  g[n-1]=0;
  b[n-1]=0;

  string s;
  cin>>s;

  for(i=n-1;i>=0;i--)
  {
    if(i==n-1)
    {
      if(s[i]=='R')
        r[n-1]++;
      else if(s[i]=='G')
        g[n-1]++;
      else
        b[n-1]++;
    }
    else
    {
      if(s[i]=='R')
      {
        r[i]=r[i+1]+1;
        g[i]=g[i+1];
        b[i]=b[i+1];
      }
      else if(s[i]=='G')
      {
        r[i]=r[i+1];
        g[i]=g[i+1]+1;
        b[i]=b[i+1];
      }
      else
      {
        r[i]=r[i+1];
        g[i]=g[i+1];
        b[i]=b[i+1]+1;
      }
    }
  }

  char ch1,ch2,ch3;
  ll ans=0,temp,cut,temp1;

  for(i=0;i<n;i++)
  {
    for(j=i+1;j<n;j++)
    {
      if(s[i]!=s[j])
      {
        temp=j-i;
        temp=j+temp;

        if(j!=(n-1))
        {
          if( (s[i]=='R' && s[j]=='G') || (s[i]=='G' && s[j]=='R') )
          {
            temp1=b[j+1];
            if(temp<n && s[temp]=='B')
            {
              temp1=temp1-1;
            }

            ans+=temp1;
          }
          else if( (s[i]=='R' && s[j]=='B') || (s[i]=='B' && s[j]=='R') )
          {
            temp1=g[j+1];
            if(temp<n && s[temp]=='G')
            {
              temp1=temp1-1;
            }

            ans+=temp1;
          }
          else
          {
            temp1=r[j+1];
            if(temp<n && s[temp]=='R')
            {
              temp1=temp1-1;
            }

            ans+=temp1;
          }
        }
      }
    }
  }

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

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

  ll t;
  t=1;

  while(t--)
    solve();

return 0;
}


Measured memory_bytes: 3676
N = int(input())
x = []
for i in range(N):
    input1 = input()
    input1 = input1.split() 
    m, n = int(input1[0]), int(input1[1])
    if(m==n):
        x.append('x')  
    else:
        x.append(0)
count = 0
flag = 0
i = 0
while(i!=N):
    if(x[i]=='x'):
        count=count+1
        if(count>=3):
            flag+=1
    else:
        count = 0
    i+=1
if(flag>0):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9208
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = input()
N = len(S)

D = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}

T = list(S)[::-1]
for i in range(N):
    T[i] = D[T[i]]
T = ''.join(T)

if S == T:
    Yes()
else:
    No()


Measured memory_bytes: 4852
#include <iostream>
#include <queue>
#include <vector>
#define MAXN 1000005

using namespace std;

const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
int p[MAXN], sz[MAXN];
bool gvis[MAXN];
int h, w, sx, sy, ex, ey;
vector<int> adj[MAXN];

int find(int u) { return p[u] == u ? u : (p[u] = find(p[u])); }

int co(int i, int j) { return i * w + j + 1; }

void connect(int u, int v) {
  int pu = find(u), pv = find(v);
  if (pu != pv) {
    if (sz[pu] >= sz[pv]) {
      p[pv] = pu;
      sz[pu] += sz[pv];
    } else {
      p[pu] = pv;
      sz[pv] += sz[pu];
    }
  }
}

int main() {
  cin >> h >> w >> sx >> sy >> ex >> ey;
  sx--, sy--, ex--, ey--;
  vector<string> a(h);
  for (int i = 0; i < h; ++i)
    cin >> a[i];
  for (int i = 1; i <= h * w; ++i)
    p[i] = i, sz[i] = 1, gvis[i] = false;
  vector<vector<bool>> vis(h, vector<bool>(w));
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j) {
      if (a[i][j] == '#' || vis[i][j])
        continue;
      queue<pair<int, int>> q;
      q.push({i, j});
      vis[i][j] = true;
      while (!q.empty()) {
        auto [ci, cj] = q.front();
        q.pop();
        for (int k = 0; k < 4; ++k) {
          int ni = ci + dy[k], nj = cj + dx[k];
          if (ni < 0 || ni >= h || nj < 0 || nj >= w || vis[ni][nj] ||
              a[ni][nj] == '#')
            continue;
          connect(co(ci, cj), co(ni, nj));
          vis[ni][nj] = true;
          q.push({ni, nj});
        }
      }
    }
  int gs = find(co(sx, sy)), ge = find(co(ex, ey));
  if (gs == ge) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j) {
      if (a[i][j] == '#')
        continue;
      int gc = find(co(i, j));
      for (int ni = i - 2; ni <= i + 2; ++ni)
        for (int nj = j - 2; nj <= j + 2; ++nj) {
          if (ni < 0 || ni >= h || nj < 0 || nj >= w || a[ni][nj] == '#')
            continue;
          int gn = find(co(ni, nj));
          if (gc != gn) {
            adj[gc].emplace_back(gn);
            adj[gn].emplace_back(gc);
          }
        }
    }
  queue<pair<int, int>> q;
  q.push({gs, 0});
  gvis[gs] = true;
  while (!q.empty()) {
    auto [g, step] = q.front();
    if (g == ge) {
      cout << step;
      return 0;
    }
    q.pop();
    for (int nxt : adj[g]) {
      if (!gvis[nxt]) {
        gvis[nxt] = true;
        q.push({nxt, step + 1});
      }
    }
  }
  cout << -1;
}

Measured memory_bytes: 59752
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def main3():
    n,m=map(int, input().split())
    k = factorization(n)
    k1 = factorization(m)

    y1 = set()
    y2 = set()

    for i in k:
        y1.add(i[0])
    for i in k1:
        y2.add(i[0])
    y1.add(1)
    y2.add(1)

    kouyaku = y1&y2
    print(len(kouyaku))



if __name__ == '__main__':
    main3()


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

int main(void){
  long N,ans,sum = 0;
  scanf("%ld",&N);
  int A[N];

  for(int i = 0;i < N;i++){
    scanf("%d",&A[i]);
    if(i == 0){
      sum += abs(A[i]);
    }else{
      sum += abs(A[i]-A[i-1]);
    }
  }
  sum += abs(A[N-1]);

  if(N == 2){
    printf("%ld\n",abs(A[1]*2));
    printf("%ld\n",abs(A[0]*2));
    return 0;
  }
  for(int i = 0;i < N;i++){
    ans = sum;
    if(i == 0){
      ans += abs(A[1]) - abs(A[1]-A[0])-abs(A[0]);
    }else if(i == N-1){
      ans += abs(A[N-2]) - abs(A[N-1]-A[N-2])-abs(A[N-1]);
    }else{
      if(A[i-1] <= A[i] && A[i] <= A[i+1]){
      }else if(A[i+1] <= A[i] && A[i] <= A[i-1]){
      }else{
        ans += abs(A[i+1]-A[i-1]) - abs(A[i+1]-A[i])-abs(A[i]-A[i-1]);
      }
    }
    printf("%ld\n",ans);
  }

  return 0;
}

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

int main(){
	int n;
	cin >> n;
	int a[100][2];
	for (int i=0; i<n; i++){
		cin >> a[i][0] >> a[i][1];
	}
	
	for (int i=0; i<n-2; i++){
		if(a[i][0]==a[i][1] && a[i+1][0]==a[i+1][1] && a[i+2][0]==a[i+2][1]){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<ll> pos;
  rep(i, N-1){
    if(S.substr(i, 2)=="AC"){
      pos.push_back(i+1);
    }
  }

  rep(i, Q){
    ll r, l;
    cin >> l >> r;
    ll tmp1 = (ll) (lower_bound(ALL(pos), l) - pos.begin());
    ll tmp2 = (ll) (lower_bound(ALL(pos), r) - pos.begin());
    cout << tmp2-tmp1 << endl;
  }
  return 0;
}


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

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

    vector<pair<double,double>> v(N);

    for(int i = 0; i < N; i++)
    {
        cin >> v.at(i).first >> v.at(i).second;
    }

    vector<int> index(N);
    for(int i = 0; i < N; i++) index.at(i) = i;

    double dis = 0;
    double dsum = 0;

    

    do
    {
        for(int i = 0; i < N-1; i++)
        {
        double x = v.at(index[i]).first - v.at(index[i+1]).first;
        double y = v.at(index[i]).second - v.at(index[i+1]).second;
        dis = pow(x*x + y*y,0.5);
        dsum += dis;
        }
    }
    while(next_permutation(index.begin(),index.end()));

    long long count = 1;
    for(int i = 1; i <= N; i++)count *= i;

    cout << fixed << setprecision(10) << dsum / count << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;

int main() {
    ll a,b,ans=0,x=0;
    cin >> a >> b;
    if (b>a*2){
        x=b-2*a;
    }
    for (ll i=x;i<=a;++i){
        if (i>b){
            break;
        }
        for (ll j=max(i,x);j<=a;++j){
            if (i+j>b){
                break;
            }
            for (ll k=j;k<=a;++k){
                if (i+j+k>b){
                    break;
                }
                if (i+j+k==b){
                    if (i==j && j==k){
                        ++ans;
                    }else if(i==j || j==k || i==k){
                        ans+=3;
                    }else{
                        ans+=6;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
int main()
{
  int A_1,A_2,A_3;
  scanf("%d %d %d",&A_1,&A_2,&A_3);
  if(A_1+A_2+A_3>=22){
    printf("bust\n");
  }
  else{
    printf("win\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<string.h>
#include<stdio.h>
int main(void)
{
	int A,i,j,l,flg,cnt=0,len=0;
	char a[101],b[101][101];
	scanf("%s %d",a,&A);
	for(i=0;i<A;i++){
		scanf("%s",b[i]);
	}
	for(i=0;i<A;i++){
		for(j=0;j<strlen(b[i]);j++){
			len=strlen(b[i]);
			flg=1;
			for(l=0;l<strlen(a);l++){
				if(len<=j+l){
					if(a[l]!=b[i][j+l-len]){
						flg=0;
					}
			//		printf("%c %c\n",a[l],b[i][j+l-len]);
				}
				else if(a[l]!=b[i][j+l]){
					flg=0;
			//	printf("%c %c\n",a[l],b[i][j+l]);
				}
				else{
			//		printf("%c %c\n",a[l],b[i][j+l]);
				}
			}
			if(flg==1){
				cnt++;
				break;
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 2756
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int a, b; cin >> a >> b;
  cout << "100 100" << endl;
  char ans[100][100];
  rep(i, 100){
    rep(j, 100){
      if(i<50) ans[i][j]='#';
      else ans[i][j]='.';
    }
  }
  int cnta = a-1;
  rep(i, 50){
    rep(j, 100){
      if(cnta==0) goto NEXTA;
      if(!(i%2) && !(j%2)){
        ans[i][j]='.'; cnta--;
      }
    }
  }
  NEXTA:;
  int cntb = b-1;
  for(int i=50; i<100; i++){
    rep(j, 100){
      if(cntb==0) goto NEXTB;
      if((i%2) && !(j%2)){
        ans[i][j]='#'; cntb--;
      }
    }
  }
  NEXTB:;
  rep(i, 100){
    rep(j, 100){
      cout << ans[i][j];
      if(j==99) cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 100000
int pertition(int *,int,int);
 
int x;

int main(void){
  int i,a,n;
  int A[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  a = pertition(A,0,n-1);
  for(i=0;i<n;i++){
    if(i==a) printf("[%d]",A[i]);
    else printf("%d",A[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
  return 0;
}

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

Measured memory_bytes: 996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    int sum=0;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
        sum+=a[i];
    }
    int u=inf,v=0;
    REP(i,n){
        if(u>abs(sum-n*a[i])){
            u=abs(sum-n*a[i]);
            v=i;
        }
    }
    cout << v << endl;
}

Measured memory_bytes: 3636
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <iomanip>
#include <bitset>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main() {
	int n;cin>>n;
	int arr[n];
	loop(n,i,0)cin>>arr[i];
	for(int i=n-1;i>=0;i-=2){
		cout<<arr[i]<<' ';
		arr[i]=-1;
	}
	for(int i=0;i<n;i++){
		if(arr[i]!=-1)cout<<arr[i]<<' ';
	}
	return 0;
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb insert
#define lb lower_bound
#define ub upper_bound
#define sz(v) ((ll)v.size())
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define F first
#define S second
#define pii pair<ll,ll> 
const ll mod = 1000000007;
const ll mod1= 1000000009;
const ll base= 2323233;
const ll base1=3424424;
#define MAXN 2000004
#define trace1(x)                cerr << #x << ": " << x << "\n";
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";
ll v[100002];
set<ll> in[100002];
vector<ll> out[100002];

ll a[100002];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n,m,i;
  cin>>n>>m;
  priority_queue<ll> pq;
  ll ans=0;
  for(i=0;i<n;i++) cin>>a[i], pq.push(a[i]), ans+=a[i];
  while(m--){
    auto tp = pq.top();
    pq.pop();
    pq.push(tp/2);
    ans+=tp/2-tp;
  }
  cout<<ans;

  return 0;
} 

Measured memory_bytes: 9336
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
//#define ivorysi
#define MAXN 100005
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
	res = 0;char c = getchar();T f = 1;
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) out(x / 10);
	putchar('0' + x % 10);
}
int N;
int a[1005][1005];
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	read(N);
	int t = 0,k = 0;
	for(int i = 1 ; i <= N ; ++i) {
		t += i;
		if(t >= N) {k = i;break;}
	}
	if(t != N) {puts("No");}
	else {
		puts("Yes");
		out(k + 1);enter;
		int cnt = 0;
		for(int j = 1 ; j <= k ; ++j) {
			for(int i = j ; i <= k ; ++i) {
				a[j][i] = ++cnt;
			}
			for(int i = j + 1 ; i <= k + 1 ; ++i) {
				a[i][j] = a[j][i - 1];
			}
		}
		for(int i = 1 ; i <= k + 1 ; ++i) {
			out(k);
			for(int j = 1 ; j <= k ; ++j) {
				space;out(a[i][j]);
			}
			enter;
		}
	}
	return 0;
}


Measured memory_bytes: 3200
import numpy as np

n, m, c = list(map(int, input().split()))
b = np.matrix(list(map(int, input().split())))
a = np.matrix([list(map(int, input().split())) for i in range(n)])
res = int(sum([i > 0 for i in a * b.T + c])[0, 0])
print(res)


Measured memory_bytes: 27216
unittest
{
	assert( [ "5 2", "1 1 2 2 5" ].parse.expand.solve == 1 );
	assert( [ "4 4", "1 1 2 2" ].parse.expand.solve == 0 );
	assert( [ "10 3", "5 1 3 2 4 1 1 2 3 4" ].parse.expand.solve == 3 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nk[ 1 ], as );
}

auto solve( long k, long[] as )
{
	as.sort();
	auto gs = as.group.map!( ( a ) => a[ 1 ] ).array;
	
	if( gs.length <= k ) return 0;
	
	gs.sort();
	auto ds = gs.take( gs.length - k );
	
	return ds.sum;
}


Measured memory_bytes: 11516
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define ff first
#define mp make_pair
#define ss second
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repp(i,a,b) for(int i=a;i<=b;i++)
// #define endl '\n'
#define mod 998244353
#define pi 3.14159265358979323
#define INF 1e15

int po(int x, int n){
    int res=1;
    while(n>0){
        if(n&1)
            res=res*x;
        x*=x;
        n>>=1;
    }
    return res;
}

int bin(int x, int n){
    int res=1; x%=mod;
    while(n){
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}

bool prime(int n){
    if(n==3)return 1;
    repp(i,2,sqrt(n)){
        if(n%i==0)return 0;
    }
    return 1;
}

// vector<int> adj[500001];
// int flag=0;
// int vis[500001]={0}, par[200001]={0}, top[500001];

// void dfs(int n, int p){
//     vis[n] = 1;
//     for(auto i: adj[n]){
//         if(top[i] == top[n]) flag=1;
//         if(!vis[i]) dfs(i, n);
//     }
// 

// vector<int> pr(2000005, 1), xx[2000005];
// void sieve(int n){ 
//     for(int p=2; p<n; p++){ 
//         if(pr[p]){ 
//             for(int i=p; i<n; i += p){
//                 pr[i]=0;
//                 xx[i].pb(p);
//             }
//         } 
//     } 
// } 

void solve(){
    int x, n, f=0, ans=INF; cin>>x>>n;
    int arr[n];
    rep(i,0,n) cin>>arr[i];
    rep(i,0,n){
        if(arr[i]==x){f=1; break;}
    }
    if(!f) return void(cout<<x<<endl);
    for(int i=x+1; i<=101; i++){
        f=0;
        rep(j,0,n){
            if(arr[j]==i){
                f=1; break;
            }
        }
        // if(i==8) cout<<f<<endl;
        if(!f){
            ans=i; break;
        }
    }
    for(int i=x-1; i>=-1; i--){
        f=0;
        rep(j,0,n){
            if(arr[j]==i){
                f=1; break;
            }
        }
        if(!f){
            if(ans-x>=x-i)ans=i;
            break;
        }
    }
    cout<<ans<<endl;

}

signed main()
{
    fast
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author zhangyong
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
                out.println("Possible");
            } else {
                out.println("Impossible");
            }
        }

    }
}



Measured memory_bytes: 21844
def this (k):
  a=int(pow(1+8*k,0.5))
  return (a-1)//2
from collections import Counter
c=Counter([])
n=int(input())
for i in range(2,int(pow(n,0.5))+1):
  if n%i==0:
    sumi=0
    while n%i==0:
      n=n//i
      sumi+=1
    c[i]=sumi
if n!=1:
  c[n]=1
ans=0
for item in c.values():
  ans+=this(item)
print (ans)

Measured memory_bytes: 9568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 2100000000
#define MOD 1000000007

bool dbgflag = false; //debug

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

  int n;
  cin >> n;
  vector<ll> height(n);
  for (int i = 0; i < n; i++) cin >> height[i];
  vector<ll> people(n);
  for (int i = 0; i < n; i++) people[i] = i - height[i];
  sort(people.begin(), people.end());

  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    ll k = i+height[i];
    cnt += (ll)(upper_bound(people.begin(), people.end(), k) - lower_bound(people.begin(), people.end(), k)); 
  }

  cout << cnt << endl;
}


Measured memory_bytes: 6376
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	long n,a,b,sum=0;
    n=sc.nextLong();
    a=sc.nextLong();
    b=sc.nextLong();
    
    sum=(n/(a+b))*a+((n%(a+b))>a?a:(n%(a+b)));
    System.out.print(sum);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    int N = S.size();

    int ans = -1;
    for (int i=0; i<S.size(); i++) {
        int cnt = 0;
        for (int j=i; j<N; j++) {
            if (S.at(j)=='A' || S.at(j)=='C' || S.at(j)=='G' || S.at(j)=='T' ) cnt++;
            else break;
        }
        ans = max(ans,cnt);
    } 

    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
  import sys
  input=sys.stdin.buffer.readline
  h,w=map(int,input().split())
  s=input()
  a=x=s[0]==35
  b=y=a and 1or 0
  d=[(b,a)]
  d_add=d.append
  for i in range(1,w):
    f=s[i]==35
    b+=a^f and 1or 0
    a=f
    d_add((b,a))
  for _ in range(h-1):
    s=input()
    f=s[0]==35
    y+=x^f and 1or 0
    b=y
    a=x=f
    p=[(b,a)]
    p_add=p.append
    for i in range(1,w):
      f=s[i]==35
      b+=a^f and 1or 0
      c,g=d[i]
      c+=f^g and 1or 0
      if b>c:b=c
      a=f
      p_add((b,a))
    d=p
  print(b+1>>1)
main()

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

int main()
{
	long long int n;
	cin >> n;
	
	long long int sum = 0;
	for (int i = 1; i <= n; ++i)
	{
		if ((i%3 == 0) or (i%5 == 0))
		{
			continue;
		}
		sum += i;
	}
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 今日の天気の入力
		String weather = sc.next();
		
		// 明日の天気を予測
		switch(weather) {
		case "Sunny":
			System.out.println("Cloudy");
			break;
		case "Cloudy":
			System.out.println("Rainy");
			break;
		case "Rainy":
			System.out.println("Sunny");
			break;
		}
	}
}


Measured memory_bytes: 23380
#include <iostream>
#include <cmath>
#include <vector>
#include <math.h>
using namespace std;
int main(){
    int N,D;
    cin>>N>>D;
    int count = 0;
    vector<vector<int>> points(N, vector<int>(D) );
    for(int i =0; i< N;i++){
        for(int jn=0 ; jn < D;jn++)
        cin >> points[i][jn];
    }
    //for(int i=0;i<N;i++){
    //    cout << points[i][1]<<endl;
    //}
    for(int i=0;i<N;i++){
        for(int j=i;j<N;j++){
            int dist=0;;
            if(i==j){
                continue;
            }
            for(int p=0;p<D;p++){
                dist += pow((points[i][p] - points[j][p]),2.0);
                //cout << points[i][p] << "    "  <<points[j][p]<<endl;
            }
            long double amari = sqrt(dist) - (int)sqrt(dist);
            //cout <<"num "<< i << " " << j <<  " "<< sqrt(dist)<<" "<<  (int)sqrt(dist)<< endl;
            //cout << amari<<endl;
            if(amari == 0){
                count++;
            }
        }
    }
    cout << count << endl;

    return 0;

}


Measured memory_bytes: 256
n,m = map(int,input().split())
g = [[],[]]
for i in range(m):
  a,b = sorted(map(int,input().split()))
  if a == 1:
    g[0].append(str(b))
  elif b == n:
    g[1].append(str(a))
g0 = set(g[0])
g1 = set(g[1])
if g0 & g1:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 26624
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string s;
  while (cin >> s) {
    vi v(s.size());
    rep(i, s.size()) v[i] = s[i] - '0';
    while (v.size() > 1) {
      vi w;
      loop(i, 1, v.size()) w.pb((v[i] + v[i - 1]) % 10);
      v = w;
    }
    cout << v.front() << endl;
  }
}

Measured memory_bytes: 3032
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
using namespace std;
 
int main(){
   
   int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   int k;
   cin>>k;
   
   cout<<a[k-1];
   
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
long long n,ans;
int main(){
    scanf("%lld",&n);
    ans=1000000000010;
    for(int i=1;i<=sqrt(n);++i){
        if(n%i==0){
            ans=n/i+i-2<ans?n/i+i-2:ans;
        }
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] d = new int[n][2];
        for (int i = 0 ; i < n ; i++) {
            for (int j = 0 ; j < 2 ; j++) {
                d[i][j] = sc.nextInt();
            }
        }
        int c = 0;
        for (int i = 0 ; i < n ; i++) {
            if (d[i][0] == d[i][1]) {
                c++;
            } else {
                c = 0;
            }
            if (c >= 3) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");

    }

}


Measured memory_bytes: 36072
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100 + 7, INF = 1e7;
int n, m, dp[maxn][maxn];
char s[maxn][maxn];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) scanf("%s", s[i] + 1);
	for (int i = 0; i <= n + 1; ++i) {
		for (int j = 0; j <= m + 1; ++j) 
			dp[i][j] = INF;
	}
	dp[1][1] = s[1][1] == '#' ? 1 : 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if(i > 1) {
				if(s[i][j] == '#') dp[i][j] = min(dp[i][j],  
							dp[i - 1][j] + (s[i - 1][j] == '#'? 0 : 1));
				else dp[i][j] = min(dp[i][j], dp[i - 1][j]);
			}
			if(j > 1) {
				if(s[i][j] == '#') dp[i][j] = min(dp[i][j], 
							dp[i][j - 1] + (s[i][j - 1] == '#'? 0 : 1));
				else dp[i][j] = min(dp[i][j], dp[i][j - 1]); 
			}
		}
	}
	printf("%d\n", dp[n][m]);
	return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.14159265358979323846;
double pi2=pi/2.0;
double eps=1e-8;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,0,-1,0};
int dw[4]={0,1,0,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll a[n];
    ll sum=0;
    ll ans=0;
    rep(i,0,n){
        cin>>a[i];
        (ans+=sum*a[i])%=mod;
        (sum+=a[i])%=mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5204
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
//#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
const ll INF=(1ll<<60)-1;
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll fact[100000+2];
ll ncrfast(ll n, ll r, ll p)
{
   if (r==0)
      return 1;
    return (fact[n]* modInverse(fact[r], p) % p *
            modInverse(fact[n-r], p) % p) % p;
}
void bfs(ll node, vector<ll> adj[],vector<bool> &visit,vector<ll> &dis)
{
    queue<ll> q;
    // ve<bool> visit(n+1);
    // ve<ll> dis(n+1);
    visit[node] = true;
    dis[node] = 0;
    q.push(node);
    while (!q.empty())
    {
        ll s = q.front();
        q.pop();
        // process node s
        for (auto u : adj[s])
        {
            if (visit[u])
                continue;
            visit[u] = true;
            dis[u] = dis[s] + 1;
            q.push(u);
        }
    }
}
void NumNodesInSubTree(int s, int e, vector <ll> adj[] , vector<ll> &count1 )
{
    count1[s] = 1;
    for (auto u : adj[s])
    {
        if (u == e)
        cont;
        NumNodesInSubTree(u, s,adj,count1);
        count1[s] += count1[u];
    }
}
class abc
{
    public:
    ll ind;
    ll val;
};
bool fun1(abc x,abc y)
{
    return x.val < y.val;
}
// bool fun2( abc x , abc y )
// {
//     return x.y < y.y ;
// }
void dfs( ll ind , vector<bool> &visit  , vector<ll> adj[] )
{
    visit[ind]=true;
    for(int i=0;i<adj[ind].size();i++)
    {
        if( !visit[ adj[ind][i]] )
        dfs(adj[ind][i],visit,adj);
    }
}
///////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*ll tc;
    cin>>tc;
    while(tc--)
    {}*/
    ll n;
    cin>>n;
    cout<< fixed << setprecision(15)<< 2*atan(1)*4*n<<'\n';
}



Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n,a;
  cin>>n>>a;
  n*=n;
  n-=a;
  cout<<n<<"\n";
  
  return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
const int maxn = 1000005;
const int maxm = maxn*2;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
int n,m,a[55];
ll dp[55][55][2505];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m;
    for(int i = 1;i<=n;i++) cin>>a[i];
    dp[0][0][0] = 1;
    for(int i = 1;i<=n;i++) {
        for(int j = 0;j<=n;j++) {
            for(int k = 0;k<=n*50;k++) {
                dp[i][j][k] += dp[i-1][j][k];
                if(j>=1 && k>=a[i]) dp[i][j][k] += dp[i-1][j-1][k-a[i]];
            }
        }
    }
    ll ans = 0;
    for(int i = 1;i<=n;i++) ans += dp[n][i][i*m];
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 54656
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define mymalloc(p,n) {p = malloc((n)*sizeof(*p));if ((p)==NULL) {printf("not enough memory?\n"); exit(1);};}

typedef struct node{
	struct node *parent;
	struct node *right;
	struct node *left;
	long key;
}node;

typedef struct{
	struct node *root;
}tree;

node *createNode(long n){
	node *node;
	mymalloc(node,1);
	node->parent=NULL;
	node->right=NULL;
	node->left=NULL;
	node->key=n;
	return node;
}

void insert(tree *T, node *z){
	node *x,*y;
	y=NULL;
	x=T->root;
	while(x!=NULL){
		y=x;
		if(z->key<x->key){
			x=x->left;
		}else{
			x=x->right;
		}
	}
	z->parent=y;
	if(y==NULL){
		T->root=z;
	}else{
	if(z->key<y->key){
		y->left=z;
	}else{
		y->right=z;
	}}
}

void findPrint(tree *T,long key){
	node *x;
	x=T->root;
	while(x!=NULL){
		if(key==x->key){
			puts("yes");
			return;
		}
		if(key<x->key){
			x=x->left;
		}else{
			x=x->right;
		}
	}
	puts("no");
}
void preorder(node *root){
	printf(" %ld",root->key);
	if(root->left!=NULL){
		preorder(root->left);
	}
	if(root->right!=NULL){
		preorder(root->right);
	}
}

void inorder(node *root){
	if(root->left!=NULL){
		inorder(root->left);
	}
	printf(" %ld",root->key);
	if(root->right!=NULL){
		inorder(root->right);
	}
}


void freeNode(node *root){
	if(root->left!=NULL){
		freeNode(root->left);
	}
	if(root->right!=NULL){
		freeNode(root->right);
	}
	free(root);
}

void printTree(node *root){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
}

main(){
	long i,n,m;
	tree *T;
	node *obj;
	char s[10];
	mymalloc(T,1);
	T->root=NULL;
	scanf("%ld",&n);
	for(i=0;i<n;i++){
		scanf(" %s",s);
		if(strcmp(s,"insert")==0){
			scanf(" %ld",&m);
			obj=createNode(m);
			insert(T,obj);
		}else{
		if(strcmp(s,"print")==0){
			printTree(T->root);
		}else{
		if(strcmp(s,"find")==0){
			scanf(" %ld",&m);
			findPrint(T,m);
		}}}
	}
	freeNode(T->root);
	free(T);
	return 0;
}

Measured memory_bytes: 19364
import java.util.Scanner;

public class Main {
  	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();
		int S = sc.nextInt();

		int ans = 0;

		for(int i=0;i<=K;i++){
			for(int j=0;j<=K;j++){
				/*
				for(int k=0;k<=K;k++){
					if(i+j+k == S){
						ans++;
					}
				}
				*/
				if(((S-(i+j)) <= K) && (S-(i+j) >= 0)){
					ans++;
				}
				
			}
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 23376
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)1e3+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n;
vector <int> v[MAXN];

int d[MAXN][MAXN];
int dp[MAXN][MAXN];
int ans = 0;
int mark[MAXN][MAXN];

int f(int x, int t) // solve t' th match of x
{
	// TRACE2(x,t);
	if(mark[x][t])
	{
		cout << -1 << endl;
		exit(0);
	}
	if(dp[x][t] != -1) return dp[x][t];

	if(t == n-1) return 0;

	mark[x][t] = 1;

	int next = v[x][t];
	ll res =  max(f(x,t+1), f(next, d[next][x] + 1)) + 1;

	mark[x][t] = 0;
	return dp[x][t] = res;
}


int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n;

	memset(dp,-1,sizeof dp);

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

	for (int i = 0; i < n; ++i)
		ans = max(ans, f(i,0));

	cout << ans << endl;
}

Measured memory_bytes: 16256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from itertools import groupby
def resolve():
    n,a,d=map(int,input().split())
    if(d==0):
        if(a==0): print(1)
        else: print(n+1)
        return
    if(d<0): a,d=-a,-d

    A=[None]*(2*n+2)
    for k in range(n+1):
        L=k*a+k*(k-1)*d//2
        R=k*a+k*(2*n-k-1)*d//2
        r=L%d
        A[2*k]=(r,L//d,0)
        A[2*k+1]=(r,R//d,1)
    A.sort()
    
    ans=0
    for key,iter in groupby(A,lambda x:x[0]):
        now=0
        over=0
        for r,v,q in iter:
            if(q==0):
                if(not over): now=v
                over+=1
            else:
                over-=1
                if(not over): ans+=v-now+1

    print(ans)
resolve()

Measured memory_bytes: 82524
var x = require("fs").readFileSync("/dev/stdin", "utf8");
x = x.split("\n");
var a = x[0], b = x[1];

for(var i=0; i<2;i++){
 a += a; 
}

if(a.includes(b) === true){
 console.log("Yes"); 
} else {
 console.log("No"); 
}


Measured memory_bytes: 19172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int maxn=0x3f3f3f3f;
int main()
{
    int a[3],ans=0;
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if((a[1]-a[0])%2)
    {
        a[0]++;
        a[2]++;
        ans++;
    }
    else
    {
        ans+=(a[1]-a[0])/2;
        a[0]=a[1];
    }
    ans+=a[2]-a[1];
    if(a[2]-(a[0]+a[2]-a[1])>0)
    {
        ans+=(a[2]-(a[0]+a[2]-a[1]))/2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
	val (a, b, c) = readLine()!!.split(" ").map { it.toInt() }
	val g = gcd(a, b)
	if (c % g == 0) {
		println("YES")
	} else {
		println("NO")
	}
}

fun gcd(a: Int, b: Int): Int {
	val m = a % b
	if (m == 0) {
		return b
	} else {
		return gcd(b, m)
	}
}

Measured memory_bytes: 36220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;cin >> n >> k;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end(),greater<ll>());
  ll ans=0;
  for(int i=0;i<n;i++){
    if(i<k){
      continue;
    }
    else{
      ans+=a[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
s = list(input())
s.reverse()
s += ["0"]
n = len(s)
dp = [[10**7 for _ in range(2)] for _ in range(n+1)]
dp[0][0] = 0
for i in range(n):
	for j in range(2):
		x = int(s[i]) + j
		for a in range(10):
			kurisagaru = False
			if a >= x:
				b = 0
			else:
				b = 10 + a - x
				kurisagaru = True
			dp[i+1][kurisagaru] = min(dp[i+1][kurisagaru], dp[i][j]+a+b)
print(dp[n][0])

Measured memory_bytes: 198196
#include<stdio.h>

int ss(int i){
  int sum=0;
  int n;
  while(i>=1){
    n=i%10;
    sum+=n;
    i/=10;
  }
  return sum;
}

int main(){
  int n,a,b;
  int i;
  int ssum=0,s;
  scanf("%d %d %d",&n,&a,&b);
  for(i=1;i<=n;i++){
    s=ss(i);
    if (s>=a&&s<=b) ssum+=i;
  }
  printf("%d\n",ssum);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   cin>>n;
   string s;
   cin>>s;

   // int ans = 0;
   // for (int i = 1; i < 1<<n; ++i)
   // {
   //    string tmp = "";
   //    for (int j = 0; j < n; ++j)
   //    {
   //       if(i&(1LL<<j)){
   //          tmp += s[j];
   //       }
   //    }

   //    sort(tmp.begin(), tmp.end());
   //    ((tmp).erase(unique((tmp).begin(), (tmp).end()), (tmp).end()));
   //    if(sz(tmp) != __builtin_popcount(i))continue;
   //    ans++;
   //    cout<<tmp<<endl;
   // }

   int freq[26];
   memset(freq, 0, sizeof freq);

   for (int i = 0; i < n; ++i)
   {
      freq[s[i]-'a']++;
   }

   int ans = 1;
   for (int i = 0; i < 26; ++i)
   {
      if(freq[i] == 1){
         ans *= 2;
         ans %= mod;
      }
      else if(freq[i] > 1){
         ans *= (freq[i] + 1);
         ans %= mod;
      }
   }
   ans--;
   ans += mod;
   ans %= mod;

   cout<<ans;

   #warning make sure N size is correct!
   return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#define ll long long
using namespace std;
#define N 100009
#define mod 1000000007

int main(){
    ll n;
    cin>>n;
    vector<int> data;
    ll minus_count=0;
    for (ll i=0; i<n; i++){
        ll p;
        cin>>p;
        if (p<0) minus_count++;
        if (p<0) p*=-1;
        data.push_back(p);
    }
    
    sort(data.begin(),data.end());
    
    ll sum=0;
    if (minus_count%2==0){
        for (ll i=0; i<n; i++) sum+=data[i];
    }
    else{
        data[0]*=-1;
        for (ll i=0; i<n; i++) sum+=data[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 892
#include<stdio.h>
int main()
{
    int n,i,d,s,number=0;
    scanf("%d",&n);
    int k = n;
    while(n%10 != 0){
        d=n%10;
        s=n/10;
        number=(number*10)+d;
        n=s;
    }

    if(number == k){
        printf("Yes");
    }
    else{
        printf("No");
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

ll MOD = 1000000007;

int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    char turn = 'a';
    while(true) {
        if (turn == 'a') {
            if (A.length() == 0) {
                cout << 'A' << endl;
                break;
            }
            turn = A[0];
            A = A.substr(1, A.length()-1);
        } else if (turn == 'b'){
            if (B.length() == 0) {
                cout << 'B' << endl;
                break;
            }
            turn = B[0];
            B = B.substr(1, B.length()-1);
        } else if (turn == 'c'){
            if (C.length() == 0) {
                cout << 'C' << endl;
                break;
            }
            turn = C[0];
            C = C.substr(1, C.length()-1);
        }
     }
    return 0;
}


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

#define INF 100000000001
#define INFS 1000000000
#define PI 3.141592653589793238

int main() {
    int n, now, tmp;
    cin >> n >> now;
    long long ans=0;


    for(int i=0; i<n-1; i++){
        cin >> tmp;
        if(now>tmp){
            ans += now - tmp;
        }
        else now = tmp;
    }

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

Measured memory_bytes: 3620