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

int H, W;
vector<string> S;
vector<vector<int>> reach;
long long cntBlack = 0;
long long cntWhite = 0;

void search(int h, int w){
    reach[h][w] = 1;
    int dh[4] = {-1, 1, 0, 0};
    int dw[4] = {0, 0, -1, 1};
    for(int i=0; i<4; i++){
        int nh = h + dh[i];
        int nw = w + dw[i];
        if(0 <= nh && nh < H && 0 <= nw && nw < W && S[nh][nw] != S[h][w] && reach[nh][nw] == 0){
            search(nh,nw);
        }    
    }
    if(S[h][w]=='#') cntBlack++;
    if(S[h][w]=='.') cntWhite++;
}

int main(){
    cin >> H >> W;
    S = vector<string>(H);
    reach = vector<vector<int>>(H, vector<int>(W, 0));  // S[h][w]が X のとき reach[h][w] = 1,  X でないとき、 reach[h][w] = 0。
    for(int i=0; i<H; i++)  cin >> S[i];

    long long ans = 0;
    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            cntBlack = 0;
            cntWhite = 0;
            if(reach[h][w] != 1){    
                search(h,w);
                ans += cntBlack*cntWhite;
            }
        }
    }
    cout << ans << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int x,t;
    cin>>x>>t;
    cout<<max(x-t,0ll)<<endl;
    return 0;
}


Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

// ref: https://codeforces.com/blog/entry/77148?#comment-619272
// crux: partitioning

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=998244353;
const int N=2e5+5;

vector<int> fact(N),invfact(N);

int pw(int x,int n)
{
    int res=1;

    x%=M;
    for(;n;n/=2)
    {
        if(n%2)
            res=(res*x)%M;

        x=(x*x)%M;
    }

    return res;
}

void compute_fact()
{
	fact[0]=1;
	for(int i=1;i<N;++i)
        fact[i]=(fact[i-1]*i)%M;

	invfact[N-1]=pw(fact[N-1],M-2);
	for(int i=N-2;i>=0;--i)
        invfact[i]=(invfact[i+1]*(i+1))%M;
}

int nCr(int n,int r)
{
	if(r<0 || n<r)
		return 0;

	int res=(fact[n]*invfact[r])%M;
	res=(res*invfact[n-r])%M;

	return res;
}

void solve()
{
    int n,m,k;
    cin>>n>>m>>k;

    int ans=0;
    for(int i=0;i<=k;++i)
        ans=(ans+(nCr(n-1,i)*((m*pw(m-1,n-i-1))%M))%M)%M;

    cout<<ans;
}

int32_t main()
{
    fast();

    compute_fact();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 6284
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int main(){
  int n,m;cin>>n>>m;
  int d[n+1];
  vector<int> v[n+1];
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  fill(d,d+n+1,-1);
  d[1]=2;
  queue<pii> q;
  q.push(make_pair(1,2));
  while(q.size()>0){
    pii p=q.front();q.pop();
    int pf=p.first,ps=p.second;
    //cout<<pf<<endl;
    int y;
    if(ps==1)y=2;
    else y=1;
    for(int i=0;i<v[pf].size();i++){
      int now=v[pf][i];
      if(now==1)continue;
      else if(d[now]==-1){
        d[now]=y;
        q.push(make_pair(now,y));
        continue;
      }
      else if(d[now]==0)continue;
      else{
        if(ps==0){
          d[now]=0;
          q.push(make_pair(now,0));
        }
        else{
          if(ps==d[now]){
            d[now]=0;
            q.push(make_pair(now,0));
          }
          else continue;
        }
      }
    }
  }
  int cnt[3];fill(cnt,cnt+3,0);
  for(int i=1;i<=n;i++){
    cnt[d[i]]++;
    //cout<<d[i]<<endl;
  }
  long long ans=0;
  ans+=(long long)(cnt[0]-1)*cnt[0]/2+(long long)cnt[0]*(cnt[1]+cnt[2])+(long long)cnt[1]*cnt[2];
  if(cnt[0]>0){
    ans=(long long)(n-1)*(n-2)/2+(long long)(n-1);
  }
  ans-=(long long)m;
  cout<<ans<<endl;
}

Measured memory_bytes: 6272
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int k=0,max;
		int[] A=new int[1000];
		int[] B=new int[1000];
		int[] count=new int[1000];
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		for(int i=0;i<n;i++){
			A[i]=sc.nextInt();
		}
		for(int j=0;j<m;j++){
			B[j]=sc.nextInt();
		}
		sc.close();
		for(int j=0;j<m;j++){
			if(B[j]>=A[k]){
				B[j]=k;
				k=0;
			}else{
				k++;
				j-=1;
			}
		}
		max=count[0];
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(B[j]==i){
					count[i]+=1;
				}
			}
			if(count[i]>max){
				max=count[i];
				k=i+1;
			}

		}
		System.out.printf("%d\n",k );
	}

}

Measured memory_bytes: 34616
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define all(a) a.begin(),a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

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

    int n; string s; cin>>n>>s;
    int ans=0,cur=0;
    rep(i,s.size())if(s[i]=='I'){cur++;chmax(ans,cur);}else{cur--;}
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>

using namespace std;

//??\???
#define MAX_N 100000
#define MAX_M 100000
int N,M;
int s[MAX_N];
int a[MAX_M];

int main() {
  ios::sync_with_stdio(false);

  cin >> N >> M;

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

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

  int cs[N];
  cs[0] = 0;
  for(int i = 1; i < N; i++) {
    cs[i] = cs[i-1] + s[i-1];
  }

  long long dis = 0;
  int cur = 0;
  for(int i = 0; i < M; i++) {
    dis += abs( cs[cur + a[i]] - cs[cur] );
    cur = cur + a[i];
  }

  cout << dis%100000 << "\n";
  return 0;
}

Measured memory_bytes: 4408
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=100010;
long long a[maxn],n;
long long ans;
int main () {
	int n;
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	scanf("%d", &n);
	for(int i = 1;i <= n;i ++){
		scanf("%d", &a[i]);
		if(a[i-1]&&a[i]) --a[i-1],--a[i],++ans;
		ans+=a[i]/2,a[i]&=1;	
}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;
using LL = long long;

int n;
string s;

int main(void)
{
	cin >> n;
	cin >> s;
	int itr = 0;
	int minitr = 0;
	for (char c : s)
	{
		if (c == '(')
		{
			itr++;
		}
		else
		{
			itr--;
		}
		minitr = min(minitr, itr);
	}
	for (int i = 0; i < -minitr; ++i)s.insert(s.begin(), '(');
	itr -= minitr;
	for (int i = 0; i < itr; ++i)s.push_back(')');
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 18, mod = 998244353, inv2 = 499122177;
int n, a[N], b[N], len, m, s;
void fwt(int * a, int op) {
    for(int i = 1; i < len; i <<= 1) {
        int s = i << 1;
        for(int j = 0; j < len; j += s)
            for(int k = 0; k < i; ++k) {
                int x = a[j + k], y = a[i + j + k];
                a[j + k] = (x + y) % mod; a[i + j + k] = (x - y + mod) % mod;
                if(op == -1) a[j + k] = 1ll * a[j + k] * inv2 % mod, a[i + j + k] = 1ll * a[i + j + k] * inv2 % mod;
            }
    }
}
int qpow(int a, int b) {
    int c = 1;
    while(b) {
        if(b & 1) c = 1ll * c * a % mod;
        a = 1ll * a * a % mod;
        b >>= 1;
    } return c;
}
int main() {
    scanf("%d", &n); m = (1 << n) - 1;
    for(int i = 0; i <= m; ++i) scanf("%d", &a[i]), s = (s + a[i]) % mod;
    s = qpow(s, mod - 2);
    for(int i = 0; i <= m; ++i) a[i] = 1ll * a[i] * s % mod;
    for(int i = 1; i <= m; ++i) b[i] = mod - 1;
    b[0] = m; a[0] = (a[0] - 1 + mod) % mod;
    len = 1 << n;
    fwt(a, 1); fwt(b, 1);
    for(int i = 0; i < len; ++i)
        a[i] = 1ll * qpow(a[i], mod - 2) * b[i] % mod;
    fwt(a, -1);
    for(int i = 0; i <= m; ++i) printf("%d\n", (a[i] - a[0] + mod) % mod);
    return 0;
}


Measured memory_bytes: 5772
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

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

const int INF=1e9;

int main(){
  int n;
  string s;
  cin>>n>>s;
  
  vector<int> A(n),B(n);
  rep(i,n){
    if(i==0){
      if(s[0]=='W') A[0]=1;
      else A[0]=0;
    }
    else if(s[i]=='W') A[i]=A[i-1]+1;
    else A[i]=A[i-1];
  }
  for(int i=n-1;i>=0;i--){
    if(i==n-1){
      if(s[n-1]=='E') B[n-1]=1;
      else B[n-1]=0;
    }
    else if(s[i]=='E') B[i]=B[i+1]+1;
    else B[i]=B[i+1];
  }
  int mi=INF;
  rep(i,n){
    mi=min(mi,A[i]+B[i]);
  }
  cout<<mi-1<<endl;

  return 0;
}

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

vector<ll> minPath;
vector<vector<pair<ll, ll>>> G;

void dfs (int i) {
    for (ll j = 0; j < G[i].size(); j++) {
        if (minPath[G[i][j].first] == -1) {
            minPath[G[i][j].first] = minPath[i] + G[i][j].second;
            dfs(G[i][j].first);
        }
    }
}

int main() {
    ll N; cin >> N;
    G.resize(N);
    ll a, b, c;
    for (ll i = 0; i < N-1; i++) {
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back(make_pair(b, c));
        G[b].push_back(make_pair(a, c));
    }

    ll Q, K; cin >> Q >> K;
    K--;

    minPath.resize(N);
    for (ll i = 0; i < N; i++) minPath[i]--;
    minPath[K] = 0;
    dfs(K);

    ll x, y;
    for (ll i = 0; i < Q; i++) {
        cin >> x >> y;
        x--; y--;
        cout << minPath[x] + minPath[y] << endl;
    }
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  cout << fixed << setprecision(10);
  ll n,d;
  cin>>n>>d;
  vector<vector<ll>> t(n,vector<ll>(d));
  rep(i,n)rep(j,d){
    cin>>t[i][j];
  }
  ll ans=0;
  rep(i,n-1){
   for(int j=i+1;j<n;j++){
     double s=0;
     double h=0;
     rep(u,d){
       h+=(t[i][u]-t[j][u])*(t[i][u]-t[j][u]);
     }
     s=sqrt(h);
     if(s-(int)s==0) ans++;
   }
  }
  COUT(ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  ll n, x = 0LL;
  string s;
  cin >> n >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != '.') {
      x *= 10;
      x += s[i] - '0';
    }
  }
  cout << n * x / 100 << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <algorithm>


int main()
{
    int A, B, C, D, E, F;
    std::cin >> A >> B >> C >> D >> E >> F;
    bool water[3000 + 1] = {}, sugar[3000 + 1] = {};
    for (int a = 0; a <= 3000; ++ a) {
        for (int b = 0; b <= 3000; ++ b) {
            if ((A * a + B * b) * 100 > 3000) break;
            water[(A * a + B * b) * 100] = true;
        }
    }
    for (int c = 0; c <= 3000; ++ c) {
        for (int d = 0; d <= 3000; ++ d) {
            if (C * c + D * d > 3000) break;
            sugar[C * c + D * d] = true;
        }
    }

    int up = 0, down = 1;
    for (int i = 0; i <= 3000; ++ i) if (water[i]) {
        for (int j = 0; j <= 3000 && j <= i / 100 * E && i + j <= F; ++ j) if (sugar[j]) {
            if (up * (i + j) <= j * down) {
                up = j; down = i + j;
            }
        }
    }
    printf("%d %d\n", down, up);
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
s = input()

if s[0]=='A' and s.count('A')==1 and s.count('C')==1 and s[2:-1].count('C')==1 and s.replace('A','a').replace('C','c').islower():
  print('AC')
else:
  print('WA')
  


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int res = 0;

		String result = "";

		res = a*(a-1)+b*(b-1);
		res/= 2;


		System.out.printf("%d\n", res);
		//System.out.printf("%d", result);
	}
}


Measured memory_bytes: 22228
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    if N==M:print('Yes')
    else:print('No')





if __name__ == "__main__":
    main()

Measured memory_bytes: 77148
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector <double>V(N);
	for (auto &x : V) cin >> x;
	sort(V.begin(), V.end());
	double temp = V[0];
	for (int i = 1; i < N; i++) {
		temp = (temp + V[i]) / 2;
	}
	cout << temp;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <cctype>
#include <algorithm>
using namespace std;
int main(void){
    int A , B ;
    cin >> A >> B ;
    if(A + B >=24 ){
        cout << (A+B) -24 << endl;
    }else{
        cout << A+B << endl;
    }
    return 0;
}

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

struct nood
{
    int x,y;
}a[105];

nood b[105];

bool comx(nood a1,nood b1)
{
    return a1.x<b1.x;
}

bool comy(nood a1,nood b1)
{
    return a1.y>b1.y;
}

int main()
{
    int n,i,j,s=0,va[105]={0};
    scanf("%d",&n);
    for(i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].y);
    for(i=1;i<=n;i++) scanf("%d%d",&b[i].x,&b[i].y);
    sort(a+1,a+n+1,comy);
    sort(b+1,b+n+1,comx);
    //for(i=1;i<=n;i++) printf("(%d,%d)\n",a[i].x,a[i].y);
    //for(i=1;i<=n;i++) printf("(%d,%d)\n",b[i].x,b[i].y);
    i=1;j=1;
    while(j<=n)
    {
        i=1;
        while(i<=n)
        {
            if(va[i]) {i++;continue;}
            if(a[i].x<b[j].x&&a[i].y<b[j].y) {va[i]=1;s++;break;}
            i++;
        }
        j++;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()

ans = 0

for i in range(1, n + 1):
    if i % 3 != 0 and i % 5 != 0 and i % 15 != 0:
        ans += i

print(ans)

Measured memory_bytes: 9196
#include <stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=1000005;
const int MAXE=1000005;
typedef pair<int,int> ii;
vector <int> adj[MAXN];
ii ec[MAXE];
int prof[MAXN],low[MAXN],padre[MAXN],cont,N,M,a,b,nec;
bool usa[MAXN];
void bridge(int v){
    int child=0; //contara el n??mero de hijos en el DFST (DFS Tree)
    usa[v]=true;
    //low nos dice el ancestro m??s alto al que apunta alguno de los descendientes de v en DFST
    //prof nos dice en que tiempo se visitaron los nodos en el DFS
    low[v]=prof[v]=++cont;
    for (int i=0; i<(int)adj[v].size(); i++){
        int w=adj[v][i];
        if (!usa[w]){
            child++;
            padre[w]=v;
            bridge(w);
            low[v]=min(low[v],low[w]);
            //(v,w) ser?? una arista de corte si:
            //no podemos alcanzar a ninguno de los ancestros
            //de v o a v desde el ??rbol enraizado en w
            if (low[w]>prof[v])ec[nec++]=make_pair(min(v,w),max(v,w));
        } else if(w!=padre[v]) low[v]=min(low[v],prof[w]);
    }
}
int main()
{
    //Asumimos que el grafo es conexo, no dirigido y simple
    //En caso de no ser conexo lo hacemos para cada componente conexa
    scanf("%d%d",&N,&M);
    for (int i=0; i<M; i++){
        scanf("%d%d",&a,&b);
        adj[a].push_back(b); adj[b].push_back(a);
    }
    //Inicializamos los padres
    fill(padre,padre+N,-1);
    //En caso de ser multicaso inicializar prof,low,usa,ec,nec
    bridge(0);
    //ordenamos los puentes para mostrarlas en orden
    sort(ec,ec+nec);
    //en ec tenemos los puentes
    for (int i=0; i<nec; i++)printf("%d %d\n",ec[i].first,ec[i].second);
    return 0;
}

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

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

  if (x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3592
import sys


input = sys.stdin.readline


def main():
  k, n = map(int, input().rstrip().split())
  a = [int(_) for _ in input().rstrip().split()]
  
  dist = [(a[i] - a[i - 1]) % k for i in range(n)]
  
  print(k - max(dist))


if __name__ == "__main__":
  main()
    

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
int main()
{ 
// freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
   int n,k;
 cin>>n>>k;
  if(n>=2*k-1)
    cout<<"YES";
    else
     cout<<"NO";
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MX 100005
char s[MX];
int N;
int rec(int b,int e){
    if(b>e)return 0;
    if(s[b]==s[e])return rec(b+1,e-1);
    if(s[b]=='x')return 1+rec(b+1,e);
    if(s[e]=='x')return 1+rec(b,e-1);
    puts("-1"),exit(0);
}
int main(void){
    scanf("%s",s),N=strlen(s);
    printf("%d\n",rec(0,N-1));
    return 0;
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int K;
    cin >> K;

    vector<int> vis(K, false);
    int cur = 0;
    for (int i = 0; i < K * 2; i++) {
        cur = (cur * 10 + 7) % K;
        if (vis[cur]) {
            cout << -1 << newl;
            return 0;
        }

        vis[cur] = true;
        if (vis[0]) {
            cout << i + 1 << newl;
            return 0;
        }
    }
    cout << -1 << newl;

    return 0;
}

Measured memory_bytes: 7156
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let s = sc.read_chars();
    let mut k: usize = sc.read();

    let n = s.len();
    let mut ans = vec![];
    for i in 0..n {
        let d = s[i] as usize - 'a' as usize;
        let update = 26 - d;
        if d == 0 {
            ans.push(s[i]);
        } else if 26 <= k + d {
            ans.push('a');
            k -= update;
        } else {
            ans.push(s[i]);
        }
    }
    if k > 0 {
        let n = ans.len();
        let s_n = ans[n - 1];
        let d = s_n as usize - 'a' as usize;
        ans[n - 1] = (((d + k) % 26) as u8 + 'a' as u8) as char;
        // ans[n - 1] = ('a' as u8 + ((ans[n - 1] as u8 - 'a' as u8) + k as u8) % 26) as char;
    }
    println!("{}", ans.iter().collect::<String>());
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2436
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner inp = new Scanner(System.in);

        ArrayList<Integer> input = new ArrayList<>();

        int rows = inp.nextInt();
        int columns = inp.nextInt();

        ArrayList<ArrayList<Integer>> numbers = new ArrayList<>();

        for (int i = 0; i < rows; i++){
            ArrayList<Integer> numberRow = new ArrayList<>();
            for (int j = 0; j < columns; j++) {
                numberRow.add(inp.nextInt());
            }
            numbers.add(numberRow);
        }

        output(numbers, rows, columns);
    }

    public static void output (ArrayList<ArrayList<Integer>> numbers, int rows, int columns) {
        int totalTotal = 0;

        ArrayList<Integer> totalCol = new ArrayList<>();

        for (int i = 0; i < columns; i++) {
            totalCol.add(0);
        }

        for (int i = 0; i < rows; i++){
            int total = 0;
            for (int j = 0; j < columns; j++) {
                if (j != 0) {
                    System.out.print(" ");
                }

                int n = numbers.get(i).get(j);
                System.out.print(n);

                total += n;

                int colTol = totalCol.get(j);
                totalCol.remove(j);
                totalCol.add(j, colTol+n);
            }

            System.out.print(" " + total);

            totalTotal += total;
            total = 0;

            System.out.print("\n");
        }

        for (int i : totalCol) {
            System.out.print(i + " ");
        }

        System.out.print(totalTotal + "\n");
    }
}



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

using namespace std;

const int MAX = 1000001;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> cnt(MAX);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		++cnt[a[i]];
	}
	for(int i = 1; i < MAX; i++){
		int inc = cnt[i];
		for(int j = 2 * i; j < MAX; j+=i){
			cnt[j]+=inc;
		}
	}
	int res = 0;
	for(int i = 0; i < n; i++){
		res+= (cnt[a[i]] == 1);
	}
	cout << res << "\n";
	
//	for(int i = 0; i < 25; i++){
//		cout << i << " - " << cnt[i] << "\n";
//	}
	
	return 0;
}


Measured memory_bytes: 8020
#include <stdio.h>

int cnt;
void insertionSort(int A[], int n, int g)
{
    
    for( int i = g; i < n; ++i ){
        int tmp = A[i];
        int j = i - g;
        while( -1 < j && tmp < A[j] ){
            
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = tmp;
    }
}

void shellSort(int A[], int n)
{
    cnt = 0;
    int m;
    int G[100];
    for( int i = 0; i < 100; ++i ){
        if( i == 0 ) G[i] = n / 2 + 1;
        else G[i] = G[i-1] / 2 - 1;
        if( G[i] < 0 ){
            G[i-1] = 1;
            G[i] = 0;
            m = i;
            break;
        }
    }
    
    for( int i = 0; i < m; ++i )
        insertionSort(A, n, G[i]);
    
    //出力
    printf("%d\n", m);
    for( int i = 0; i < m; ++i ){
        if( i ) printf(" ");
        printf("%d", G[i]);
    }
    printf("\n%d\n", cnt);
    for( int i = 0; i < n; ++i )
        printf("%d\n", A[i]);
}

int main()
{
    //入力
    int n;
    scanf("%d", &n);
    int A[n];
    for( int i = 0; i < n; ++i )
        scanf("%d", &A[i]);
    
    //シェルソート
    shellSort(A, n);
    
    return 0;
}


Measured memory_bytes: 5636
// input! macro from
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

// use std::collections::HashMap;
use std::collections::BTreeMap;
use std::io;
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::max;
use std::cmp::min;

fn read_string() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    line
}

fn read_as_primitive<T: FromStr>() -> T {
    let s = read_string();
    s.trim().parse().ok().expect("failed to parse input")
}

fn read_as_collection<U: FromStr, T: FromIterator<U>>() -> T {
    let s = read_string();
    s.trim().split_whitespace().map(|s| s.parse().ok().expect("failed to parse")).collect()
}

fn read_as_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let s = read_string();
    let elems: Vec<_> = s.trim().split_whitespace().collect();    
    (
        elems[0].parse().ok().expect("failed to parse"), 
        elems[1].parse().ok().expect("failed to parse"),
    )
}

fn fromdigits(xs: &[i32]) -> String {
    let v: Vec<String> = xs.iter().map(|x| x.to_string()).collect();
    v.join("")
}

fn main () {
    let (n, m): (i32, i32) = read_as_pair();
    let mut xs: Vec<i32> = read_as_collection();
    xs.sort_by(|a, b| b.cmp(a));

    let sticks = [2, 5, 5, 4, 5, 6, 3, 7, 6];
    let mut hm = BTreeMap::new();
    for (num, stk) in (1..10).zip(sticks.iter()) {
        hm.insert(num, stk);
    }

    let mut dp: Vec<i32> = vec![-100; 10_005];
    dp[0] = 0;
    for i in 1i32..n+1 {
        for k in &xs {
            let hm_k = *hm[k];
            if i - hm_k >= 0 {
                dp[i as usize] = max(dp[i as usize], dp[(i - hm_k) as usize] + 1);
            }
        }
    }

    let mut ans : Vec<i32> = Vec::new();
    let mut digit_len = dp[n as usize];
    let mut matches = n;
    while digit_len > 0 {
        for k in &xs {
            let hm_k = *hm[k];
            if matches - hm_k >= 0 && dp[(matches - hm_k) as usize] == dp[matches as usize] - 1 {
                digit_len -= 1;
                matches -= hm_k;
                ans.push(*k);
                break;
            }
        }
    }
    
    println!("{}", fromdigits(&ans[..]));
}

Measured memory_bytes: 4352
#include<stdio.h>
int main(){
  int i,j,k;
  int n;
  int ans = 1;
  int a[200001] = {0};
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
   scanf("%d ",&a[i]);
  }
  
  for(i=0;i<n;i++){
   if(ans==a[i]){
    ans++; 
   }
  }
  
  if(ans==1){
   printf("-1\n");
    return 0;
  }
  
  printf("%d\n",n-ans+1);
 return 0; 
}



Measured memory_bytes: 2492
N = int(input())						# 5
A = list( map(int, input().split()) )	# 1 2 3 4 5 ...

if 0 in A:
  print(0)
  exit()

p108 = pow(10,18)
ans = A[0]
for a in A[1:]:
  ans *= a
  if ans > p108:
    print(-1)
    exit()

if ans > p108:
  print(-1)
  exit()

print(ans)



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

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

int main() {
  int N;
  cin >> N;
  int ans=0;
  for(int a=1; a<=N; a++){
    for(int b=1; b<=N; b++){
      for(int c=1; c<=N; c++){
        ans+=gcd(gcd(a,b),c);
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include<stack>
#include<string>
#include<algorithm> 
#include <set>
#include<list>
#include <bit>
#include <bitset>
#include <cstdint>
#include <initializer_list>
using namespace std;
int main() {
	long long int N, ans=0,max_val=10000000; cin >> N;

	vector<long long int >data(N);
	for (int i = 0; i < N; i++)cin >> data[i];
	for (int i = 0; i < N; i++) {
		if (max_val >= data[i]) {
			max_val = data[i];
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4836
def main():
    import sys
    input = sys.stdin.readline

    import heapq
    def dijkstra_heap(s,g,edge):
        #始点sから各頂点への最短距離
        d = [10**20] * (n+2)
        used = [True] * (n+2) #True:未確定
        d[s] = 0
        used[s] = False
        edgelist = []
        sx,sy,sr=edge[s][0],edge[s][1],edge[s][2]
        for i in range(n+2):
            x,y,r=edge[i][0],edge[i][1],edge[i][2]
            dist=((x-sx)**2+(y-sy)**2)**(1/2)
            heapq.heappush(edgelist,(max(dist-r-sr,0),i))
        while len(edgelist):
            minedge = heapq.heappop(edgelist)
            #まだ使われてない頂点の中から最小の距離のものを探す
            v = minedge[1]
            if not used[v]:
                continue
            d[v] = minedge[0]
            used[v] = False
            bx,by,br=edge[v][0],edge[v][1],edge[v][2]
            for i in range(n+2):
                x,y,r=edge[i][0],edge[i][1],edge[i][2]
                dist=((x-bx)**2+(y-by)**2)**(1/2)
                if used[i]:
                    heapq.heappush(edgelist,(max(dist-r-br,0)+d[v],i))
            if not used[g]:
                break
        return d[g]

    sx,sy,gx,gy = map(int,input().split()) #n:頂点数　w:辺の数
    n=int(input())
    edge=[(sx,sy,0),(gx,gy,0)]
    for i in range(2,n+2):
        x,y,r=map(int,input().split())
        edge.append((x,y,r))
    print(dijkstra_heap(0,1,edge))

if __name__ == '__main__':
    main()

Measured memory_bytes: 117468
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;
int main(){
	int n; cin >> n;
	vector<long> A(n);
	vector<long> B(n);
	for (int i = 0; i < n; i++){
		cin >> A[i] >> B[i];	
	}
	long ans = 0;
	long tmp = 0;
	for (int i = n-1; i >= 0; i--){
		A[i] += ans;
		tmp = B[i] -  (A[i] % B[i]);
		ans += tmp; 
		//for (int j = 0; j <= i; j++){
		//	A[j] += tmp;
		//}
		if (A[i] % B[i] == 0) ans -= B[i];

	}

	cout << ans << endl;

	
return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	4 * MAX5;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll t = 1;
ll n, x, k, q, m, y, r;
string s;

// <------------- Implement Functions Here ----------> //

  


// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	map<string,ll> val;
	for(ll i=0;i<n;i++) {
		cin>>s;
		val[s]++;
	}

	ll maxi = 0;
	for(auto it : val) maxi = max(maxi,it.s);

	for(auto it : val) {
		if(it.s == maxi) {
			cout<<it.f;newl;
		}
	}
}

int main() {
	fastio; randomINT;
	//cin >> t;
	while (t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 28636
import java.util.Scanner;

class Main{
	static final long MOD = 1000000007;

	static int H, W, K;
	static long[][] dp = new long[110][10];
	static int ans = 0;
	static long n = 0;





	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int T = sc.nextInt();

		int ans = 1000000000;
		for(int i = 0;i < n;i++){
			int	c = sc.nextInt();
			int	t = sc.nextInt();
			if(t <= T){
				ans = Math.min(ans, c);
			}

		}
		if(ans == 1000000000){
			System.out.println("TLE");
		}else{
			System.out.println(ans);
		}
	}
}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 22996
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		String s[] = new String[N];
		for(int i = 0; i < N; i++){
			s[i] = sc.next();
		}
		Arrays.sort(s);
		for(int i = 0; i < N; i++){
			System.out.print(s[i]);
		}
		System.out.println("");
	}
}

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

int main(){
    string s;   cin >> s;
    int k, ans;  cin >> k;
    for(int i=0; i<s.size(); i++){
        if(i==k-1) ans = s[i]-'0';
        else if(s[i]=='1') continue;
        else ans = s[i]-'0';
        break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FOR(i,j,k) for(int i=j;i<k;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair < int, int > pii;

const int maxn=1e5+100, INF=1000000000+7;

int a,b;
char c[110][110];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>a>>b;
    FOR(i,0,100){
        FOR(j,0,100){
            c[i][j]='.';
        }
    }
    for(int i=99;i>=0;i--){
        for(int j=99;j>=0;j--){
            if((b>1 || (b==1 && a==1)) && (i+j)%2==0 && i%2==1){
                c[i][j]='#';
                b--;
            }
        }
    }
    a--;
    FOR(i,0,100){
        FOR(j,0,100){
            if((i+j)%2==1 && a>0 && i%2==0){
                c[i+1][j]='#';
                if(j==1){
                    c[i][j-1]='#';
                    c[i+1][j-1]='#';
                }
                if(j!=99){
                    c[i][j+1]='#';
                    c[i+1][j+1]='#';
                }
                a--;
            }
        }
    }
    cout<<"100 100"<<endl;
    FOR(i,0,100){
        FOR(j,0,100){
            cout<<c[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include <math.h>
#include <stdlib.h>
#define N 100000

#define MAX 2000000
#define INFTY 1000000

int n, a[MAX+1];

void Heapify(int i)
{
  int l, r, largest, tmp;
  l = 2*i;
  r = 2*i+1;

  if(l <= n && a[l] > a[i])
    largest = l;
  else
    largest = i;
  if(r <= n && a[r] >  a[largest])
    largest = r;

  if(largest != i) {
    tmp = a[i];
    a[i] = a[largest];
    a[largest] = tmp;
    Heapify(largest);
  }
}

int extract()
{
  int maxv;
  if(n < 1)
    return -INFTY;
  maxv = a[1];
  a[1] = a[n--];
  Heapify(1);
  return maxv;
}

void increasedata(int i, int data)
{
  int tmp;

  if(data <a[i])
    return ;
  a[i] =data;
  while(i > 1 && a[i/2] < a[i]) {
    tmp = a[i];
    a[i] = a[i/2];
    a[i/2] = tmp;
    i /= 2;
  }
}

void insert(int data)
{
  n++;
  a[n] = -INFTY;
  increasedata(n,data);
}

int main()
{
  char c[10];
  int data;

  while(1) {
    scanf("%s", c);
    if(strcmp(c, "end") == 0)
      break;
    if(strcmp(c, "insert") == 0) {
      scanf("%d", &data);
      insert(data);
    }
    else {
      printf("%d\n", extract());
    }
  }
  return 0;
}



Measured memory_bytes: 5692
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
print(n + n**2 + n**3)

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int count = 0;
  for (int i = 0; i < N; i++){
    cin >> a.at(i);
    count += a.at(i);
  }
  cout << count - N;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n,maxt,mint=1<<30;
int main()
{
	cin>>n;
	while(n--)
	{
		int tmp;
		cin>>tmp;
		maxt=max(maxt,tmp);
		mint=min(mint,tmp);
	}
	cout<<maxt-mint;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f3f3f3f3f
#define pi 3.1415926535898

#define N 200010
using namespace std;

ll ans;
ll a[N],s[N];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        ans+=s[a[i]]++;
    }
    for(int i=0;i<n;i++)
    {
        cout<<ans-s[a[i]]+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 6712
#include <iostream>
#include <cstdio>
#include <fstream>
using namespace std;

int main(){
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int q;
  cin >> q;

  double x, y, k;
  double ax, ay, bx, by;
  for(int i=0; i<q; i++){
    cin >> x >> y;
    ax = x-x1; ay = y-y1;
    bx = x2-x1; by = y2-y1;
    k = (ax*bx + ay*by)/(bx*bx + by*by);
    printf("%.10lf %.10lf\n", bx*k+x1+0, by*k+y1+0);
  }

  return 0;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;
 
void solve()
{
	int x;
	cin>>x;
	if(x>=30)
		cout<<"Yes";
	else
		cout<<"No";
}
 
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 3648
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e3 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}

int n;

int main()
{
    cin>>n;
    cout<<n*(n+1)/2<<endl;
	return 0;
}

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

namespace test
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			List<int> resultList = new List<int> ();

			int n = int.Parse (Console.ReadLine());
			for (int i =0; i<n; i++) {
				char[] input = Console.ReadLine ().ToCharArray ();
				Array.Sort (input);
				string minString = new string (input);
				Array.Reverse (input);
				string maxString = new string (input);
				resultList.Add (int.Parse(maxString) - int.Parse(minString));
			}

			foreach (int a in resultList) {
				Console.WriteLine (a);
			}



		}


	}
	
}

Measured memory_bytes: 5808
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = /*1'000'000'007;*/998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 100'000;
const int LOGN = 18;

int n, m, k;

int tree[N];

void add(int r, int val)
{
  for (; r < N; r |= r + 1) {
    tree[r] = max(tree[r], val);
  }
}

int get(int r)
{
  int res = 0;
  for (; r >= 0; r = (r & (r + 1)) - 1) {
    res = max(res, tree[r]);
  }
  return res;
}

void solve(int test)
{
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    b[i] = i;
  }
  stable_sort(begin(b), end(b), [&](int x, int y) {
    return a[x] > a[y];
  });
  int ans = 1;
  for (int i = 0; i < n; ++i) {
    int val = get(b[i] - 1);
    add(b[i], val + 1);
    ans = max(ans, val + 1);
  }
  cout << ans << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 1472