akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int n, m;
vector<int> a[100010];
priority_queue<int> h;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,n) {
        int u, v;
        cin >> u >> v;
        if (u > m) continue;
        a[u].emplace_back(v);
    }
    ll res = 0;
    FORE(i,m-1,0) {
        FOR(j,0,SZ(a[m-i])-1) h.push(a[m-i][j]);
        if (!h.empty()) {
            res += h.top();
            h.pop();
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "YES" : "NO";
}



int main(){
    int n,q; cin >> n >> q;
    string st; cin >> st;

    int ac[n];
    rep(i,n){
        ac[i] = 0;
    }

    rep1(i,n-1){
        if(st[i-1] == 'A' and st[i] == 'C') ac[i]++;
    }

    int s[n+1];
    s[0] = 0;
    rep(i,n){
        s[i+1] = s[i] + ac[i];
    }

    rep(i,q){
        int l,r; cin >> l >> r;

        cout << s[r] - s[l] << endl;
    }




}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> a(n), b(n), c(n);
	for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
	vector<vector<int>> dp(n, vector<int>(2));
	dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
	for(int i = 1; i < n; i++){
		dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][2], dp[i-1][0]);
		dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
	}
	cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
	return 0;
}


Measured memory_bytes: 9864
N=int(input())
W=[input() for _ in range(N)]

w=set(W)
answer="Yes"

if len(w)==len(W):
    for i in range(1,N):
        if W[i-1][len(W[i-1])-1]==W[i][0]:
            pass
        else:
            answer="No"
            break
    print(answer)
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  string s;
  cin >> s;
  ll ans = 10000;
  for (char c = 'a'; c <= 'z'; c++) {
    int tmp = 0;
    int l = 0;
    REP(i, s.size()) {
      if (s[i] == c) {
        tmp = max(i - l, tmp);
        l = i + 1;
      }
    }
    tmp = max((ll)s.size() - l, (ll)tmp);
    ans = min(ans, (ll)tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <functional>

using namespace std;
static const int INF = 1e9;
typedef pair<int, int> P;

void solve()
{
	string s;
	cin >> s;
	string hand;
	while (hand.size() < s.size())
	{
		hand += "gp";
	}
	int ans = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		if (s[i] == 'g' && hand[i] == 'p')
		{
			++ans;
		}
		else if (s[i] == 'p' && hand[i] == 'g')
		{
			--ans;
		}
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 512
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    s =int(input())

    if s == 7 or s == 5 or s == 3:
        print("YES")
    else:
        print("NO")

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

int main(){

    int x, a, b, c;
    cin >> x;

    a = x / 3600;
    b = (x - 3600 * a) / 60;
    c = x - 3600 * a - 60 * b;

    cout << a << ':' << b << ':' << c << "\n";
}


Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main(void){
	char c_table[]={'k','s','t','n','h','m','y','r','w'};
	char p_table[]="aiueo";
	string s,ans;
	cin>>s;
	for(int i=0;i<s.size();i+=2){
		string tmp;
		if(s[i]-'0' > 1){
			tmp+=c_table[s[i]-'0'-2];
			if(s[i+1]=='T') tmp+=p_table[0];
			else if(s[i+1]=='L') tmp+=p_table[1];
			else if(s[i+1]=='U') tmp+=p_table[2];
			else if(s[i+1]=='R') tmp+=p_table[3];
			else if(s[i+1]=='D') tmp+=p_table[4];
		}else if(s[i]-'0' == 1){
			if(s[i+1]=='T') tmp+=p_table[0];
			else if(s[i+1]=='L') tmp+=p_table[1];
			else if(s[i+1]=='U') tmp+=p_table[2];
			else if(s[i+1]=='R') tmp+=p_table[3];
			else if(s[i+1]=='D') tmp+=p_table[4];
		} if(s[i]-'0' == 0){
			if(s[i+1]=='U'){
				tmp+="nn";
			}else if(s[i+1]=='T') tmp+="wa";
			else if(s[i+1]=='D') tmp+="wo";
		}
		ans+=tmp;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <algorithm>
#include <stdint.h>

int ps[5005];
int64_t dp[5005];

int main(){
  int N,A,B;
  scanf("%d %d %d",&N,&A,&B);
  for(int i=1;i<=N;i++){
    scanf("%d",&ps[i]);
    for(int j=0;j<=N;j++){
      if(j<ps[i]){
	dp[j]+=A;
      }else if(j>ps[i]){
	dp[j]+=B;
      }
    }
    for(int j=1;j<=N;j++){
      dp[j]=std::min(dp[j],dp[j-1]);
    }
  }
  printf("%ld\n",dp[N]);
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll d1[400100];
ll d2[400100];

int main(){
  clr(d1,0);
  clr(d2,0);
  ll n,k,c;
  cin>>n>>k>>c;
  string s;
  cin>>s;
  rep(i,0,c){
    s += "x";
  }
  ll c1 = 0;
  rep(i,0,s.sz){
    if(c1==0 && s[i]=='o'){
      d1[i] = 1;
      c1 = c;
    }
    else if(c1>0){
      c1--;
    }
  }
  ll c2 = 0;
  per(i,0,s.sz){
    if(c2>=c && s[i]=='o'){
      d2[i] = 1;
      c2 = 0;
    }
    else{
      c2++;
    }
  }
  ll a = 0;
  ll b = 0;
  rep(i,0,s.sz){
    a += d1[i];
    b += d2[i];
  }
  if(a!=k||b!=k){
    return 0;
  }
  rep(i,0,n){
    if(s[i]=='o'){
      ll a = d1[i];
      ll b = d2[i];
      if(a==1&&b==1){
        cout << i+1 << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 8068
N=int(input())
tlst=[]

for i in range(N):
    t=int(input())
    tlst.append([list(map(int,input().split())) for _ in range(t)])
ans=0
for i in range(2**N):
    bit=[0]*N
    cnt=0
    for j in range(N):
        if (i>>j)&1==1:
            bit[j]=1
            cnt+=1
    
    for j in range(N):
        if bit[j]==1:
            for xt,yt in tlst[j]:
                if bit[xt-1]!=yt:
                    cnt=-1
                    break
            
            if cnt==-1:
                break
    
    ans=max(ans,cnt)

print(ans)

Measured memory_bytes: 44908
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("AC")
    else:print("WA")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#n = ip()                              #入力整数1つ
#n,k= (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意
#xor は(a ^ b)でいける

if a[0] != 'A':j(0)
b = a[2:len(a)-1]
if b.count('C') != 1:j(0)
if a[len(a)-1] == 'C':j(0)
b = a[1:]
for i in range(1,len(a)):
    p = a[i].lower()
    if not (p == a[i] or a[i]=='C'):
        j(0)
j(1)

Measured memory_bytes: 5144
N = int(input())
j_dic = {}
for _ in range(N):
    A = int(input())
    j_dic[A] = (j_dic.get(A,0) + 1)%2

ans = 0
for key in j_dic:
    if j_dic[key] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 15068
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  ll n,i,a;
  vector<ll> ans;
  cin >> n;
  a=n;
  for(i=2;i*i<=n;i++){
    if(a%i==0){
      ll tmp=0;
      while(a%i==0){
        tmp++;
        a=a/i;
      }
      ans.push_back(tmp);
    }
  }
  if(a!=1){
    ans.push_back(1);
  }
  ll sum=0;
  for(i=0;i<ans.size();i++){
    for(ll j=1;ans[i]-j>=0;j++){
      ans[i]=ans[i]-j;
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N;
    N = scanner.nextInt();
    int[] V = new int[N];
    int[] C = new int[N];
    for (int i = 0; i < N; i++)
      V[i] = scanner.nextInt();
    for (int i = 0; i < N; i++)
      C[i] = scanner.nextInt();

    int ans = 0;
    for (int i = 0; i < N; i++)
      ans += Math.max(0, V[i] - C[i]);

    System.out.println(ans);
  }
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


struct Sieve {
  int n;
  vector<int> f, primes;
  //初期化、primesの中にnまでの素数
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  //xが素数（fの中にある）かを判断
  bool isPrime(int x) { return f[x] == x;}
  //xを素因数分解
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  //素因数分解したものを、)vector<P> (値、数)にする
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


int main() {

  ll q;
  cin>>q;

  Sieve sieve(100005);
  vector<int> V=sieve.primes;
  map<ll,ll>mp;
  rep(i,V.size()){
    mp[V[i]]++;
  }
  vector<ll> v(100005,0);
  ll cnt=0;
  for(ll i=1;i<=100000;i++){
    if (mp[(i+1)/2]>=1 and mp[i]>=1){
      cnt++;
    }
    v[i]=cnt;
  //  cout<<cnt<<" "<<i<<'i'<<endl;
  }
  rep(i,q){
    int l1,r1;
    cin>>l1>>r1;
    ll ans=v[r1]-v[l1-1];
    cout<<ans<<endl;

  }
}


Measured memory_bytes: 5632
#include<iostream>
using namespace std;
int main() {
	int N, K, ans = 0;
	int A[100][100];
	int d[100];
	int sunuke[100] = {};
	cin >> N >> K;
	for (int i = 0; i < K; i++) {
		cin >> d[i];
		for (int j = 0; j < d[i]; j++) {
			cin >> A[i][j];
			sunuke[A[i][j]-1] = 1;
		}
	}
	for (int k = 0; k < N; k++) {
		if (sunuke[k] == 0) {
			ans = ans + 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        s[i]='x';
    }
    cout<<s<<"\n";
}

Measured memory_bytes: 3652
S=input()
A=int(S[0:2])
B=int(S[2:4])
if (A== 0 or A>=13) and (B==0 or B>=13):
  print("NA")
elif (A== 0 or A>=13) and (B!=0 or B<=12):
  print("YYMM")
elif (A!=0 or A<=12) and (B== 0 or B>=13):
  print("MMYY")
else:
  print("AMBIGUOUS")




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

int main(){
    int a,b;
    cin>>a>>b;
    if(a+b==15)cout<<'+'<<endl;
    else if(a*b==15)cout<<'*'<<endl;
    else cout<<'x'<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int a,b;  cin>>a>>b;
  cout<<a*b<<endl;
  return 0;
}


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

void f(int n,char c){
    for(int i=0;i<n;i++){
        cout<<c;
    }
}

int main() {
int a,b,c,d,dx,dy;
cin>>a>>b>>c>>d;
dx=c-a;
dy=d-b;
f(dy,'U');
f(dx,'R');
f(dy,'D');
f(dx+1,'L');
f(dy+1,'U');
f(dx+1,'R');
f(1,'D');
f(1,'R');
f(dy+1,'D');
f(dx+1,'L');
f(1,'U');
cout<<endl;
	return 0;
}

Measured memory_bytes: 256
class Card:
    def __init__(self, name):
        self.name = name
        self.value = int(name[1])
    def __lt__(self, other):
        return self.value < other.value
    def __repr__(self):
        return self.name

def bubble_sort(C, N):
    for i in range(N):
        for j in range(N-1, i, -1):
            if C[j] < C[j-1]:
                C[j], C[j-1] = C[j-1], C[j]
    return C

def selection_sort(C, N):
    for i in range(N):
        minj = i
        for j in range(i, N):
            if C[j] < C[minj]:
                minj = j
        C[i], C[minj] = C[minj], C[i]
    return C

n = int(input())
cards = [Card(s) for s in input().split()]

bubbled_cards = bubble_sort(cards[:], n)
selected_cards = selection_sort(cards[:], n)
print(' '.join(str(s) for s in bubbled_cards))
print('Stable')
print(' '.join(str(s) for s in selected_cards))
if bubbled_cards == selected_cards:
    print('Stable')
else:
    print('Not stable')

Measured memory_bytes: 7792
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const LL MOD=924844033;
const LL g=5;
const LL gi=554906420;
const LL N=200005*8;
struct qq
{
	LL x,y,last;
}e[N*2];LL num,last[N];
LL n;
LL pow (LL x,LL y)
{
	if (y==1) return  x;
	LL lalal=pow(x,y>>1);
	lalal=lalal*lalal%MOD;
	if (y&1) lalal=lalal*x%MOD;
	return lalal;
}
void init (LL x,LL y)
{
	num++;
	e[num].x=x;e[num].y=y;
	e[num].last=last[x];
	last[x]=num;
}
LL tot[N];
LL a[N],b[N];
void dfs (LL x,LL fa)
{
	tot[x]=1;
	for (LL u=last[x];u!=-1;u=e[u].last)
	{
		LL y=e[u].y;
		if (y==fa) continue;
		dfs(y,x);
		tot[x]+=tot[y];
	}
	if (fa!=0) 	{a[tot[x]]++;a[n-tot[x]]++;}
}
LL JC[N],inv[N];
LL bin[N];
void ntt (LL *a,LL n,LL o)
{
	for (LL u=0;u<n;u++)	bin[u]=(bin[u>>1]>>1)|((u&1)*(n>>1));
	for (LL u=0;u<n;u++)
		if (u<bin[u])
			swap(a[u],a[bin[u]]);
	for (LL u=1;u<n;u<<=1)
	{
		LL w,t,wn=pow(o==1?g:gi,(MOD-1)/(u<<1));
		for (LL i=0;i<n;i=i+(u<<1))
		{
			w=1;
			for (LL j=0;j<u;j++)
			{
				t=w*a[u+i+j]%MOD;
				a[u+i+j]=(a[i+j]-t+MOD)%MOD;
				a[i+j]=(a[i+j]+t)%MOD;
				w=w*wn%MOD;
			}
		}
	}
	if (o==-1)
	{
		LL Inv=pow(n,MOD-2);for (LL u=0;u<n;u++) a[u]=a[u]*Inv%MOD;
	}
}
int main()
{
	//printf("%lld\n",pow(g,MOD-2));
	num=0;memset(last,-1,sizeof(last));
	scanf("%lld",&n);
	for (LL u=1;u<n;u++)
	{
		LL x,y;
		scanf("%lld%lld",&x,&y);
		init(x,y);init(y,x);
	}
	dfs(1,0);
	JC[0]=1;for (LL u=1;u<=n;u++) JC[u]=JC[u-1]*u%MOD;
	inv[n]=pow(JC[n],MOD-2);for (LL u=n-1;u>=0;u--) inv[u]=inv[u+1]*(u+1)%MOD;
	for (LL u=1;u<=n;u++) a[u]=a[u]*JC[u]%MOD;
	for (LL u=0;u<=n;u++) b[u]=inv[n-u];
	LL now=1;while (now<=n) now<<=1;now<<=1;
	ntt(a,now,1);ntt(b,now,1);
	for (LL u=0;u<now;u++) a[u]=a[u]*b[u]%MOD;
	ntt(a,now,-1);
	for (LL u=1;u<=n;u++)
	{
		now=JC[n]*inv[u]%MOD*inv[n-u]%MOD*n%MOD;
		now=(now-a[n+u]*inv[u]%MOD+MOD)%MOD;
		printf("%lld\n",now);
	}
	return 0;
}

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

int main() {
 int N;
   cin >> N;
  int sum;
  for(int i =0 ; i<N ; i++){
    int l, r;
    cin >> l >> r ;
    sum += r-l+1;
  }
  cout << sum << endl;
}
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set;

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

#define     int                 ll
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
	int n; cin >> n;
	cout<<(1000 - n%1000)%1000<<'\n';
}

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


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

int main() {
	string s;
	cin >> s;
	bool def = true;
	
	for (int i = 0; i < s.size(); i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (s[i] != s[j]) {
				continue;
			}
			else {
				def = false;
				break;
			} 
		}
	}
	if (def) cout << "yes" << endl;
	else cout << "no" << endl;

	return 0;
}

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

int h, w, d;
typedef pair<int, int> P;
vector<P> a;
vector<int> v;

int dist(int p, int q){
	return abs(a[p].first - a[q].first) + abs(a[p].second - a[q].second);
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> h >> w >> d;
	a.resize(h*w);
	for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j){
//			cout << i << " " << j << "\n";
			int t;
			cin >> t;
//			cout << "t " << t << "\n";
			a[t-1] = P(i, j);
		}
//	for(int i=0; i<h*w; ++i)
//		cout << a[i].first << " " << a[i].second << "\n";
	for(int i=0; i<d; ++i){
//		cout << i << "\n";
		v.push_back(0);
	}
	for(int i=d; i<h*w; ++i){
//		cout << i << "\n";
		v.push_back(dist(i, i-d));
		v[i] += v[i-d];
	}
//	for(int i=0; i<h*w; ++i)
//		cout << v[i] << "\n";
	int q;
	cin >> q;
	while(q--){
//		cout << q << "\n";
		int l, r;
		cin >> l >> r;
		cout << v[r-1] - v[l-1] << "\n";;
	}
}

Measured memory_bytes: 2296
#include<iostream>
using namespace std;
int main(){
  string s;
  cin>>s;
  
  int ans=0;
  for(int i=0;i<s.size();i++) {
    if(s.at(i)=='1') {
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        long n = sc.NextInt();
        long m = sc.NextInt();

        Console.WriteLine(n == 1 ? (m == 1 ? 1 : m - 2) : (m == 1 ? n - 2 : (n - 2) * (m - 2)));
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 11092
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;

int main(){
  int n;
  int a;
  cin>>n;
  cin>>a;
  n=n%500;

  if(n<=a)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, m;
  cin >> n >> m;
  ll ans = n*m - 2*n - 2*m + 4;
  cout << abs(ans) << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3628
$|=1;
$Q = <STDIN>;chomp $Q;
for($i=0;$i<$Q;$i++){
	$line = <STDIN>;chomp $line;
	($l,$r)=split " ",$line;
	push @L,$l;
	push @R,$r;
}

@P=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317);

$s=0;
for($i=3;$i<=100000;$i++){
	$f=1;
	$ii=($i+1)/2;
	for($j=0;$P[$j]*$P[$j]<=$ii;$j++){
		if($ii%$P[$j]==0) { $f=0; last; }
	}
	if ($f) {
		for($j=0;$P[$j]*$P[$j]<=$i;$j++){
			if($i%$P[$j]==0) { $f=0; last;}
		}
		$s=$s+1 if ($f);
	}
	$S[$i]=$s;
	#push @PP,$i;
}

for($i=0;$i<$Q;$i++){
	$c=$S[$R[$i]]-$S[$L[$i]-1];
	print "$c\n";
}

Measured memory_bytes: 24704
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  float x,y,b,p;
  cin>>n;
  FOR(i,n){
    cin>>x>>y>>b>>p;
    float a1,a2;
    if(b>=5 && p>=2){
      x*=0.8;
      y*=0.8;
      a1=x*b+y*p;
    }else{
      a1=x*b+y*p;
      if(b<5){
        b=5;
      }
      if(p<2){
        p=2;
      }
      x*=0.8;
      y*=0.8;
      a2=x*b+y*p;
      a1=min(a1,a2);
    }
    cout<<a1<<endl;
  }

  return 0;
}




Measured memory_bytes: 3316
numbers = list(map(lambda x: int(x), input().split()))
nums = list(map(lambda x: int(x), input().split()))
t = numbers[1]

total = t
for i in range(1, len(nums)):
    check = nums[i] - nums[i - 1] 
    total += check if check <= t else t

print(total)
    


Measured memory_bytes: 30788
N, A, B = map(int, input().split())

def sumEachDigit(n):
    s = str(n)
    array = list(map(int, s))
    return sum(array)

res = 0
for i in range(1, N+1):
    sum_i = sumEachDigit(i)
    if sum_i >= A and sum_i <= B:
        res += i

print(res)

Measured memory_bytes: 3188
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($a,$b) = explode(" ",trim(fgets(STDIN)));
//$A  = explode(" ",trim(fgets(STDIN)));
//https://ta1sa.hatenablog.com/entry/2018/06/10/224718
$list=array(1,6,9,36,81,216,729,1296,6561,7776,46656,59049);
$dp = array_fill(0,100010,1000000010);
$dp[0]=0;
for($i=0;$i<$N;$i++) {
  for($j=0;$j<count($list);$j++) {
    if ($i+$list[$j]>$N) continue;
    $dp[$i+$list[$j]]=min($dp[$i+$list[$j]],$dp[$i]+1);
  }
}
printf("%d\n",$dp[$N]);


Measured memory_bytes: 18036
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define f first
#define s second
signed main()
{
    FAST;
    
     int i=0,j=0,k=0,n=0,m=0,count=0,temp=0,z;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,anss=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,zz=0,d=0,val=0;
    
    string a;
    cin>>a;
    
    if(a[2]==a[3] && a[4]==a[5])
    {
        cout<<"Yes"<<endl;
    }
    
    else cout<<"No"<<endl;
    
        
        
    
    
    
    
    
}


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

const int INF = 1<<28;
const int MAXN = 1000001;
const int di[] = {0,1,0,-1};
const int dj[] = {1,0,-1,0};
bool isPrime[MAXN];
int I[MAXN], J[MAXN];

const int H = 1111;
const int W = 1111;
int G[H][W];
int m, n;
pair<int, int> dp[H][W];

int main() {
  fill(isPrime, isPrime+MAXN, true);
  isPrime[0] = isPrime[1] = false;
  for(int i = 2; i < MAXN; ++i) {
    if(!isPrime[i]) continue;
    for(int j = i*2; j < MAXN; j += i) {
      isPrime[j] = false;
    }
  }

  {
    fill(G[0], G[H], INF);
    int pi = 500, pj = 500, d = 2;
    G[pi][pj] = 1;
    I[1] = pi, J[1] = pj;
    for(int num = 2; num < MAXN; ++num) {
      for(int k = 0; k < 4; ++k) {
        int nd = (d + k + 2) % 4;
        int ni = pi + di[nd];
        int nj = pj + dj[nd];
        if(G[ni][nj] != INF) continue;
        G[ni][nj] = num;
        pi = ni, pj = nj, d = nd;
        I[num] = pi, J[num] = pj;
        break;
      }
    }
  }

  while(cin >> m >> n && (m|n)) {
    int si = I[n], sj= J[n];
    fill(dp[0], dp[H], make_pair(-1, -1));
    dp[si][sj] = make_pair(isPrime[G[si][sj]], 
                           isPrime[G[si][sj]] * G[si][sj]);
    pair<int, int> res = dp[si][sj];
    for(int i = si; i+1 < H; ++i) {
      for(int j = 0; j < W; ++j) {
        if(dp[i][j].first == -1) continue;
        for(int d = -1; d <= 1; ++d) {
          int ni = i + 1;
          int nj = j + d;
          if(nj < 0 || nj >= W) continue;
          if(G[ni][nj] > m) continue;
          dp[ni][nj]
            = max(dp[ni][nj],
                  make_pair(dp[i][j].first + isPrime[G[ni][nj]],
                            max(dp[i][j].first, isPrime[G[ni][nj]]*G[ni][nj])));
          res = max(res, dp[ni][nj]);
        }
      }
    }
    cout << res.first << " " << res.second << endl;
  }
  return 0;
}

Measured memory_bytes: 24416
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll n;
    cin>>n;
    ll ans = 0;
    for(ll i=1; i<=n; i++){
        ll x;
        cin>>x;
        if((i&1)&&(x&1)){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 3624
/*s1190073  Rina Sato,
File name: prog1a.c,
2012 4/18(Wed),
This is a sort program.*/

#include<stdio.h>
int main(void){
  int j,i,N,A[100],key;
  scanf("%d",&N);
  for(j = 0 ; j < N ; j++){
    scanf("%d",&A[j]);
    printf("%d",A[j]);
    
    /*make space on each number*/
    if(j < N-1){ 
      printf(" ");
    }
  }
  printf("\n");

  for(j = 1 ; j < N ;j++){
    key = A[j];
    /* insert A[j] into the sorted sequence A[1,...,j-1] */
    i = j - 1;
    while(A[i] > 0 && A[i] > key){
      A[i+1] = A[i];
      i = i - 1;
    }
    A[i+1] = key;
    for(i = 0 ; i < N ; i++){
      printf("%d",A[i]);
      if(i < N-1){
	printf(" ");
      }
    }     
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

use std::ascii::AsciiExt;
use std::cmp;
use std::collections::VecDeque;
use std::io::Write;
use std::iter::Iterator;

fn main() {
    input! {
        n:usize,
        m:usize,
        bredge:[(usize, usize);m],
    }

    let mut bredge_mut = bredge; 
    bredge_mut.sort_by_key(|&a| a.1);


    let mut ans = 1;
    let mut t = bredge_mut[0].1;
    for i in 0..m {
        if  t <= bredge_mut[i].0 {
            ans += 1;
            t = bredge_mut[i].1;
        }
    }

    println!("{}", ans);

}


Measured memory_bytes: 6396
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
#define sp cout<<"---------------------------------------------------"<<endl
const long long inf=2e15+7;
long long pre[200010]; 
int main(){
      long long n,i,x,p1,p2,p3,minn,P;
      cin>>n;
      for(i=1;i<=n;i++){
          scanf("%lld",&x);
          pre[i]=pre[i-1]+x;
      }
      p1=1,p2=2,p3=3;
      long long ans=inf;
      for(p2;p2<n;p2++){
        minn=inf;
        for(i=p1;i<p2;i++)
          if(abs(pre[i]-(pre[p2]-pre[i]))<minn){
            minn=abs(pre[i]-(pre[p2]-pre[i]));
            p1=i;
          }else break;
        minn=inf;
        if(p3<=p2)p3=p2+1;
        for(i=p3;i<=n;i++)
          if(abs((pre[i]-pre[p2])-(pre[n]-pre[i]))<minn){
            minn=abs((pre[i]-pre[p2])-(pre[n]-pre[i]));
            p3=i;
          }else break;
        minn=inf;long long maxn=0;
        minn=min(pre[p1],min(pre[p2]-pre[p1],min(pre[p3]-pre[p2],pre[n]-pre[p3])));
        maxn=max(pre[p1],max(pre[p2]-pre[p1],max(pre[p3]-pre[p2],pre[n]-pre[p3])));
        ans=min(ans,maxn-minn);
      }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 1792
def main():
  import sys

  f = "" # 前回のステップの文字 "<" or ">" 
  ans = 0 # Answer
  count = 0 # Ai
  continuous = 0 # ">" が何回連続するか
  
  for m in sys.stdin.readline().strip("\n"):
    if m=="<":
      if f==">" and count>0:
        # 清算
        ans-=count*continuous
        count=0
      count+=1
        
    else:
      if f=="<":
        # セット
        continuous=0
      count-=1
      continuous+=1
      if count==-1:
        ans+=continuous
        count=0
        continue

    ans+=count
    f=m

  print(ans)
    
if __name__ == '__main__':
    main()

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

const int M = 2e5 + 100;
int h[M];
vector<int> e[M];

int bfs(int u) {
    for (int v : e[u])
        if (h[v] >= h[u]) return 0;
    return 1;
}

int main() {
    int n, m; cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> h[i];
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) ans += bfs(i);
    cout << ans;
}


Measured memory_bytes: 11448
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N;
    cin >> N;
    lint ans = 0;
    FOR(i, 1, N+1) {
        if(i%3 != 0 && i%5 != 0) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
/*
	Author: Ritik Patel
	
	Idea: 
*/


//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& STL DEBUGGER &&&&&&&&&&&&&&&&&&&&&&&&&&&

// #define _GLIBCXX_DEBUG       // Iterator safety; out-of-bounds access for Containers, etc.
// #pragma GCC optimize "trapv" // abort() on (signed) integer overflow.

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& LIBRARIES &&&&&&&&&&&&&&&&&&&&&&&&&&&

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

/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; 
*/
//find_by_order()->returns an iterator to the k-th largest element(0-based indexing)
//order_of_key()->Number of items that are strictly smaller than our item

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#define int long long int
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()
 
// const ld PI  = 3.141592;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEBUG &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define XOX
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}
 
void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
 
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&

int N = (int)1e6 + 2;


void solve(){
  	int n; cin >> n;
  	N = n + 1;
    int spf[N];
    for(int i = 1; i < N; ++i){
        spf[i] = i;
    }
    for(int i = 2; i < N; ++i){
        if(spf[i] == i){
            for(int j = i * i; j < N; j += i){
                spf[j] = min(spf[j], i);
            }
        }
    }
    map<int, int> mp;
    int res = 1;
    for(int i = 2; i <= n; ++i){
        int total = 1;
        mp.clear();
        int num = i;
        while(num != 1){
            mp[spf[num]]++;
            num /= spf[num];
        }
        for(auto &x: mp){
            total *= (x.second + 1);
        }
        res += total * i;
        int here = total * i;
    }
    cout << res << '\n';
    
}



int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    int T = 1; 
    // cin >> T;
    for(int i = 1; i <= T; ++i){
        // brute();
        solve();
    }
    return 0;
}

/*
Sample inp
*/

Measured memory_bytes: 81788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		int data = Integer.parseInt(reader.readLine());
		
		for(int i=1; i<=data; i++){
			if(i%3==0){
				builder.append(" ").append(Integer.toString(i));
				continue;
			}
			int x=i;
			do{
				if(x%10==3){
					builder.append(" ").append(Integer.toString(i));
					break;
				}
				x/=10;
			}while(x!=0);
		}
		
		System.out.println(builder);
		
	}
}

Measured memory_bytes: 21036
def main():
    N = int(input())
    W = list(map(int, input().split()))
    ans = []
    for i in range(N):
        res1, res2 = 0, 0
        res1 += sum(W[:i])
        res2 += sum(W[i:])
        ans.append(abs(res2 - res1))
    print(min(ans))
main()

Measured memory_bytes: 3060
//atcoder alsing

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

int main(){
    int n, m, k; int count = 0;
    cin>>n>>m>>k;

    for(int i = n; i<= m; ++i){
        if(i%k==0) count++;
    }

    cout<<count;
    return 0;

}

Measured memory_bytes: 3624
def nikkei19q_b():
    N = int(input())
    A = str(input())
    B = str(input())
    C = str(input())
    ans = 0
    for i in range(N):
        chset = set([A[i], B[i], C[i]])
        change = len(chset) - 1
        ans += change
    print(ans)

nikkei19q_b()

Measured memory_bytes: 3064
//by Judge
#define HGS_AK_IOI true
#include<bits/stdc++.h>
#define int long long
#define Rg register
#define fp(i,a,b) for(Rg int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(Rg int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(Rg int i=head[u],v=e[i].to;i;v=e[i=e[i].nxt].to)
#define open(S) freopen(S".in","r",stdin),freopen(S".out","w",stdout)
#define ll long long
using namespace std;
const int inf=1e9+7;
const int M=1e5+3;
typedef int arr[M];
#ifndef Judge
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#endif
char buf[1<<21],*p1=buf,*p2=buf;
template<class T>inline T Min(T x,T y){return x<y?x:y;}
template<class T>inline T Max(T x,T y){return x>y?x:y;}
template<class T>inline bool cmax(T& a,T b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T& a,T b){return a>b?a=b,1:0;}
inline int read(){ int x=0,f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0'; return x*f;
} int n,ans; arr pre,suf;
struct node{ int l,r; }a[M]; inline bool cmp(node x,node y){ return x.r<y.r; }
signed main(){ n=read(); fp(i,1,n) a[i].l=read(),a[i].r=read(); sort(a+1,a+1+n,cmp);
	fp(i,1,n) pre[i]=Max(pre[i-1],a[i].l); fd(i,n,1) suf[i]=Max(suf[i+1],a[i].l);
	fp(i,2,n) cmax(ans,Max(a[1].r-pre[i-1]+1,0ll) + Max(a[i].r-suf[i]+1,0ll)),
		cmax(ans,Max(a[1].r-Max(pre[i-1],suf[i+1])+1,0ll) + Max(a[i].r-a[i].l+1,0ll));
	return !printf("%lld\n",ans);
}

Measured memory_bytes: 5376
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include<iostream>
#include<map>
#include<set>
#include<vector>

using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
#define rep(i, n) for (i32 i = 0; i < (i32)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64, i64>;

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    i64 h, w, m;
    cin >> h >> w >> m;
    set<P> st;
    i64 max_row = 0, max_col = 0;
    map<i64,i64> mp_row,mp_col;
    rep(i, m) {
        i64 H, W;
        cin >> H >> W;
        H--;
        W--;
        mp_row[H]++;
        mp_col[W]++;
        st.insert(P(H, W));
    }
    for (auto v:mp_row) {
        if (v.second > max_row) {
            max_row = v.second;
        }
    }
    for (auto v:mp_col) {
        if (v.second > max_col) {
            max_col = v.second;
        }
    }
    set<i64> row,col;
    i64 cnt_row = 0,cnt_col = 0;
    rep(i,h) {
        if (mp_row[i] == max_row)row.insert(i);
    }
    rep(i,w) {
        if (mp_col[i] == max_col)col.insert(i);
    }
    i64 ans = max_row + max_col;
    i64 cnt = 0;
    for(auto v:st){
        if(row.count(v.first) && col.count(v.second))cnt++;
    }
    if(cnt == row.size() * col.size())ans--;
    cout << ans << endl;
}

Measured memory_bytes: 88032
import collections
n = int(input())
d = list(map(int,input().split()))
init = d[0]
c = collections.Counter(d)
d.sort()
maxim = d[-1]
#print(c)
if init != 0 or c[0] >= 2:
    print(0)
    exit()
else:
    ans = 1
    for i in range(1,maxim):
        ans *= c[i]**c[i+1]
        #print(i)
    print(ans%998244353)

Measured memory_bytes: 62516