akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int N; cin >> N;
    vector<pair<int,int> > p(N);
    vector<int> n(N);
    for(int i=0;i<N;i++){
        cin >> p[i].first >> p[i].second;
        n[i] = i;
    }
    double average=0.0;
    ll cnt = 0;
    do{
        cnt++;
        double dist=0.0;

        for(int i=1;i<N;i++){
            int x1 = p[n[i-1]].first;
            int y1 = p[n[i-1]].second;
            int x2 = p[n[i]].first;
            int y2 = p[n[i]].second;
            dist += sqrt(1.0*(x1-x2)*(x1-x2)+1.0*(y1-y2)*(y1-y2));
        }
        average += dist;
    }while(next_permutation(n.begin(),n.end()));
    cerr << cnt << endl;
    printf("%.8lf\n",average/cnt);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
#include<functional>
using namespace std;
typedef pair<double, int> P;
priority_queue<P, vector<P>, greater<P>> Q;
#define MAX_N 1005
int x[MAX_N], y[MAX_N]; double dist[MAX_N];
vector<int>path[MAX_N]; vector<P>X[MAX_N];
void dijkstra(int a, int b) {
	memset(dist, 1e+9, sizeof(dist));
	for (int i = 0; i < MAX_N; i++) { path[i].clear(); dist[i] = 1e+9; }
	Q.push(make_pair(0.0, a)); dist[a] = 0; path[a].push_back(a);
	while (!Q.empty()) {
		pair<double, int>pa = Q.top(); Q.pop();
		double a1 = pa.first; int a2 = pa.second;
		for (int i = 0; i < X[a2].size(); i++) {
			int to = X[a2][i].second; double dis = X[a2][i].first;
			if (dist[to] > a1 + dis) {
				dist[to] = a1 + dis; path[to].clear();
				path[to] = path[a2]; path[to].push_back(to);
				Q.push(make_pair(dist[to], to));
			}
		}
	}
	if (path[b].size() == 0) { cout << "NA" << endl; }
	else {
		for (int i = 0; i < path[b].size(); i++) { if (i) { cout << ' '; } cout << path[b][i]; }
		cout << endl;
	}
}
int main() {
	int N, Q, s, g, a, b, c;
	while (true) {
		for (int i = 0; i < MAX_N; i++) { X[i].clear(); }
		cin >> N; if (N == 0) { break; }
		for (int i = 0; i < N; i++) { cin >> a >> b >> c; x[a] = b; y[a] = c; }
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				double dist2 = sqrtl((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
				if (dist2 <= 50.0) {
					X[i].push_back(make_pair(dist2, j));
				}
			}
		}
		cin >> Q;
		for (int i = 0; i < Q; i++) { 
			cin >> s >> g; dijkstra(s, g); 
		}
	}
	return 0;
}

Measured memory_bytes: 3212
T1,T2 = map(int,input().split())
A1,A2 = map(int,input().split())
B1,B2 = map(int,input().split())

dis1 = (A1 - B1) * T1
dis2 = (A2 - B2) * T2

if dis1 > 0:
    dis1 = -dis1
    dis2 = -dis2

"""
if dis1 + dis2 <0:
    print(0)

elif dis1 == -dis2:
    print("infinity")
"""

if dis1 + dis2 == 0:
    print("infinity")

elif dis1+dis2 < 0:
    print(0)

else:
    S = dis1//(dis1+dis2)
    R = dis1%(dis1+dis2) 
    if R == 0:
        ans = S*2 
    else:
        ans = S*2 + 1
    
    print(abs(ans))

Measured memory_bytes: 3064
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n,m;
int s[1111],t[1111];


int main(){
    cin>>n>>m;
    rep(i,m){
        cin>>s[i]>>t[i];
        s[i]--;
    }

    for(int i=0;;i++){
        string tmp=to_string(i);
        //cout<<tmp<<endl;
        if(tmp.size()>n)
            break;
        if(tmp.size()<n)
            continue;

        int cnt=0;
        rep(j,m){
            if(tmp[s[j]]-'0'==t[j])
                cnt++;
        }
        if(cnt==m){
            cout<<tmp<<endl;
            return 0;
        }
        // cout<<tmp[0]<<" "<<cnt<<endl;
    }

    cout<<-1<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+10;
int n;
int is_sheep[MAXN];
string s;

void print() {
    for(int i=0;i<n;i++) {
        if(is_sheep[i]) cout << "S";
        else cout << "W";
    }
    cout << endl;
}

int get_next(int next_to, int sheep, int response) {
    if( (sheep && response == 'o') || (!sheep && response == 'x') ){
        return next_to;
    } else {
        return 1-next_to;
    }

}

bool guess(int first, int second) {
    is_sheep[0] = first;
    is_sheep[1] = second;

    for(int i=1;i<n-1;i++) {
        is_sheep[i+1] = get_next(is_sheep[i-1], is_sheep[i], s[i]);
    }

    if(is_sheep[0] == get_next(is_sheep[n-2], is_sheep[n-1], s[n-1]) && is_sheep[1] == get_next(is_sheep[n-1], is_sheep[0], s[0] )) return true;
    else return false;
}


int main() {
    cin >> n;
    cin >> s;
    int fir[] = {1, 0, 1, 0};
    int sec[] = {0, 1, 1, 0};

    bool done = false;
    for(int i=0;i<4;i++) {
        if(guess(fir[i], sec[i])) {
            done = true;
            print();
            break;
        }
    }

    if(!done) cout << "-1\n";
    
}

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


int main() {
    int n;

    cin >> n;
    for (int x = 1; x <= n; x++) {
        int s;
        cin >> s;

        cout << "Case " << x << ":" << endl;
        for (int i = 0; i < 10; i++) {
            s = (s * s / 100) % 10000;
            cout << s << endl;
        }
    }
    return 0;
}

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

int main() {
    int64_t K;
    std::cin >> K;

    int64_t sum = 0;
    for (int i = 1; i <= K; ++i) {
        for (int j = 1; j <= K; ++j) {
            for (int k = 1; k <= K; ++k) {
                sum += std::gcd(std::gcd(i, j), k);
            }
        }
    }

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 3620
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cctype>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <cstdio>
#include <iomanip>
#include <numeric>
#include <list>
#include <bitset>
#include <ctime>
#include <deque>
#include <functional>
int a[200005],n,l,r,mid;

inline bool check(const int &k)
{
    if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))
        return 1;
    if((k<a[n-1]&&k<a[n])||(k<a[n]&&k<a[n+1]))
        return 0;
    for (int i=1;i<n-1;i++)
    {
        if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))
            return 1;
        if((k<a[n+i]&&k<a[n+i+1])||(k<a[n-i]&&k<a[n-i-1]))
            return 0;
    }
    return (a[1]<=k&&a[1]<=k);
}

int main()
{
    scanf("%d",&n);
    for (int i=1;i<n<<1;i++) scanf("%d",a+i);
    for (r=(n<<1)-1,mid=l+r>>1;l<r;mid=l+r>>1) if (check(mid)) r=mid;else l=mid+1;
    printf("%d",l);
}


Measured memory_bytes: 1024
#include<iostream>
#include<variant>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<climits>
#include<set>

using namespace std;

int main(void) {
	long long int dat[4],max=LLONG_MIN;
	cin >> dat[0] >> dat[1] >> dat[2] >> dat[3];
	for (int i = 0; i<2; i++) {
		for (int k = 2; k < 4; k++) {
			if (i == k)continue;
			if (max < dat[i] * dat[k])max = dat[i] * dat[k];
		}
	}
	cout << max;
	return 0;
}

Measured memory_bytes: 3668
from collections import deque

K=int(input())
# BFS
M=1
L=9
tmp=deque([1,2,3,4,5,6,7,8,9])
k=1
while L<K:
    k=str(tmp.popleft())
    if int(k[-1])-1>=0:
        tmp.append(int(k+str(int(k[-1])-1)))
        L+=1
    tmp.append(int(k+k[-1]))
    L+=1
    if int(k[-1])+1<10:
        tmp.append(int(k+str(int(k[-1])+1)))
        L+=1
    M+=1

print(tmp[K-M])

Measured memory_bytes: 5872
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(), v.end()
using namespace std;

int k;
string s;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> k >> s;

    if( s.size()<=k ){
        cout << s; return 0;
    }

    cout << s.substr( 0 , k ) + "...";

    return 0;
}


Measured memory_bytes: 3644
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')

a, b, c, k = map(int, input().split())

if k <= a:
    print(k)
elif k <= a + b:
    print(a)
else:
    rest = k - (a + b)
    print(a - rest)


Measured memory_bytes: 68456
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
using namespace std;

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


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

	int sum_w[n+1], sum_e[n+1];
	fill(sum_w, sum_w+n+1, 0);
	fill(sum_e, sum_e+n+1, 0);
	for (int i = 1; i <= n; i++) {
		sum_w[i] = sum_w[i-1];
		if (s[i-1]=='W') sum_w[i]++;
		sum_e[i] = sum_e[i-1];
		if (s[n-i]=='E') sum_e[i]++;
	}
	int res = n;
	rep(i, n) {
		res = min(res, sum_w[i] + sum_e[n-i-1]);
	}
	cout << res << endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int N,L,i;
   string x;
   vector<string>z;
   cin>>N>>L;
   for(i=0;i<N;i++)
   {
       cin>>x;
       z.push_back(x);
   }
   sort(z.begin(),z.end());
   for(i=0;i<N;i++)
   {
       cout<<z[i];
   }

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll Q=1000000007;
const double PI=3.14159265358979323846;

int main(){
  ll X;
  cin >> X;
  for(ll i=1;i<=1000;i++){
    if(100*i<=X && X<=105*i){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
const ll inf=1e9;
int main(void){
    ll h,n;
    cin>>h>>n;
    vector<pair<ll,ll>>a(n);
    rep(0,i,n){
        cin>>a[i].first>>a[i].second;
    }
    ll dp[h+1];
    rep(0,i,h+1)dp[i]=inf;
    dp[0]=0;
    rep(0,i,h){
        rep(0,j,n){
            ll x=min(a[j].first+i,h),y=a[j].second;
            dp[x]=min(dp[x],dp[i]+y);
            //cout<<"dp["<<x<<"]="<<dp[x]<<endl;
        }
    }
    cout<<dp[h]<<endl;
}


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

int main(){
	ios_base::sync_with_stdio(false);	cin.tie(NULL);
	int n;	cin >> n;	map<int, int> a;
	for (int i = 0; i < n; i++) {
		int x;	cin >> x;	a[x]++;
	}
	int res = n;
	for (auto &p : a) {
		res -= p.second - 1;
	}
	res -= 1 - res % 2;	cout << res;
}



Measured memory_bytes: 4992
// C - Together
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vi C(100000+1);
	int a,b,c;
	rp(i, 0, N){
		cin>>a;
		C[a]++;
	}
	a = C[0]; b = C[1]; c = C[2];
	int ans = a + b + c;
	rp(i, 3, C.size())
		if(C[i] != 0){
			a = b; b = c; c = C[i];
			ans = max(ans, a+b+c);
		}
	cout<< ans <<endl;
}

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

#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string str;
    cin >> str;
    if (str == "SUN") cout << "7\n";
    if (str == "MON") cout << "6\n";
    if (str == "TUE") cout << "5\n";
    if (str == "WED") cout << "4\n";
    if (str == "THU") cout << "3\n";
    if (str == "FRI") cout << "2\n";
    if (str == "SAT") cout << "1\n";
}
/*

 */

Measured memory_bytes: 3628
//Name: ALDS1_1_D: Maximum Profit
//Level: 2
//Category:
//Note:

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int R, n;
    int min_R, ans = -1e9;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> R;

        if (i == 0)
            min_R = R;
        else {
            ans = max(ans, R-min_R);
            min_R = min(min_R, R);
        }
    }

    cout << ans << endl;

    return 0;
}

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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define FORR(el,vecc) for(auto& el:vecc)
#define ll long long int
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).begin(),(c).end(),greater<int>()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.6lf\n",a);
#define SIZE

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define N (int)(1e5+10)


using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;

long long fast_exp(long long n,long long k){
    ll t = n;

    while (k >1){
        k--;
      n=(n*t)%998244353;
  }
    return n;
}
/*ios_base::sync_with_stdio(false);cin.tie(0);*/
int main(){
    ll n;
    cin >>n;
    vl vec ( n);
    map <ll , ll >mm;
    for (int i = 0; i <n ; ++i) {
        cin>>vec[i];
        mm[vec[i]]++;
    }
    if ( vec[0] != 0){
        cout << 0;
        return 0;
    }
    sort(BEND2(vec));
    if(mm[0] != 1){
        cout << 0;
        return 0;
    }
    ll res =1;
    for (int j = 1; j <= vec[0] ; ++j) {
        res = (res*((fast_exp(mm[j-1],mm[j]))%998244353)%998244353)%998244353;
        res = res %998244353;
    }
    cout << res;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (auto &v : vec)
    cin >> v;

  int vsum = 0;
  for (auto &v : vec)
    vsum ^= v;

  for (auto &v : vec)
    cout << (vsum ^ v) << endl;
}

Measured memory_bytes: 4048
import java.util.*;

public class Main {

	public static void main(String[] args) {
	
		int[] d;
		d= new int [10];
		int a=0,b=0,c=0;
		
		Scanner sc=new Scanner(System.in);
		for(int i=0;i<10;i++){
			d[i]=sc.nextInt();
			if(d[i]>a){
				c=b;
				b=a;
				a=d[i];
			}
			else if(d[i]>b){
				c=b;
				b=d[i];
			}
			else if(d[i]>c){
				c=d[i];
			}
			
		}
		System.out.println(a+"\n"+b+"\n"+c);
	}

}

Measured memory_bytes: 12000
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, D = map(int, input().split())

    D = D * D
    count = 0
    for i in range(N):
        x, y = map(int, input().split())
        if D - x * x - y * y >= 0:
            count += 1

    print(count)


if __name__ == "__main__":
    main()


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  Graph(int n):E(n){E.resize(n);V=n;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  string s;cin>>s;
  int k;cin>>k;
  string ans="";
  for(int i=0;i<s.size();i++){
    if(i!=s.size()-1){
      if(26-(s[i]-'a')<=k){
	ans+='a';
	if(s[i]!='a')
	k-=26-(s[i]-'a');
      }else ans+=s[i];
    }else{
      ans+=(char)('a'+(((s[i]-'a'))+(k))%26);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <list>
#include <numeric>
#include <math.h>
#include <cstdlib>
#include <queue>
#include <iterator>
#include <limits>
#include <string>
#include <sstream>
#include <iomanip>
#include <bitset>
#include <mutex>
#include <condition_variable>
#include <atomic>
#include <stack>
#include <memory>
#include <deque>
#include <string_view>
#include <random>
#include <chrono>
#include <cstring>

using namespace std;

static int my_speed_up = []() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }();
using ll = long long; using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T> using vv = vector<vector<T>>;
template<class T> using vvv = vector<vector<vector<T>>>;
template<class T> using vvvv = vector<vector<vector<vector<T>>>>;
#define for_b(i, b) for (int i = 0; i < (b); ++i)
#define for_ab(i, a, b) for (int i = a; i < (b); ++i)
#define what_is(x) cout << #x << " = " << x << endl;
#define what_are(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl;
#define pad(x) for_b(i, x) cout << "  ";
#define show_1d(___x) cout << #___x << " = "; for (auto& ___num : ___x) cout << ___num << ", "; cout << endl;
#define show_2d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto ___num : ___row) cout << ___num << ", "; cout << endl; }
#define show_3d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto& ___row2 : ___row) { for (auto ___num : ___row2) cout << ___num << ", "; cout << endl; }cout << endl; }

vv<int> d4 = {{1,0},{-1,0},{0,1},{0,-1}};
vv<int> d8 = {{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
bool is_valid_pos(const vv<int>& tb, int x, int y) {
    return x >= 0 && x < tb.size() && y >= 0 && y < tb[0].size();
}


int main()
{
    const ll mod = 1000000007;
    int N;
    cin >> N;
    v<ll> tb(N);
    for_b(i,N)
        cin >> tb[i];
    
    ll sum = accumulate(tb.begin(), tb.end(), (ll)0);
    
    ll res = 0;
    for_b(i,tb.size() - 1)
    {
        sum -= tb[i];
        int mod_sum = sum % mod;
        ll cur = tb[i] * mod_sum;
        cur %= mod;
        res += cur;
        res %= mod;
    }
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 4776
#include<stdio.h>

int prime[1000000];

void ertsthns(int n){
  int i;
  for(i=2;i<=n;i++){
    if(prime[i]==1){
      int j;
      for(j=2*i;j<=n;j+=i){
	prime[j]=0;
      }
    }
  }
}

void doit(int n){
  int i;
  int cnt=0;
  ertsthns(n);
  for(i=0;i<=n;i++){
    if(prime[i]==1){
      cnt++;
    }
  }
  printf("%d\n",cnt);
}

int main(){
  int n;
  while(scanf("%d",&n)!=EOF){
    int i;
    for(i=0;i<=n;i++){
      if(i<2){
	prime[i]=0;
      }
      else{
	prime[i]=1;
      }
    }
    doit(n);
  }
  return 0;
}

Measured memory_bytes: 4500
n,m,q=map(int,input().split())
a=[[0 for j in range(n+1)] for i in range(n+1)]
for i in range(m):
    l,r=map(int,input().split())
    a[l][r]+=1
for i in range(n):
    for j in range(n):
        a[i+1][j+1]+=a[i][j+1]+a[i+1][j]-a[i][j]
for i in range(q):
    l,r=map(int,input().split())
    print(a[r][r]-a[r][l-1]-a[l-1][r]+a[l-1][l-1])

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

public class Main {
	private static void solve(){
		//Implement solution here.
		long a = nl();
		long b = nl();
		long c = nl();
		long d = nl();
		long lcm = lcm(c,d);

		long result = b - a + 1; 
		result -= countDiv(a, b, c);
		result -= countDiv(a, b, d);
		result += countDiv(a, b, lcm);
		System.out.println(result);		
	}

	static long countDiv(long a, long b, long t) {		
		long result = 0;
		if(a > 0) {
			result = b / t - (a - 1) / t; 
		} else {
			result = b / t;
		}
		return result;
	}

	//Find greatest common divisor
	static long gcd (long a, long b) {
		return b > 0 ? gcd(b, a%b) : a;
	}
	//Find least common multiple
	static long lcm (long a, long b) {
		return a * b / gcd(a, b);
	}    

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

using namespace std;

#define ll long long

int bin_pow(int a, int pow) {
    if (pow == 0) return 1;
    if (pow == 1) return a;
    if (pow % 2 == 0) {
        int tmp = bin_pow(a, pow / 2);
        return tmp * tmp;
    }
    return a * bin_pow(a, pow - 1);
}

int fact(int x) {
    int ans = 1;

    for (int i = 1; i <= x; i++) ans *= i;
    return ans;
}

int count(vector<int> a) {
    int ans = 0;
    unordered_set<int> was;
    for (int i = 0; i < a.size(); i++) {
        int count = a[i] - 1;
        for (int j = 1; j < a[i]; j++) {
            count -= was.count(j);
        }
        ans += count * fact(a.size() - i - 1);
        was.insert(a[i]);
    }

    return ans;
}

ll m = 1000000007;

bool isPrime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

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

    set<int> s;
    s.insert(1);
    s.insert(2);
    s.insert(3);
    
    int a, b;
    cin >> a >> b;
    s.erase(a);
    s.erase(b);
    
    for (int ss : s) cout << ss;
    
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
from collections import defaultdict,Counter
def saiki(cnts):
  hitomozi = []
  d = defaultdict(lambda: [])
  heads = defaultdict(lambda: 0)
  for s,c in cnts:
    if len(s)==1:
      hitomozi.append(s[0])
    else:
      for k,v in c.items():
        if v>0:
          heads[k] += 1
      t = s[-1]
      c[t] -= 1
      s.pop(-1)
      d[t].append([s,c])
  for h in hitomozi:
    ans[0] += heads[h]
  for v in d.values():
    if len(v)<=1:
      continue
    saiki(v)
  return 

N = int(input())
S = [list(input()) for _ in range(N)]
ans = [0]
cnts = []
for s in S:
  cnts.append([s,Counter(s)])
saiki(cnts)
print(ans[0])


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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  int num[n];
  REP(i,n) {
    cin >> num[i];
  }
  int ans = 1;
  int min = num[0];
  REPS(i,1,n) {
    if(num[i] <= min) {
      ++ans;
      min = num[i];
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

int main() {
    int n, p;
    cin >> n >> p;
    long long dp[2] = {1, 0};
    for (int a; cin >> a; ) {
        if (a % 2 == 0) {
            dp[0] *= 2;
            dp[1] *= 2;
        } else {
            tie(dp[0], dp[1]) = make_tuple(dp[0] + dp[1], dp[1] + dp[0]);
        }
    }
    cout << dp[p];
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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

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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        s: chars,
    }
    let mut mi = 1 << 28;
    let mut cur = 0;
    for i in 0..n {
        if s[i] == '#' {
            cur += 1;
        }
    }
    for i in (0..n + 1).rev() {
        if i < n {
            if s[i] == '.' {
                cur += 1;
            } else {
                cur -= 1;
            }
        }
        mi = min(mi, cur);
    }
    puts!("{}\n", mi);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;
//#define B
#define D

#ifdef A
int main(void)
{
	int a, b;
	cin >> a >> b;
	cout << a / b << " " << a %b << " ";
	printf("%f\n", static_cast<double>(a) / b);
	return 0;
}


#endif // A

#ifdef B
#define PI 3.141592653589f
int main(void)
{
	double r;
	cin >> r;
	printf("%.6f %.6f\n",r * 2 * PI, PI * r * r);
	return 0;
}
#endif // B


#ifdef C
#define _MAX 2000

void add(std::pair<int, int> &a) { cout << a.first + a.second << endl; }
void sub(std::pair<int, int> &a) { cout << a.first - a.second << endl; }
void mul(std::pair<int, int> &a) { cout << a.first * a.second << endl; }
void les(std::pair<int, int> &a) { cout << a.first / a.second << endl; }

int main(void)
{
	char op;
	pair<int, int> dis;
	vector<pair<int, int> > arr_num(_MAX);
	vector<char> arr_c(_MAX);

	op = 0;
	//arr_c[0] =0 ;


	for (size_t i = 0; i < _MAX && op != '?'; i++)
	{
		cin >> dis.first >> op >> dis.second;

		arr_num[i] = dis;
		arr_c[i] = op;
	}

	for (size_t i = 0; i < _MAX && arr_c[i] != '?'; ++i)
	{
		switch (arr_c[i])
		{
		case '+':
			add(arr_num[i]);
			break;

		case '-':
			sub(arr_num[i]);
			break;
		case '/':
			les(arr_num[i]);
			break;
		case '*':
			mul(arr_num[i]);
			break;
		}

	}



	return 0;
}
#endif // C

#ifdef D
#define INT_MIN     (-2147483647 - 1) // minimum (signed) int value
#define INT_MAX       2147483647    // maximum (signed) int value

int main(void)
{
	int n;
	int num;
	int max= INT_MIN, min= INT_MAX;
	long long sum = 0;
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		cin >> num;
		if (num > max) max = num;
		if (num < min) min = num;
		sum += num;
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}

#endif // D

Measured memory_bytes: 3100
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main()
{
	int a, b;
	for(int i=0; scanf("%d%d", &a, &b), a||b; ++i){
		bool output = false;
		if(i)
			puts("");

		reep(j, a, b+1){
			if(j%4==0 && (j%100!=0 || j%400==0)){
				printf("%d\n", j);
				output = true;
			}
		}

		if(!output)
			puts("NA");
	}

	return 0;
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
for ele in a:
  d[ele] += 1
ans = 0
for k, v in d.items():
  if k!=v:
    t = float("INF")
    if v>k:
      t = v-k
    ans += min(t, v)
print(ans)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

using namespace std;
using ll = long long;
typedef pair<int, int> Pair;

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

vector<vector<ll>> f(ll n) {
  vector<vector<ll>> res;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i != 0) continue;
    ll cnt = 0;
    while (n % i == 0) cnt++, n /= i;
    res.push_back({i, cnt});
  }
  if (n > 1) res.push_back({n, 1});
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;

  ll g = gcd(a, b);
  auto s = f(g);

  cout << s.size() + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
typedef long long ll;

int main()
{
	ll A,B,N;
	scanf("%lld %lld %lld", &A,&B,&N);
	ll i = N;
	ll x;
	ll n;
	ll sum;
	if (N >= B - 1)
		x = B - 1;
	else if (N < B)
		x = N;
	sum = (A*x/B) - A * (x/B);
	printf("%lld\n", sum);
	return (0);
}


Measured memory_bytes: 2144
#include <stdio.h>

int main(void){

	int a,b,d,r;
	double f;

	scanf("%d %d",&a,&b);

	d = a/b;
	r = a%b;
	f = 1.0*a/b;

	printf("%d %d %.5lf",d,r,f);

	return 0;

}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;cin >> N;

    int M = sz(to_string(N));

    int L = to_string(N)[0];
    int R = to_string(N)[sz(to_string(N))-1];


    ll ans = 0;

    REP(i,N){ //A
        string t = to_string(i);
        char l = t[0];
        char r = t[sz(t)-1];

        if(!(r-'0') || !(l-'0'))continue;

        for(int k = 2;k < M;k++)
        {
            ans += ll(pow(10,k-2));
        }
        if(M >= 3){
            if((r-'0') <= L){
                int tmp = (r-'0') * (ll)(pow(10,M-1)) + (l-'0');
                ll tmpt = 0;
                while(tmp <= N){
                    tmp += 10;
                    tmpt++;
                }

                ans += min(tmpt,(ll)(pow(10,M-2)));
            }
        }else if(M == 2){
            int tmp = (r-'0') * (ll)(pow(10,M-1)) + (l-'0');
            //cout << tmp <<' ';
            if(tmp <= N)ans++;
        }

        
        if(l == r)ans++;
        //if(i < 100)cout << ans << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
"""dd = [(-1, 0), (0, 1), (1, 0), (0, -1)];
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)];
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  # SingleInt
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  # HeightString
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  # NumberGrid
def grid(n): return [s_list() for _ in range(n)]


def main():
    n = int(input())
    s = input()
    count = 0
    for i in range(1000):
        key = str(i + 1000)[1:]
        if key[0] in s:
            s2 = s[s.index(key[0]) + 1:]

            if key[1] in s2:
                s3 = s2[s2.index(key[1])+1:]

                if key[2] in s3:
                    count += 1

                else:
                    continue
    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14352
class UnionFind:
    def __init__(self,n):
        super().__init__()
        self.par = [-1]*n
        self.rank = [0]*n
        self.tsize = [1]*n
    
    def root(self,x):
        if self.par[x] == -1:
            return x 
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x_r = self.root(x)
        y_r = self.root(y)
        
        if self.rank[x_r]>self.rank[y_r]:
            self.par[y_r] = x_r

        elif self.rank[x_r]<self.rank[y_r]:
            self.par[x_r] = y_r

        elif x_r != y_r:
            self.par[y_r] = x_r
            self.rank[x_r] += 1

        if x_r != y_r:
            size = self.tsize[x_r]+self.tsize[y_r]
            self.tsize[x_r] = size
            self.tsize[y_r] = size

    def isSame(self,x,y):
        return self.root(x) == self.root(y)

    def size(self,x):
        return self.tsize[self.root(x)]

def main():
    n,m = tuple([int(t)for t in input().split()])

    uf = UnionFind(n)

    for _ in range(m):
        a_i,b_i = tuple([int(t)-1 for t in input().split()])
        uf.unite(a_i,b_i)

    candidates = []

    for i in range(n):
        candidates.append(uf.size(i))

    print(max(candidates))
if __name__ == "__main__":
    main()

Measured memory_bytes: 25252
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;


int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	int same = 0;
	for(int i=1; i<s.size(); i++){
		if(s[i] == s[i-1]){
			same++;
			if(same >= 2){
				break;
			}
		}
		else{
			same = 0;
		}
	}

	if(same >= 2){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

typedef long long LL;

const int maxn=2e5+5;

int n,m,p[maxn];

int ga[maxn];
int get(int x) {return (ga[x]==x) ?x :ga[x]=get(ga[x]) ;}

unordered_map<int,bool> mp[maxn];

int main()
{
    scanf("%d %d",&n,&m);
    fo(i,1,n) scanf("%d",&p[i]), ga[i]=i;
    fo(i,1,m)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        ga[get(x)]=get(y);
    }

    fo(i,1,n) mp[get(i)][p[i]]=1;
    int ans=0;
    fo(i,1,n) ans+=mp[get(i)][i];
    //fo(i,1,n) printf("%d\n",mp[get(i)][i]);

    printf("%d\n",ans);
}

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

int main(void)
{
	char s[1001];
	char *curr;
	const char *target="Hoshino", *trs="Hoshina";
	int i, n;
	scanf("%d%*c", &n);
	for(i=0; i<n; i++)
	{
		gets(s);
		curr = s;
		while(*curr != '\0')
		{
			if(*curr == *target)
			{
				if(strncmp(curr, target, strlen(target))==0)
					strncpy(curr, trs, strlen(target));
			}
			curr++;
		}
		puts(s);
	}
	return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define rep(i,n) for (i = 0; i < (n); i++)
#define MAX_N 200000 // 2*(10^5)
#define MAX_Si 11 // 1 <= i <= 10

int compare_char(const void *a, const void *b) {
  return (strcmp((const char *)a, (const char *)b));
}

int main(void) {
  int N;
  char S[MAX_N][MAX_Si]; // S[i] (1 <= i <= N)

  int i;
  int j;
  int max_count;
  int count[MAX_N];

  scanf("%d", &N);
  rep(i,N) {
    scanf("%s", S[i]);
    count[i] = 1;
  }

  qsort(S, N, sizeof(S[0]), compare_char);

  j = 0; // for count
  max_count = 1;
  rep(i,N-1) {
    if (strcmp(S[i], S[i+1]) == 0) {
      count[j] += 1;
      if (max_count < count[j]) {
        max_count = count[j];
      }
    }
    else {
      j = i + 1; // next
    }
  }

  rep(i,N) {
    if (count[i] == max_count) {
      printf("%s\n", S[i]);
    }
  }

  return (0);
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    double sumbit=0;
    double sumyen=0;

    for(int i=0; i<N; i++){
        double x;
        string u;
        cin >> x >> u;

        if(u == "JPY"){
            sumyen += x;
        }else{
            sumbit += x;
        }
    }

    sumyen += sumbit*380000;

    cout << sumyen << endl;
    return 0;
}

Measured memory_bytes: 3736
#include <stdio.h>
#include <math.h>

int main(void) 
{
    int A,B,C,D,sum,a,b;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&D);

    a = fmin(A,B);
    b = fmin(C,D);

    sum = a + b;

    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,sum=0;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
       if(i%15!=0&&i%5!=0&&i%3!=0)
       {
           sum+=i;
       }
      
   }
   cout<<sum;
}

Measured memory_bytes: 3636
n = list(map(int,input().rstrip()))
for i in range(2**3):
  ope = ["-"] * 3
  ans = n[0]
  for j in range(3):
    if (i >> j) & 1:
      ope[j] = "+"
      ans += n[j+1]
    else:
      ans -= n[j+1]
  if ans == 7:
    res = [ope[i]+str(n[1+i]) for i in range(3)]
    res = "".join(res)
    res = str(n[0]) + res + "=7"
    print(res)
    break

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

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

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		int l,r,d;
		cin>>l>>r>>d;
		int temp = d;
		int ans = 0;
		while(temp <= r) {
			if(temp >=l and temp <= r) {
				ans++;
			}
			temp += d;
		}
		cout<<ans<<"\n";
 	}
 	return 0;
}


Measured memory_bytes: 3608
//FizzBuzz列 a1,a2,... を次のように定めます。
//i が 3 でも 5 でも割り切れるなら、ai=FizzBuzz
//そうではなく i が 3 で割り切れるなら、ai=Fizz
//そうではなく i が 5 で割り切れるなら、ai=Buzz
//そうではないなら、ai=i
//FizzBuzz列の N 項目までに含まれる数の和を求めてください。
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  ll N; cin >> N;
  ll sum = 0;
  for(ll i = 1; i <= N; ++i){
    if(!(((i % 3 == 0) && (i % 5 == 0)) || (i % 3 == 0) || (i % 5 == 0))){
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3576
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long l = (long) - 2e9;
		long r = (long) 2e9;
		while(r - l > 1){
			
			long c = (l + r) / 2;
			if(f(c) > f(c + 1)){
				l = c;
			} else {
				r = c;
			}
		}
		
		Console.WriteLine(f(r));
		
	}
	
	long f(long b){
		long ret = 0;
		for(int i=0;i<N;i++){
			ret += Math.Abs(A[i] - (b + i + 1));
		}
	
		return ret;
	}
	
	
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 30684
#include <bits/stdc++.h>
#include <string>
#define INF 100000
using namespace std;
int H, W,N;
int sx, sy;
typedef long long ll;

int main(){
    cin >> N;
    vector<ll> yama;
    vector<ll> ans(N);
    for(int i=0;i<N;i++){
        ll tmp;
        cin  >> tmp;
        yama.push_back(tmp);
    }
    ll as=0;
    for(int i=0;i<N;i++){
        if(i%2==0){
            as += yama[i];
        }else{
            as += yama[i]*(-1);
        }
    }
    ans[0] = as;
    for(int i=1;i<N;i++){
        ans[i] = 2*yama[i-1]-ans[i-1];
    }
    for(int i=0;i<N;i++){
        cout << ans[i] << " " ;
    }
    cout << endl;
}

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

int main(void)
{
  string s;
  cin >> s;

  int pos = 0;
  int result[15];

  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] == '0')
    {
      result[pos] = 0;
      pos++;
    }
    else if (s[i] == '1')
    {
      result[pos] = 1;
      pos++;
    }
    else if (s[i] == 'B')
    {
      pos--;
      if (pos < 0)
        pos = 0;
    }
  }

  for (int i = 0; i < pos; i++)
  {
    cout << result[i];
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
#include<sstream>
#include<chrono>
#include<algorithm>
#include<functional>
#include<cstdlib>
#include<numeric>
#include<queue>
#include<stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
constexpr double PI = 3.14159265358979323846;
int memo_fib[std::numeric_limits<short>::max() - 1];

int main()
{
	int a, b = 0;
	cin >> a >> b;
	if (a <= b)std::cout << "unsafe" << std::endl;
	else std::cout << "safe" << std::endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=r-1;i>=(int)(l);--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int a[100010];

signed main()
{
	int N; cin >> N;
	rep(i, N) a[read() - 1] = i + 1;

	rep(i, N) printf("%lld%c", a[i], i==N-1?'\n':' ');
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int n;
 cin >> n;
 int* L = new int[n];
 int count = 0;
 for (int i = 0; i < n;i++){
   cin >> L[i];
 }
 sort(L,L+n);
 for(int i = 0;i < n;i++){
   for(int j = i+1;j < n;j++){ 
     for(int k = j+1;k < n;k++){
       if(L[i]+L[j]>L[k]&& L[i]!=L[j]&& L[i]!=L[k]&& L[k]!=L[j]) count++;        
     }
   }
 }
 cout << count;
  
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <ctype.h>
#include <cstdio>
using namespace std;
static const int max_n = 50;
int n, k;
char s[max_n+1];
void solve() {
s[k-1] = s[k-1] + 0x20;
cout << s << endl;
}

int main() {
	cin >> n >> k >> s;
	solve();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
typedef long long ll;

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

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

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

  int count=0;
  for(int i=0; i<N-2; i++)
    {
      if(p[i]<p[i+1] && p[i+1]<p[i+2])
	count++;
      if(p[i+2]<p[i+1] && p[i+1]<p[i])
	count++;
      
    }

  cout << count << endl;


  return 0;
}


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



Measured memory_bytes: 256