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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_H 50
#define MAX_W 50
#define INF 1152921504606846976

typedef pair<i64, i64> P;

i64 H, W;
char G[MAX_H][MAX_W];
i64 d[MAX_H][MAX_W]; // 最短距離

i64 dy[] = {1, 0, -1,  0};
i64 dx[] = {0, 1,  0, -1};

bool inside(i64 y, i64 x) {
  return (0 <= y && y < H && 0 <= x && x < W);
}

i64 solve() {
  REP(y, H) {
    REP(x, W) {
      d[y][x] = INF;
    }
  }

  queue<P> que;
  que.push(mp(0, 0));
  d[0][0] = 0;
  i64 ny, nx;
  while (!que.empty()) {
    P yx = que.front(); que.pop();
    if (yx.F == H - 1 && yx.S == W - 1) break;

    REP(i, 4) {
      ny = yx.F + dy[i];
      nx = yx.S + dx[i];
      if (inside(ny, nx) && d[ny][nx] == INF && G[ny][nx] != '#') {
        que.push(mp(ny, nx));
        d[ny][nx] = d[yx.F][yx.S] + 1;
      }
    }
  }

  return d[H - 1][W - 1];
}

int main() {
  cin >> H >> W;
  i64 cnt_black = 0;

  REP(y, H) {
    REP(x, W) {
      cin >> G[y][x];
      if (G[y][x] == '#') {
        cnt_black++;
      }
    }
  }

  i64 d = solve();
  if (d == INF) {
    cout << -1 << endl;
    return 0;
  }
  cout << H * W - (d + 1) - cnt_black << endl;

  return 0;
}

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

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int cnt=0;
  for(int i=1; i<=N; i++){
    string num=to_string(i);
    int sum=0;
    for(int j=0; j<num.size(); j++){
      int m=num[j]-'0';
      sum+=m;
    }
    if(A<=sum && sum<=B) cnt+=i;
  }
  cout << cnt <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int human = scan.nextInt();
		int checkPoint = scan.nextInt();
		
		int[] humanx = new int[human];
		int[] humany = new int[human];
		int[] checkPointX = new int[checkPoint];
		int[] checkPointY = new int[checkPoint];
		
		for (int i = 0; i < humanx.length; i++) {
			humanx[i] = scan.nextInt();
			humany[i] = scan.nextInt();
		}
		
		for (int i = 0; i < checkPointX.length; i++) {
			checkPointX[i] = scan.nextInt();
			checkPointY[i] = scan.nextInt();
		}
		
		for (int i = 0; i < humanx.length; i++) {
			int p = 0;
			int ans = 1000000000;
			for (int j = 0; j < checkPointX.length; j++) {
				int leng = Math.abs((humanx[i] - checkPointX[j])) + Math.abs((humany[i] - checkPointY[j]));
				if (ans > leng) {
					ans = leng;
					 p = j + 1;
				}
			}
			System.out.println(p);
		}
		scan.close();
	}

}

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

long long dp[10][1010];

int main(){
  int n,s;
  while(cin >> n >> s,n+s){
    for(int i=0;i<=n;i++)
      for(int j=0;j<=s;j++)dp[i][j] = 0;
    dp[0][0] = 1;

    for(int i=0;i<=100;i++){
      for(int j=n-1;j>=0;j--){
	for(int k=s;k>=0;k--){
	  if(dp[j][k] && k+i<=s)dp[j+1][k+i] += dp[j][k];
	}
      }
    }
    cout << dp[n][s] << endl;
  }
}

Measured memory_bytes: 1236
#include<stdio.h>
 
int main(){
 
    int a[10];
    int i, j, temp;
 
 
        for(i = 0; i< 10; i++){
//          printf("??±?±?????????%d\n",i+1);
            while(1){
                scanf("%d",&a[i]);
                if((a[i] >= 0) && (a[i] <= 10000))    
                    break;
                else
                    while( getchar() != '\n' );         
            }
        }
 

    for(i=0; i<10; i++){
        for(j=i+1 ;j<10; ++j){
            if(a[i]<a[j]){
                temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
    }
 

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

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  int i,j;
  for(i=0;i<N;i++)cin >> X[i];
  long ans = (long)1 << 30,temp;
  for(i=1;i<=100;i++) {
    temp = 0;
    for(j=0;j<N;j++) {
      temp += pow(X[j]-i,2.0);
    }
    ans = min(ans,temp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    
	int N,M;
    string S;
    int indexA=0,indexZ=0,result=0;
	cin >> S;
    for(int i=0;i<S.size();i++){
        if(S[i]=='A') {
            indexA=i;
            break;
        }
    }
    for(int i=S.size()-1;i>=0;i--){
        if(S[i]=='Z') {
            indexZ=i;
            break;
        }
    }
    if(indexZ-indexA+1>0){
        result=indexZ-indexA+1;
    }
    cout << result << "\n";
}

Measured memory_bytes: 720
import math

a, b, x = map(int,input().split())

v = a*a*b

if x <= v/2:
  c = (2*x/b)/a
  ans = math.degrees(math.atan(b/c))
else:
  x = v - x
  d = 2*x/(a*a)
  ans = math.degrees(math.atan(d/a))
print(ans)

Measured memory_bytes: 3060
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    A,B,C,D = LMIIS()
    t = True
    while A > 0 and C > 0:
        if t :
            C -= B
        else:
            A -= D
        t ^= True
    if t:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Measured memory_bytes: 65152
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define ii pair<ll,ll>
#define v vector<ll>
#define vii vector<ii>
#define vv vector<vector<ll> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const ll MOD = 1000000007; // 998244353
ll n,a[3001],dp[2][3001][3001];
ll solve(ll turn,ll l,ll r){
    if(l>r)return 0;
    if(dp[turn][l][r]!=-1)
        return dp[turn][l][r];
    ll ans;
    if(!turn){
        ans=a[r]+solve(1-turn,l,r-1);
        ans=max(ans,a[l]+solve(1-turn,l+1,r));
    }
    else{
        ans=-a[r]+solve(1-turn,l,r-1);
        ans=min(ans,-a[l]+solve(1-turn,l+1,r));
    }
    return dp[turn][l][r]=ans;
}
int main(){
    boost;
    memset(dp,-1,sizeof dp);
    cin>>n;
    for (ll i = 0; i < n; ++i)
        cin>>a[i];
    cout<<solve(0,0,n-1);
    return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 141184
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector <int> a(m);
    REP(i,m)cin >> a[i];
    int left=0;
    int right = 0;
    FOR(i,x,n+1){
        if(find(ALL(a),i) != a.end()){
            right++;
        }
    }
    FORR(i,x,0){
        if(find(ALL(a),i) != a.end()){
            left++;
        }
    }

    cout << min(right,left) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=110000;
int n,sum[N],head=1,tail=2;
struct info{
	int num,id;
	inline bool operator <(const info &a)const{
		return num==a.num?id<a.id:num>a.num;
	}
}a[N];
long long ans[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i].num),a[i].id=i;
	sort(a+1,a+n+1);
	while (tail<=n){
		while (a[tail].num==a[tail-1].num) tail++;
		ans[a[head].id]+=1ll*(a[head].num-a[tail].num)*(tail-1);
		if (a[tail].id>a[head].id) a[head].num=a[tail].num;
		else head=tail;
		tail++;
	}
	ans[a[head].id]+=1ll*a[head].num*n;
	for (int i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 2688
import sys

input = sys.stdin.readline

n, m, q = map(int, input().split())
ls = [[0] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
    l, r = map(int, input().split())
    ls[l][r] += 1
for i in range(1, n + 1):
    for j in range(1, n + 1):
        ls[i][j] += ls[i - 1][j] + ls[i][j - 1] - ls[i - 1][j - 1]
for _ in range(q):
    l, r = map(int, input().split())
    print(ls[r][r] - ls[l - 1][r] - ls[r][l - 1] + ls[l - 1][l - 1])

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

int main() {
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];
    
    set<int> values; // insert するときに重複を取り除いてくれます
    for (int i = 0; i < N; ++i) {
        values.insert(d[i]); // 挿入します
    }
    
    // set のサイズを出力します
    cout << values.size() << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(){
    string t;
    cin >> t;
    REP(i, t.length()) {
        if(t[i] == '1') t[i] = '9';
        else t[i] = '1';
    }

    cout << t << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>n;
    rep(i,n)cin>>a[i];
    int okk=1;
    rep(i,n-1){
        if(a[i]>a[i+1])okk=0;
    }
    if(okk){
        Cout("YES");
        return 0;
    }
    rep(i,n){
        rep(j,n){
            if(i==j)continue;
            tmp=i;tmpp=j;
            rep(k,n){
                if(k==tmp)b[k]=a[tmpp];
                else if(k==tmpp)b[k]=a[tmp];
                else b[k]=a[k];
            }
            int ok=1;
            rep(k,n-1){
                if(b[k]>b[k+1])ok=0;
            }
            if(ok){
                Cout("YES");
                return 0;
            }
        }
    }
    Cout("NO");
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
const ll MINF = LLONG_MIN;
const int INT_INF = INT_MAX;
using Tree = vector<pair<int, int>>;
bool checkPrime(int x)
{
    for (int i = 2; i <= sqrt(x); i++)
    {
        if ((x % i) == 0)
            return false;
    }
    return true;
}
int main()
{
    int x;
    cin >> x;
    while (!checkPrime(x))
        x++;
    cout << x << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
using namespace std;



int main(){
    while(1){
        
        
        
        
        
        
    const int mx=1e9+7;
    int n,m,s,go,gt;
    cin>>n>>m>>s>>go>>gt;
    if(n==0 && m==0){break;}
    s--; go--; gt--;
    int a[1000][1000];
    fill(&a[0][0],&a[999][1000],mx);
    for(int i=0;i<n;i++){
        a[i][i]=0;
    }
    for(int i=0;i<m;i++){
        int b,c,d;
        cin>>b>>c>>d;
        a[b-1][c-1]=d;
        //a[c-1][b-1]=d;
    }
    
    for(int i=0;i<n;i++){
        for(int t=0;t<n;t++){
            for(int k=0;k<n;k++){
                a[t][k]=min(a[t][i]+a[i][k],a[t][k]);
            }
        }
    }
    int ans=mx;
    for(int i=0;i<n;i++){
        if(a[s][i]!=mx && a[i][go]!=mx && a[i][gt]!=mx){
            ans=min(a[s][i]+a[i][go]+a[i][gt],ans);
        }
    }
        
        /*
        cout<<endl;
        for(int i=0;i<n;i++){
            for(int t=0;t<n;t++){
                cout<<(a[i][t]==mx? -1:a[i][t])<<" ";
            }
            cout<<endl;
        }
        cout<<endl;
        */
        
        
    assert(ans!=mx);
    cout<<ans<<endl;
    
    
    
    
    
    }
    
    
    return 0;
}


Measured memory_bytes: 6992
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    H, W, K = NMI()
    dp = make_grid(H+1, W, 0)
    move = make_grid(W, W, 0)

    dp[0][0] = 1

    for case in range(2**(W-1)):
        bad_case = False
        prev_bit = -1
        for i in range(W-1):
            now_bit = (case >> i) & 1
            if now_bit == prev_bit == 1:
                bad_case = True
            prev_bit = now_bit
        if bad_case:
            continue

        for b in range(W):

            if b == 0:
                if (case >> 0) & 1:
                    move[0][1] += 1
                else:
                    move[0][0] += 1

            elif b == W - 1:
                if (case >> b - 1) & 1:
                    move[b][b - 1] += 1
                else:
                    move[b][b] += 1

            else:
                if (case >> b - 1) & 1:
                    move[b][b - 1] += 1
                elif (case >> b) & 1:
                    move[b][b + 1] += 1
                else:
                    move[b][b] += 1

    for h in range(1, H+1):
        for w in range(W):
            for i in range(W):
                dp[h][w] += dp[h-1][i] * move[i][w]

    print(dp[H][K-1]%MOD)


if __name__ == "__main__":
    main()

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

using namespace std;
typedef long long ll;

const ll M = (long long) 1e9+7;

vector<ll> fac(2000001); 
vector<ll> ifac(2000001); 


ll mpow(ll x, ll n){ 
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ 
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main()
{
    ll n,k;
    ll X,Y;
    ll x,y;
    cin >> X >> Y;

    ll a,b,c,d;

    a=1;
    b=2;

    c=2;
    d=1;

    if( (d*X-c*Y)%(a*d-b*c)!=0 || (-b*X+a*Y)%(a*d-b*c)!=0 ){
        cout << 0 << endl;
        return 0;
    }else{
        x=(d*X-c*Y)/(a*d-b*c);
        y=(-b*X+a*Y)/(a*d-b*c);
        if( x<0 || y<0 ){
            cout << 0 << endl;
            return 0;
        }
    }

    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<2000000; i++){
        fac[i+1] = fac[i]*(i+1) % M; 
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; 
    }


    ll ans=0;
    ans = comb(x+y, y)%M;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 31616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;

int main() {
	ll n, x, d; cin >> n >> x >> d;
	if (d == 0) {
		if (x == 0) cout << 1 << endl;
		else cout << n + 1 << endl;
		return 0;
	}
	if (d < 0) {
		x = -x;
		d = -d;
	}
	unordered_map<ll, vector<pair<ll, ll>>> r;
	r[0].emplace_back(0, d);
	ll left = 0, right = 0;
	for (int i = 0; i < n; i++) {
		left += i;
		right += n - i - 1;
		r[(i + 1)*x % d].emplace_back((i + 1)*x + d*left, (i + 1)*x + d*(right + 1));
	}
	for (auto &p : r) {
		auto &v = p.second;
		sort(v.begin(), v.end(), [&](auto &a, auto &b) {
			return a.second < b.second;
		});
	}
	for (auto &p : r) {
		auto &v = p.second;
		for (int j = (int)v.size() - 2; j >= 0; j--) {
			if (v[j].second > v[j + 1].first) {
				v[j].second = v[j + 1].first;
				if (v[j].first > v[j].second) {
					v[j].first = v[j].second;
				}
			}
		}
	}
	ll ans = 0;
	for (auto &p : r) {
		auto &v = p.second;
		for (int j = 0; j < (int)v.size(); j++) {
			if (v[j].first >= v[j].second) continue;
			ans += (v[j].second - v[j].first) / d;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 17864
import java.io.*;
import java.util.*;

public class Main {
	static final Reader in = new Reader();
	static final PrintWriter out = new PrintWriter(System.out);
	
	public static void main(String[] args) {
		int n=in.nextInt();
		Pair[] d = new Pair[n];
		int[] s1 = new int[n], p = new int[n];
		long[] s2 = new long[n];
		Map<Long, Integer> mp = new HashMap<Long, Integer>();
		for(int i=0; i<n; ++i) {
			d[i] = new Pair(in.nextLong(), i);
			mp.put(d[i].a, i);
			s1[i]=1;
		}
		Arrays.sort(d);
		for(int i=0; i<n-1; ++i) {
			int u=d[i].b;
			p[u]=mp.getOrDefault(d[i].a-n+2*s1[u], -1);
			if(d[i].a-n+2*s1[u]>=d[i].a||p[u]==-1)
				fk();
			s1[p[u]]+=s1[u];
			s2[p[u]]+=s2[u]+s1[u];
		}
		if(s2[d[n-1].b]!=d[n-1].a)
			fk();
		for(int i=0; i<n-1; ++i)
			out.println((d[i].b+1)+" "+(p[d[i].b]+1));
		out.close();
	}
	
	static void fk() {
		System.out.println(-1);
		System.exit(0);
	}
	
	static class Pair implements Comparable<Pair> {
		long a;
		int b;
		Pair(long a, int b) {
			this.a=a;
			this.b=b;
		}
		public int compareTo(Pair o) {
			return -Long.compare(a, o.a);
		}
	}
	
	static class Reader {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		
		String next() {
			while(st==null||!st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 55192
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int cnt[maxn], fl[maxn]; 
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cnt[i] = 1;
	fl[1] = 1;
	for (int i = 0; i < m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		cnt[y]++, cnt[x]--;
		if (fl[x]) fl[y] = 1;
		if (!cnt[x]) fl[x] = 0;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans += fl[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <functional>

using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; const int INF=1e9; const ll LINF=1e18;

int main(){
  ll q,h,s,d; cin>>q>>h>>s>>d;
  s = min(q*4, min(h*2, s));
  ll n; cin>>n;
  if (n%2==0) {
    cout<<min(n*s,n*d/2)<<endl;
  } else {
    cout<<min(n*s,(n/2)*d+s)<<endl;
  }
}

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

int main(){
  int N,Y;
  int counter=0;
  cin>>N>>Y;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      if(Y==10000*i+5000*j+1000*(N-i-j)){
        cout<<i <<' '<<j <<' '<<N-i-j<<endl;
        counter++;
        break;
      }
    }if(counter)break;
  }
  if(counter==0)cout<<-1<<' '<<-1<<' '<<-1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int h, w;
  char s[110][110]={};
  cin >> h >> w;
  for(int i=1; i<h+1; i++){
    for(int j=1; j<w+1; j++){
      cin >> s[i][j];
    }
  }

  for(int i=0; i<h+2; i++){
    for(int j=0; j<w+2; j++){
      if(s[i][j]==0)cout << "#";
      else cout << s[i][j];
    }
    cout << endl;
  }

}


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

using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back

using namespace std;

int main(){

    int a,b;
    cin>>a>>b;
    int c=a+b;

    if(a%3==0||b%3==0||c%3==0){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,f[3][105];
int main()
{
    scanf("%d",&n);
    for (int i=1; i<=2; i++)
        for (int j=1; j<=n; j++)
            scanf("%d",&f[i][j]),
                  f[i][j]+=max(f[i-1][j],f[i][j-1]);
    printf("%d",f[2][n]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

int calcTime(int h1, int m1, int h2, int m2){
    int t1, t2;
    t1 = h1*60 + m1;
    t2 = h2*60 + m2;
    return t2 - t1;
}

signed main(){
    int M, t;
    cin >> M >> t;
    vector<pair<string, int> > d;
    int h, m, hp, mp;
    string name;
    rep(i, 0, 2 * M){
        scanf("%d:%d ",&h, &m);
        cin >> name;
        if(i % 2){
            //name = s;
            hp = h;
            mp = m;
        }else if(i % 2 == 0 && i != 0){
            int tmp = calcTime(hp, mp, h, m);
            //cout << tmp << " " << name << endl;
            if(tmp >= t){
                d.push_back(make_pair(name, tmp));
            }
        }
    }
    cout << d.size() <<endl;
    rep(i, 0, d.size()){
        cout << d[i].first <<" "<< d[i].second << endl;
    }
}

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

int main() {
    int x, y;
    cin >> x >> y;
    if(2*x <= y && y <= 4*x && y%2 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

template <class T>
struct SegmentTree{
  using F = function<T(T,T)>;
  F f;
  T inf;
  int n;
  vector<T> node;

  SegmentTree(vector<T> v,T inf,F f):inf(inf),f(f){
    n = 1; while(n < v.size()) n *= 2;
    node.resize(2*n-1,inf);
    for(int i = 0; i < v.size(); i++) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; i--) node[i] = f(node[2*i+1],node[2*i+2]);
  }

  void update(int k,T val){
    k += n-1;
    node[k] = val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  void add(int k,T val){
    k += n-1;
    node[k] += val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  T getval(int a,int b){ return getval(a,b,0,0,n); }
  T getval(int a,int b,int k,int l,int r){
    //区間[a, b)の値を返す
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return node[k];
    T vl = getval(a, b, 2*k+1, l, (l+r)/2);
    T vr = getval(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }
};

signed main(){

  int n; cin >> n;
  vector<int> p(n),order(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
    p[i]--;
    order[p[i]] = i;
  }

  SegmentTree<int> seg(vector<int>(n,0),0,[&](int x,int y){
    return (x + y);
  });
  auto getid = [&](int num){
    int left = -2,right = n;
    while(right - left > 1){
      int mid = (left + right) / 2;

      if(seg.getval(0,mid+1) >= num) right = mid;
      else left = mid;
    }
    return right;
  };

  int ans = 0;
  for(int i = n-1; i >= 0; i--){
    seg.add(order[i],1);
    int num = seg.getval(0,order[i]+1);
    int ll = getid(num-2);
    int l = getid(num-1);
    int r = getid(num+1);
    int rr = getid(num+2);
    int res = (order[i] - l) * (rr - r) + (r - order[i]) * (l - ll);
    ans = (ans + res * (i+1));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int MAX = 1e5+10, MAXL = 20;
ll n, q, k, dis[MAX];
vector<int> g[MAX];
map<pair<int, int> , ll> edge;

void bfs (int v) {
	queue<int> qu;
	qu.push(v);
	dis[v] = 0;
	while (!qu.empty()) {
		int u = qu.front();
		qu.pop();
		for (int i : g[u])
			if (dis[i] == -1) {
				dis[i] = dis[u] + edge[{u,i}];
				qu.push(i);
			}
	}
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n-1; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		g[a].pb(b); g[b].pb(a);
		edge[{a, b}] = edge[{b, a}] = c;
	}
	fill (dis, dis + n, -1);
	cin >> q >> k;
	k--;
	bfs (k);
	//cout << dis[2] << ' ' << dis[3] << endl;
	while (q--) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		cout << dis[a] + dis[b] << endl;
	}
	return 0;
}

Measured memory_bytes: 20736
//Dile a la jardinera que traigo flores
#include <bits/stdc++.h>

#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define trace(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = int(a); i < int(b); i++)
#define iFR(i,a) for(int i = int(a-1); i >= int(0); i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

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

const int N=1e5+5;
vector<ii>gfo[N];int d[N];

inline void build(int n){
	FOR(i,1,n)FOR(j,0,10)
		gfo[i].pb(mp((10*i+j)%n,j));
}

inline int dijkstra(int n){
	priority_queue<ii,vector<ii>,greater<ii> >pq;
	FOR(i,0,N)d[i]=INT_MAX;
	FOR(i,1,10)if(d[i]>i){
		d[i]=i;pq.push(mp(i,i%n));
	}
	while(!pq.empty()){
		ii ini=pq.top();pq.pop();
		int dist=ini.fst;
		int u=ini.snd;
		if(dist>d[u])continue;
		for(ii v:gfo[u])if(d[u]+v.snd<d[v.fst]){
			d[v.fst]=d[u]+v.snd;
			pq.push(mp(d[v.fst],v.fst));
		}
	}
	return d[0];
}

int main(){
	int n;scanf("%d",&n);
	build(n);
	int res=dijkstra(n);
	cout<<res<<endl;
	return 0;
}

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

int main() {
  ll x;
  cin >> x;
  ll ans = x/11*2;
  if(x%11>0) ++ans;
  if(x%11>6) ++ans;
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<math.h>
#include <iterator>
#include<algorithm>
#include<fstream>
#include<map>
#include<string>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
const int maxn = 2e5 + 5;
#define ll long long
int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if (k >= a) { k -= a; ans += a; }
    else { cout << k << endl; return 0; }
    if (k >= b) { k -= b; }
    else { cout << ans << endl; return 0; }
    ans -= k;
    cout << ans;
    
}

Measured memory_bytes: 3544
def inpl():
    return list(map(int, input().split()))


def backtrack(towns, x=0, y=0, v=0, ans=0, flag=True):
    # print(towns)
    if not towns:
        ans += v
        return ans
    t = 0
    for i in range(len(towns)):
        nx, ny = XY[towns[i]]
        if flag:
            tmp = ((nx - x)**2 + (ny - y)**2)**0.5
        else:
            tmp = 0
        t += backtrack(towns[:i]+towns[i+1:], nx, ny, v+tmp, ans)
    return t + ans


N = int(input())
XY = [inpl() for i in range(N)]

ans = backtrack([i for i in range(N)], flag=False)

f = 1
for i in range(1, N + 1):
    f *= i
print(ans / f)


Measured memory_bytes: 3188
#include <stdio.h>
int main(){
    int n, a, min = 1000000, max = -1000000;
    long long sum = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {   
        scanf("%d", &a);
        if (min > a){
            min = a;
        }
        if (max < a){
            max = a;
        }
        if (1){
            sum = sum + a;
        }
    }
    printf("%d %d %lli\n", min, max, sum);
    return 0;   
}


Measured memory_bytes: 2108
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<array>
using namespace std;

int main(){

    string s;
    cin >> s;

    int count0 = 0,count1 = 0;

    string s1 = s;
    s[0] = '0';
    if(s[0] == s1[0])++count1;
    else ++count0;
    s1[0] = '1';

    for(int i = 1; i < s.length(); ++i){

        if(s[i] == s[i-1]){

            if(s[i] == '1')s[i] = '0';
            else s[i] = '1';
            ++count0;

        }
    }
    for(int i = 1; i < s.length(); ++i){

        if(s1[i] == s1[i-1]){

            if(s1[i] == '1')s1[i] = '0';
            else s1[i] = '1';
            ++count1;

        }
    }
    cout << min(count0,count1) << endl;

    return 0;
}

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

int main(){
   int n, k;
   cin >> n >> k;
   string s;
   cin >> s;

   if(s[k-1] == 'A') s[k-1] = 'a';
   if(s[k-1] == 'B') s[k-1] = 'b';
   if(s[k-1] == 'C') s[k-1] = 'c';

   cout << s << endl;

   return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 19;
int n, q, d;
int a[N];
bool ans[N];
int enter[N];
int min_cant[N];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	cin >> n >> d;
	FOR(i, 0, n) cin >> a[i];
	
	enter[0] = d;
	FOR(i, 1, n + 1)
	{
		enter[i] = enter[i - 1];
		if (abs(enter[i] - a[i - 1]) < enter[i])
			enter[i] = abs(enter[i] - a[i - 1]);
	}
	
	if (enter[n] != 0)
		FOR(i, 0, n) ans[i] = true;
	else
	{
		min_cant[n] = 0;
		RFOR(i, n, 0)
		{
			min_cant[i] = min_cant[i + 1];
			
			if (a[i] / 2 <= min_cant[i])
				min_cant[i] += a[i];
		}
		
		FOR(i, 0, n) 
			ans[i] = enter[i] > min_cant[i + 1];
	}
	
	cin >> q;
	while(q--)
	{
		int x;
		cin >> x;
		cout << (ans[x - 1] ? "YES\n" : "NO\n");
	}
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 8448
input1 = input()

a = input1[0] + input1[1]
b = input1[2] + input1[3]


if a == "01" or a == "02" or a == "03" or a == "04" or a == "05" or a == "06" or a == "07" or a == "08" or a == "09" or a == "10" or a == "11" or a == "12":
    a = "M?"
else:
    a = "?"

if b == "01" or b == "02" or b == "03" or b == "04" or b == "05" or b == "06" or b == "07" or b == "08" or b == "09" or b == "10" or b == "11" or b == "12":
    b = "M?"
else:
    b="?"

if a == "M?" and b == "M?":
    print("AMBIGUOUS")


if a == "M?" and b == "?":
    print("MMYY")

if a == "?" and b == "M?":
    print("YYMM")

if a == "?" and b == "?":
    print("NA")

Measured memory_bytes: 3064
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<int> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    int a, b, c;
    VE v;
    cin >> a >> b >> c;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end());
    print(v[2] * 10 + v[1] + v[0]);
}

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

int main() {
	string s; cin >> s;
	int N = s.length();
	int M = pow(2, N - 1);
	long long sum = 0;
	long long a = 0;
	for (int i = 0; i < M; i++) {
		long long z = i;
		long long a = s[0] - '0';
		for (int j = 1; j < N; j++) {
			if (z % 2 == 0) {
				a = a * 10 + s[j] - '0';
			}
			else {
				sum += a;
				a = s[j] - '0';
			}
			z /= 2;
		}
		sum += a;
		a = 0;
	}
	cout << sum;
}

Measured memory_bytes: 256
Q=[]
A=->*x{Q<<[?+,*x]*" "}
C=->*x{Q<<[?<,*x]*" "}

C[3,0,3]
0.upto(30){|i|
 A[3+i,3+i,4+i]
}

def to_b(x,s)
 A[x,3,x]
 31.downto(0){|i|
  A[3+i,s+33,s+32]
  C[s+32,x,s+i]
  A[s+i,2,s+32]
  i.times{A[s+32,s+32,s+32]}
  A[s+32,s+33,s+33]
 }
end

to_b(0,67)
to_b(1,195)

30.times{|i|
 30.times{|j|
  A[67+i,195+j,324]
  C[3,324,325]
  A[326+i+j,325,326+i+j]
 }
}

60.times{|i|
 i.times{A[326+i,326+i,326+i]}
 A[2,326+i,2]
}

puts Q.size,Q

Measured memory_bytes: 14960
// AtCoder キーエンス プログラミング コンテスト 2020
// B - Robot Arms
// 2020.1.20 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

#define MAX 100005
typedef struct { int x, l; } T;
T a[MAX]; int N;

void Qsort(T *a, int l, int r) {
	int i, j, m; T t;
	
	i = l, j = r, m = a[(l+r) >> 1].x;
	while (1) {
		while (a[i].x < m) i++;
		while (m < a[j].x) j--;
		if (i >= j)	break;
		t = a[i], a[i] = a[j], a[j] = t;
		i++, j--;
	}
	if (l+1 < i) Qsort(a, l, i-1);
	if (j+1 < r) Qsort(a, j+1, r);
}
	
int main()
{
	int i, k, ans;
	
	N = in();
	for (i = 0; i < N; ++i) a[i].x = in(), a[i].l = in();
	Qsort(a, 0, N-1);
	
	k = 0, ans = 1;
	for (i = 1; i < N; ++i) {
		if (a[k].x+a[k].l <= a[i].x-a[i].l) ++ans, k = i;
		else if (a[k].x+a[k].l > a[i].x+a[i].l) k = i;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws Exception{
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader (is);
		String input = br.readLine();
		if(((input.indexOf("N")!=-1) == (input.indexOf("S")!=-1)) && ((input.indexOf("W")!=-1) == (input.indexOf("E")!=-1))) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
long long x,k,d,n,ans;
int main()
{
	cin>>x>>k>>d;
	if(x==0)
	{
		if(k%2==0) cout<<0;
		else cout<<d;
		return 0;
	}
	x=abs(x);n=x/d;
	if(n>=k)
	{
		cout<<x-k*d;
		return 0;
	}
	if((k-n)%2==0) ans=x-n*d;
	else ans=n*d+d-x;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int main (void) {
    int N;
    int K;

    cin >> N >> K;
    int cnt[N + 1] = {0};
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        cnt[A]++;
    }

    sort(cnt, cnt + N, greater<int>());
    int ans = N;
    for (int i = 0; i < K; i++) {
        ans -= cnt[i];
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
#define vi vector<int>
#define mii map<int,int>

int main() {
	ll n, sum=0;
	cin >> n;
	for(ll i=1;i<=n;i++) {
		if(i%3 != 0 && i%5 != 0) {
			sum += i;
		}
	}
	
	cout << sum << "\n";
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
typedef complex<double> Point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll cnt = 0;
    rep(i,s.length()){
        cnt += s[i]-'0';
    }
    Yes(cnt%9 == 0);
}



Measured memory_bytes: 3720
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s;

	cin >> s;

	if (s.length() < 4) {
		cout << "No" << endl;

	} else if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;		
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define pr pair<int, int>
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int N = 122222;
ll n, same, pos1, pos2;
ll a[N], vis[N], fac[N];

ll mut(ll a, ll b){
	ll y = 1, t = a;
	for (; b; b >>= 1, t = t * t % MOD)
		if (b & 1) y = y * t % MOD;
	return y;
}
ll C(ll n, ll m){
	if (n < m) return 0;
	return fac[n] * mut(fac[m], MOD - 2) % MOD * mut(fac[n-m], MOD - 2) % MOD;
}

int main(){
	read(n);
	rep(i, 1, n + 1) read(a[i]), vis[a[i]]++;
	rep(i, 1, n) if (vis[i] >= 2){same = i; break;}
	rep(i, 1, n + 1) if (a[i] == same) if (!pos1) pos1 = i; else pos2 = i;
	fac[0] = 1; rep(i, 1, n + 1) fac[i] = fac[i-1] * i % MOD;
	printf("%lld\n", n);
	rep(k, 2, n + 1){
		ll ret = (C(n - 1, k) + C(n - 1, k - 2) + C(n - 1, k - 1) * 2) % MOD;
		ret = (ret - C(n - pos2 + pos1, k - 1)) % MOD;
		printf("%lld\n", (ret + MOD) % MOD);
	}
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

int main(){
	
	ll n;
	while(cin>>n){
		ll ans = 0;
		FOR(i,0,10)FOR(j,0,10)FOR(k,0,10)FOR(l,0,10){
			if(i+j+k+l==n)ans++;
		}
		cout << ans << endl;
	}
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}


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

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

const int MAXN = 2e5 + 5;

int N;
pii a[MAXN], b[MAXN];
int memo[MAXN];
int idx[MAXN];
ll suff[MAXN];
pil f[MAXN];

void operator +=(pil &lhs, const pil &rhs) {
	lhs.first += rhs.first;
	lhs.second += rhs.second;
}

void update(int x, pil val) {
	for (; x < MAXN; x += x & -x)
		f[x] += val;
}

pil get(int x) {
	pil res = {0, 0};
	for (; x; x -= x & -x)
		res += f[x];
	return res;
}

void solve(double &opt, ll &p, ll &q, ll rest, int A, int B) {
	ll val = rest + B - A;
	if (val < 0)
		return;
	int lo = 0, hi = N;
	while (lo < hi) {
		int mid = (lo + hi + 1) / 2;
		if (get(mid).second <= val)
			lo = mid;
		else
			hi = mid - 1;
	}
	pil tmp = get(lo);
	ll cp = 0, cq = 0;
	if (B) {
		cp = (ll)B * tmp.first + min(val - tmp.second, (ll)B);
		cq = B;
	}
	else {
		cp = tmp.first;
		cq = 1;
	}
	double copt = (double)cp / cq;
	if (copt > opt) {
		opt = copt;
		p = cp;
		q = cq;
	}
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d%d", &a[i].first, &b[i].first);
		a[i].second = b[i].second = i;
		memo[i] = a[i].first;
	}
	
	sort(a, a + N);
	sort(b, b + N);
	
	for (int i = 0; i < N; i++)
		idx[a[i].second] = i + 1;
	
	for (int i = N - 1; i >= 0; i--)
		suff[i] = suff[i + 1] + max(b[i].first - memo[b[i].second], 0);
	
	double ans = 0;
	ll num = 0, denom = 1;
	for (int i = 0; i < N; i++) {
		int which = b[i].second;
		solve(ans, num, denom, suff[i + 1], memo[which], b[i].first);
		update(idx[which], {1, memo[which]});
		solve(ans, num, denom, suff[i + 1], 0, 0);
	}
	
	denom *= N;
	ll g = __gcd(num, denom);
	printf("%lld %lld\n", num / g, denom / g);
	
	return 0;
}

Measured memory_bytes: 8448
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_A&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        H, W = map(int, input().split())
        if H == 0 and W == 0:
            break

        for y in range(H):
            print('#' * W)
        print()


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7696
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};

    static int n, m;
    static HashMap<Integer, List<Integer>> G;

    public static void main(String[] args) {
        input();
        solve();
    }

    static void solve() {
        if(n + m == 15) {
            print('+');
        }else if(n * m == 15) {
            print('*');
        }else{
            print('x');
        }
    }

    static void input() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(char c) {
        System.out.println(c);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }

    static void print(float i) {
        System.out.println(i);
    }

    static void printArray2D(int[][] array, char del) {
        int r = array.length;
        int c = array[0].length;
        for(int i = 0; i < r; i++) {
            for(int j = 0; j < c; j++) {
                System.out.format("%3d", array[i][j]);
                if(j != c-1) System.out.print(del);
                else System.out.print('\n');
            }
        }
    }
}

class P {
    int x, y;
    P(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

class E {
    int from, to;
    long w;
    E(int from, int to, long w) {
        this.from = from;
        this.to = to;
        this.w = w;
    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
     ll n,a[100005],k,ans=0;
     cin>>n>>k;
     for(int i=0;i<n;i++)
       cin>>a[i];
     sort(a,a+n);
     for(int i=0;i<k;i++)
       ans+=a[i];
     cout<<ans<<"\n";
     return 0;
}

Measured memory_bytes: 3560
n=int(input())
C1=0
C2=0
C3=0
C4=0
for i in range(n):
    k=str(input())
    if k=="AC":
        C1 +=1
    elif k=="WA":
        C2 += 1
    elif k=="TLE":
        C3 += 1
    else:
        C4 += 1
        
    #l.append(str(input()))



print("AC x " + str(C1))
print("WA x " + str(C2))
print("TLE x " + str(C3))
print("RE x " + str(C4))

Measured memory_bytes: 9168
n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
dic={}
dic['AC']=0
dic['WA']=0
dic['TLE']=0
dic['RE']=0
key=['AC','WA','TLE','RE']

for i in range(n):
    s=input()
    dic[s]=dic[s]+1

for k in key:
    print("{0} x {1}".format(k,dic[k]))

Measured memory_bytes: 9048