akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = 1 << 30;
// static const ll INF = 1LL << 62;
// --------------------------------------------------------


VB is_prime_numbers(int N) {
    double root_n = sqrt(N) + 0.5;
    VB is_prime(N + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for(int i = 4; i <= N; i += 2) is_prime[i] = false;
    for(int f = 3; f <= root_n; f += 2) {
        for(int i = 2 * f; i <= N; i += f) is_prime[i] = false;
    }
    return is_prime;
}


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

    int Q; cin >> Q;

    static const int MAX_N = 1e+5;
    VB is_like_2017(MAX_N + 1, false);
    auto is_prime = is_prime_numbers(MAX_N);
    for (int i = 1; i <= MAX_N; i += 2) {
        if (is_prime[i] && is_prime[(i + 1) / 2]) {
            is_like_2017[i] = true;
        }
    }

    VI S(MAX_N + 1, 0);
    FOR(i, 1, MAX_N + 1) S[i] = S[i - 1] + is_like_2017[i];

    REP(_, Q) {
        int l, r; cin >> l >> r;
        cout << S[r] - S[l - 1] << '\n';
    }

    return 0;
}


Measured memory_bytes: 3696
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
  ll n, ma, mb;
  cin >> n >> ma >> mb;
  vl a(n), b(n), c(n);
  rep(i, n) { cin >> a[i] >> b[i] >> c[i]; }
  vvvl data(n + 1, vvl(401, vl(401, INF)));
  data[0][0][0] = 0;
  rep(i, n) {
    rep(ca, 401) {
      rep(cb, 401) {
        if (data[i][ca][cb] < INF) {
          data[i + 1][ca][cb] = min(data[i + 1][ca][cb], data[i][ca][cb]);
          data[i + 1][ca + a[i]][cb + b[i]] =
              min(data[i + 1][ca + a[i]][cb + b[i]], data[i][ca][cb] + c[i]);
        }
      }
    }
  }
  ll ans = INF;
  rep(ca, 401) {
    rep(cb, 401) {
      if (ca > 0 && cb > 0 && ma * cb == mb * ca) {
        ans = min(ans, data[n][ca][cb]);
      }
    }
  }
  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 53504
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()

ans = INF
for a1, a2, a3 in zip(S, S[1:], S[2:]):
    num = int(a1 + a2 + a3)
    tmp = abs(num - 753)
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 9028
#include <cstdio>

const int MaxN = 200005;

int n, arr[MaxN];

bool check(int x) {
	auto get = [x](int pos) { return arr[pos] > x; };
	int l = 0;
	while (l + 1 < n && get(n - l - 1) != get(n - l)) ++l;
	int r = 0;
	while (r + 1 < n && get(n + r + 1) != get(n + r)) ++r;
	return l < r ? get(n - l) : get(n + r);
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < 2 * n; ++i) scanf("%d", arr + i);
	int l = 1, r = 2 * n - 1;
	while (l < r) {
		int mid = (l + r) >> 1;
		if (check(mid)) {
			l = mid + 1;
		} else {
			r = mid;
		}
	}
	printf("%d\n", l);
	return 0;
}

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

int gcd(int x, int y) {
	int tmp;
	while (y > 0) {
		tmp = y;
		y = x % y;
		x = tmp;
	}
	return x;
}

int main() {
	int x, y;
	cin >> x >> y;
	cout << gcd(x, y) << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    string s;
    cin>>s;
    Vec c(26);
    ll n = s.length();
    rep(i,n){
        c[s[i]-'a']++;
    }
    bool ok = true;
    rep(i,26){
        if(c[i]%2==1)ok=false;
    }
    Yes(ok);
    return  0;
}


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

using namespace std;

const int N = 1e5 + 7;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;


int solver() {
    string s; cin >> s;
    int sum = 0;
    for (int i = 0; i < s.size(); ++i) {
        sum += s[i] - '0';
    }
    cout << (((sum % 9) == 0) ? "Yes" : "No") << endl;
    return 0;
}

int main() {
    int tests = 1;
    // cin >> tests;
    for (int i = 1; i <= tests; ++i) {
        solver();
    }
    return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <cstdio>
#include <list>
#include <vector>
using namespace std;
const int num = 10000;
vector<int> ne[num];
int n, c[num];
list<int> ans;
inline void dfs(int a) {
	c[a] = 1;
	for (int i = 0; i < ne[a].size(); i++)
		if (c[ne[a][i]] == 0) dfs(ne[a][i]);
	ans.push_front(a);
}
inline void tp() {
	for (int i = 0; i < n; i++) 
		if (c[i] == 0) dfs(i);
}
int main() {
	int p, s, t;
	cin >> n >> p;
	for (int i = 0; i < p; i++) {
		scanf("%d%d", &s, &t);
		ne[s].push_back(t);
	}
	for (int i = 0; i < n; i++) c[i] = 0;
	tp();
	for (int i = 0; i < n; i++) {
		list<int>::iterator it  = ans.begin();
		printf("%d\n", *it);
		ans.pop_front();
	}
	return 0;
}

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

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

	int N, K;
	cin >> N >> K;

	vector<int> X1(N);
	vector<int> Y1(N);
	vector<int> D1(N);
	vector<int> X2(N);
	vector<int> Y2(N);
	vector<int> D2(N);

	for (int i = 0; i < N; i++){
		cin >> X1[i] >> Y1[i] >> D1[i] >> X2[i] >> Y2[i] >> D2[i];
	}
	
	//ソート用vector
	vector<int> X(2*N);
	vector<int> Y(2*N);
	vector<int> D(2*N);
	for (int i = 0; i < N; i++){
		X[2 * i]     = X1[i];
		X[2 * i + 1] = X2[i];
		Y[2 * i]     = Y1[i];
		Y[2 * i + 1] = Y2[i];
		D[2 * i]     = D1[i];
		D[2 * i + 1] = D2[i];
	}
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	sort(D.begin(), D.end());

	long long int ans = 0;
	int kasanari;
	for (int i = 0; i < 2*N-1; i++){ //X
		for (int j = 0; j < 2*N-1; j++){ //Y
			for (int k = 0; k < 2*N-1; k++){ //D
				kasanari = 0;
				for (int l = 0; l < N; l++){ //実際の直方体
					if ((X1[l]<=X[i] && X[i+1] <= X2[l]) &&
						(Y1[l]<=Y[j] && Y[j+1] <= Y2[l]) &&
						(D1[l]<=D[k] && D[k+1] <= D2[l]))
						kasanari++;
				}
				if (kasanari >= K){
					ans += (long long int)(X[i + 1] - X[i]) * (Y[j + 1] - Y[j]) * (D[k + 1] - D[k]);
				}
			}
		}
	}

	cout << ans << "\n";

	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

bool is_check[100000];
int card[100000];

struct UnionFind {
  vector<LL> data;
  UnionFind(LL size) : data(size, -1) { }
  bool unionSet(LL x, LL y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(LL x, LL y) {
    return root(x) == root(y);
  }
  LL root(LL x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  LL size(LL x) {
    return -data[root(x)];
  }
};

void solve(long long N, long long M, std::vector<long long> X, std::vector<long long> Y, std::vector<long long> Z){
    if(N == 2) {
        cout << 1 << endl;
        return;
    }

    REP(i, N) {
        is_check[i] = false;
        card[i] = 0;
    }

    UnionFind uf(N);
    REP(i, M) {
        X[i]--;
        Y[i]--;

        uf.unionSet(X[i], Y[i]);
    }



    int cost = 0;
    REP(i, N) {
        if(uf.root(i) == i) cost++;
    }
    cout << cost << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> X(M);
    std::vector<long long> Y(M);
    std::vector<long long> Z(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
        scanf("%lld",&Z[i]);
    }
    solve(N, M, std::move(X), std::move(Y), std::move(Z));
    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  int b = 0;
  int ans = 1;
  if (N < K) {
    cout << ans << endl;
  }
  else{
    while(b<=N){
    b = pow(K,ans+1);
    ans++;
  }
  cout << ans << endl;
}
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = sc.nextInt();
        long[] ryuka = new long[87];
        ryuka[0] = 2;
        ryuka[1] = 1;

        for (int i = 2; i <= n; i++) {
            ryuka[i] = ryuka[i-1] + ryuka[i-2];
        }
        
        System.out.println(ryuka[n]);
    }
}


Measured memory_bytes: 23764
N, K = map(int, input().split())
a = list(map(int, input().split()))

one_pos = 0
for i, num in enumerate(a):
    if num == 1:
        one_pos = i
        break
count = (i - 1) // (K - 1) + 1
if count * (K - 1) >= len(a):
    pass
else:
    if count * (K - 1) + 1 > i + 1:
        count += (len(a) - (count * (K - 1) + 1) - 1) // (K - 1) + 1
    else:
        count += (len(a) - (i + 1) - 1) // (K - 1) + 1
print(count)

Measured memory_bytes: 13880
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (n); i++)

int main() {
	string S;
	cin >> S;

	if (S.length() == 2) {
		if(S[0]==S[1]) cout << 1 <<" "<< 2 << endl;
		else cout << -1 <<" "<< -1 << endl;
		return 0;
	}

	for (int i = 0; i < S.length()-2; i++) {
		if (S[i] == S[i + 1]) {
			cout << i+1 <<" "<< i+3 << endl;
			return 0;
		}
		if (S[i] == S[i + 2]) {
			cout << i+1 <<" "<< i+3 << endl;
			return 0;
		}
	}

	for (int i = S.length() - 1; i >= 2; i--) {
		if (S[i] == S[i - 1]) {
			cout << i-1 <<" "<< i+1 << endl;
			return 0;
		}
		if (S[i] == S[i - 2]) {
			cout << i-2 <<" "<< i+1 << endl;
			return 0;
		}
	}

	cout << -1 <<" "<< -1 << endl;
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int K;
    cin >> K;
    vector<vector<P>> graph(K);
    for(int i = 1; i < K; ++i){
        int u = (i + 1) % K;
        int v = i * 10 % K;
        graph[i].emplace_back(u, 1);
        graph[i].emplace_back(v, 0);
    }
    vector<int> dist(K, INF);
    dist[1] = 1;
    deque<int> deq;
    deq.push_back(1);
    while(!deq.empty()){
        int from = deq.front();
        deq.pop_front();
        for(auto& e : graph[from]){
            int to = e.first, cost = e.second;
            if(!cost){
                if(chmin(dist[to], dist[from])) deq.push_front(to);
            }
            else{
                if(chmin(dist[to], dist[from] + 1)) deq.push_back(to);
            }
        }
    }
    cout << dist[0] << endl;
}

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

int main(){
    int n,m,sum=0,x,y;
    cin >> n >> m;
    vector<int> reex(n,0);
    reex.at(0)=1;
    vector<int> nb(n,1);

    for(int i=0;i<m;i++){
        cin >> x >> y;
        nb.at(x-1)--;
        if(reex.at(x-1)==1){
            if(nb.at(x-1)==0){
                reex.at(x-1)=0;
                reex.at(y-1)=1;
                nb.at(y-1)++;
            }else{
                reex.at(y-1)=1;
                nb.at(y-1)++;
            }
        }else{
            nb.at(y-1)++;
        }
    }

    for(int i=0;i<n;i++){
        sum+=reex.at(i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<chrono>
 
using namespace std;
using namespace std::chrono;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
ll mod=1000000007;
const int MX=0x3f3f3f;

int main(){
	IOS;
    int h,w,i,j;
    cin>>h>>w;
    char s;
    vector<vector<int>> ch(h+2,vector<int> (w+2,0));
    REP(i,1,h){
        REP(j,1,w) {
            cin>>s;
            if(s=='.') ch[i][j]=1; 
    }
    }
    int ans=0;
    REP(i,1,h){
        REP(j,1,w){
            if(ch[i][j]){
           //     cout<<i<<" "<<j<<endl;
                vector<vector<int>> vis(h+2,vector<int>(w+2,0));
                queue<vector<int>> q;
                int temp=0;
                vis[i][j]=1; 
                q.push({i,j,0});
                while(!q.empty()){
                    vector<int> v=q.front();
                    q.pop();
                    temp=max(temp,v[2]);
                    if(ch[v[0]-1][v[1]]&&!vis[v[0]-1][v[1]]){
                        vis[v[0]-1][v[1]]=1;
                        q.push({v[0]-1,v[1],v[2]+1});
                    }
                    if(ch[v[0]+1][v[1]]&&!vis[v[0]+1][v[1]]){
                        vis[v[0]+1][v[1]]=1;
                        q.push({v[0]+1,v[1],v[2]+1});
                    }
                    if(ch[v[0]][v[1]-1]&&!vis[v[0]][v[1]-1]){
                        vis[v[0]][v[1]-1]=1;
                        q.push({v[0],v[1]-1,v[2]+1});
                    }
                    if(ch[v[0]][v[1]+1]&&!vis[v[0]][v[1]+1]){
                        vis[v[0]][v[1]+1]=1;
                        q.push({v[0],v[1]+1,v[2]+1});
                    }
                }
                ans=max(ans,temp);
               // cout<<ans<<endl;
            }
        }
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>

int main() {
    
    long long a, b = 0;
    std::cin >> a >> b;
    
    long long d = a / b;
    long long r = a % b;
    long double f = (double) a / (double) b;
    
    
    std::cout << d << " " << r << " " << std::fixed << std::setprecision(5) << f << std::endl;
    
    return 0;

}


Measured memory_bytes: 3244
def game():
    n = int(input())
    listofwords =[]
    for i in range(n):
        strTEMP = input()

        if i == 0:
            listofwords.append(strTEMP)
            continue
        else:
            if strTEMP in listofwords:
                return "No"
            else:
                cmp = listofwords[-1]
                if strTEMP[0] != cmp[-1]:
                    return "No"
                else:
                    listofwords.append(strTEMP)
    return "Yes"

print(game())

Measured memory_bytes: 3060
#pragma GCC target ("avx2")
//#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
ll vis[100005]={0};
void dfs(vll adj[],ll v)
{
    vis[v]=1;
    for(auto i:adj[v])
    {
        if(vis[i]==0)
        {
            vis[i]=1;
            dfs(adj,i);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,ans=0;
    cin>>n>>m;
    vll adj[n+1];
    for(ll i=1;i<=m;i++)
    {
        ll x,y;
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    for(ll i=1;i<=n;i++)
    {
        if(vis[i]==0)
        {
            ans++;
            dfs(adj,i);
        }
    }
    cout<<ans-1;
    return 0;
}


Measured memory_bytes: 11404
def dfs(i, sum, n, s)
  return (sum == s) ? 1 : 0 if n == 0
  return 0 if i > 9

  ans = 0
  ans += dfs(i + 1, sum + i, n - 1, s)
  ans += dfs(i + 1, sum, n, s)
  ans
end

while true
  n, s = gets.split(' ').map(&:to_i)
  break if n == 0 && s == 0
  puts dfs(0, 0, n, s)
end

Measured memory_bytes: 6092
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
class SegmentTree(object):
    def __init__(self,A,dot,e):
        n=2**((len(A)-1).bit_length())
        self.__n=n
        self.__dot=dot
        self.__e=e
        self.__node=[e]*(2*n)
        for i in range(len(A)):
            self.__node[i+n]=A[i]
        for i in range(n-1,-0,-1):
            self.__node[i]=dot(self.__node[2*i],self.__node[2*i+1])

    def add(self,i,c):
        i+=self.__n
        node=self.__node
        node[i]=self.__dot(node[i],c)
        while(i!=1):
            i//=2
            node[i]=self.__dot(node[2*i],node[2*i+1])

    def sum(self,l,r):
        vl,vr=self.__e,self.__e
        l+=self.__n; r+=self.__n
        while(l<r):
            if(l%2==1):
                vl=self.__dot(vl,self.__node[l])
                l+=1
            l//=2
            if(r%2==1):
                r-=1
                vr=self.__dot(self.__node[r],vr)
            r//=2
        return self.__dot(vl,vr)

def resolve():
    n,m,Q=map(int,input().split())
    X=[0]*(m+Q)
    for i in range(m):
        l,r=map(int,input().split())
        l-=1; r-=1
        X[i]=(0,l,r,i)
    for i in range(Q):
        l,r=map(int,input().split())
        l-=1; r-=1
        X[m+i]=(1,l,r,i)
    X.sort(lambda x:(x[2],x[0])) # 右端の昇順、先に一点追加してからクエリに答える

    from operator import add
    tree=SegmentTree([0]*n,add,0)
    ans=[0]*Q
    for x,l,r,i in X:
        if(x==0):
            tree.add(l,1)
        else:
            ans[i]=tree.sum(l,r+1)

    for a in ans: print(a)
resolve()

Measured memory_bytes: 111044
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  
  cout<<min(N*A,B)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,y;
  cin>>n>>x>>y;
  --x;--y;
  map<int,int> m;
  for(int i=0;i<n-1;++i)for(int j=i+1;j<n;++j){
    ++m[min({
      j-i,
      abs(x-i)+1+abs(j-y),
      abs(y-i)+1+abs(j-x)
    })];
  }
  for(int i=1;i<n;++i)cout<<m[i]<<"\n";
}

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

struct Dice {
    int a, b, c, d, e, f;
    Dice(int a, int b, int c, int d, int e, int f) {
        setFaces(a, b, c, d, e, f);
    }
    void setFaces(int a, int b, int c, int d, int e, int f) {
        this->a = a;
        this->b = b;
        this->c = c;
        this->d = d;
        this->e = e;
        this->f = f;
    }
    void rollSingle(char dir) {
        switch (dir) {
            case 'N':
                setFaces(b, f, c, d, a, e);
                break;                
            case 'E':
                setFaces(d, b, a, f, e, c);
                break;                
            case 'S':
                setFaces(e, a, c, d, f, b);
                break;                
            case 'W':
                setFaces(c, b, f, a, e, d);
                break;
        }
    }
    void roll(string s) {
        for (int i=0; i<s.size(); i++)
            rollSingle(s[i]);
    }
};

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    string s;
    cin >> s;
        
    Dice dice(a, b, c, d, e, f);    
    dice.roll(s);
    cout << dice.a << endl;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=35,INF=1<<30;
vector<pair<int,double>> G[MAX];
double dis[MAX][MAX][MAX];
int lim[MAX][MAX];

struct data{
    double dis;
    int now;
    int from;
    int v;
};

auto compare = [](data &A,data &B){
    return A.dis>B.dis;
};//Dijkstraで使うなら大きいもの

void dijkstra(int u){
    dis[u][32][1]=0;
    priority_queue<data,vector<data>,decltype(compare)> PQ(compare);
    
    PQ.push({0.0,u,32,1});
    while(!PQ.empty()){
        data x=PQ.top();PQ.pop();
        if(dis[x.now][x.from][x.v]<x.dis) continue;
        if(x.v==0) continue;
        
        for(pair<int,double> to:G[x.now]){
            for(int cha=-1;cha<=1;cha++){
                if(x.v+cha<0||x.v+cha>lim[x.now][to.first]+1||x.v>lim[x.now][to.first]) continue;
                if(to.first==x.from) continue;
                
                if(dis[to.first][x.now][x.v+cha]>dis[x.now][x.from][x.v]+to.second/x.v){
                    dis[to.first][x.now][x.v+cha]=dis[x.now][x.from][x.v]+to.second/x.v;
                    PQ.push({dis[to.first][x.now][x.v+cha],to.first,x.now,x.v+cha});
                }
            }
        }
    }
    return;
}//a,dが長さ


int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M;cin>>N>>M;
        if(N+M==0) break;
        
        for(int i=0;i<N;i++){
            G[i].clear();
        }
        memset(lim,0,sizeof(lim));
        
        for(int i=0;i<MAX;i++) for(int j=0;j<MAX;j++) for(int k=0;k<MAX;k++) dis[i][j][k]=INF;
        
        int s,g;cin>>s>>g;
        s--;g--;
        
        for(int i=0;i<M;i++){
            int a,b,c,d;cin>>a>>b>>c>>d;
            a--;b--;
            G[a].push_back({b,c});
            G[b].push_back({a,c});
            lim[a][b]=d;
            lim[b][a]=d;
        }
        
        dijkstra(s);
        
        double ans=INF;
        
        /*for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                cout<<dis[1][j][k]<<" ";
            }
            cout<<endl;
        }*/
        
        for(int i=0;i<N;i++){
            ans=min(ans,dis[g][i][0]);
        }
        
        if(ans==INF) cout<<"unreachable"<<endl;
        else cout<<setprecision(25)<<ans<<endl;
    }
}






Measured memory_bytes: 4584
from itertools import accumulate, permutations

import bisect


N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = [0] + list(accumulate(A))
B = [0] + list(accumulate(B))

ans = 0
for i in range(N+1):
    a = A[i]
    if a > K:
        continue
    r = K - a
    j = bisect.bisect(B, r) - 1
    ans = max(ans, i + j)

print(ans)


Measured memory_bytes: 41328
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
#define rep(n) for( int i = 0 ; i < n ; i++ )
#define REP(n) for( int i = 1 ; i <= n ; i++ )
#define repll(n) for( ll i = 0 ; i < n ; i++ )
#define REPll(n) for( ll i = 1 ; i <= n ; i++ )
#define rep2(n) for( int j = 0 ; j < n ; j++ )
#define REP2(n) for( int j = 1 ; j <= n ; j++ )
#define repll2(n) for( ll j = 0 ; j < n ; j++ )
#define REPll2(n) for( ll j = 1 ; j <= n ; j++ )

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s , t;
    cin >> s >> t;
    int n = s.length();
    int a[26] = {} , b[26] = {};
    bool y = true;
    for( int i = 0 ; i < n ; i++ ) {
        a[s[i] - 'a']++;
		b[t[i] - 'a']++;
        if( a[s[i] - 'a'] != b[t[i] - 'a'] ) {
            y = false;
            break;
        }
    }
    if( y ) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3672
#include <iostream>
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const long long MAXN = 2600;
vector<pair<long long,long long>> v1[MAXN];
long long dp[MAXN][MAXN];
priority_queue<pair<long long,pair<long long,long long>>> q1;
long long n,m,s;
long long a[MAXN];
long long b[MAXN];
long long c[MAXN];
long long d[MAXN];
bool visited[MAXN][MAXN];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m>>s;
    for(long long i=1;i<=m;i++){
        long long u,v;
        cin>>u>>v>>a[i]>>b[i];
        v1[u].push_back(make_pair(v,i));
        v1[v].push_back(make_pair(u,i));
    }
    for(long long i=1;i<=n;i++){
        cin>>c[i]>>d[i];
        for(long long j=0;j<=2500;j++){
            dp[i][j] = 1e18;
        }
    }
    for(long long i=0;i<=min(s,1LL*2500);i++){
        dp[1][i] = 0;
        q1.push(make_pair(0,make_pair(1,i)));
       
    }
    
    while(q1.size()){
        auto hold= q1.top();
        long long curr = hold.second.first;
        long long extra = hold.second.second;
        
        q1.pop();
        if(visited[curr][extra]){
            continue;
        }
       
        visited[curr][extra] = true;
       // cout<<curr<<" "<<extra<<" "<<hold.first<<endl;

        for(auto x:v1[curr]){
            
            if(extra>=a[x.second] && dp[x.first][extra-a[x.second]]>dp[curr][extra]+b[x.second]){
                
                dp[x.first][extra-a[x.second]] = dp[curr][extra]+b[x.second];
                q1.push(make_pair(-dp[x.first][extra-a[x.second]],make_pair(x.first,extra-a[x.second])));
            }
        }
        for(long long j=extra+1;j<=2500;j++){
            long long lft = j-extra;
            long long mult = (lft/c[curr]) + (lft%c[curr]!=0);
            long long cost = 1LL*mult*d[curr];
            if(dp[curr][j]>dp[curr][extra]+cost){
                dp[curr][j] = dp[curr][extra]+cost;
                q1.push(make_pair(-dp[curr][j],make_pair(curr,j)));
            }
        }
    }
    
    for(long long i=2;i<=n;i++){
        long long ans = 1e18;
        for(long long j=0;j<=2500;j++){
            ans = min(ans,dp[i][j]);
        }
        cout<<ans<<" ";
    }
    
}

Measured memory_bytes: 102700
"use strict";
 
// inputに入力データ全体が入る
function Main(input) {
  input = input.split(" ");
  var a = parseInt(input[0]);
  var b = parseInt(input[1]);
  var c = parseInt(input[2]);
  
  a = a % b;
  var flag = 0;
  for (var i=0; i<b; i++) {
    if (a*i%b===c) {
      flag = 1;
      break;
    }
  }
  if (flag === 1) {
    console.log("YES");
  } else {
    console.log("NO");
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const long long int infLL = 9000000000000000000;
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937
const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;
#define MOD 1000000007
typedef long long ll;
const int mx=2e5+125;
ll pr[mx],ar[mx],br[mx];
#define PB push_back
#define endl '\n'
#define S second
#define F first
int main()
{
    faster();
    ll n,h,w;
    cin>>n;
    cin>>h>>w;
    int c=0;
    while(n--){
        ll a,b;
        cin>>a>>b;
        if(a>=h && b>=w)c++;

    }
    cout<<c<<endl;






    return 0;
}



Measured memory_bytes: 3612
#include<iostream>
using namespace std;
#define N 100
int main(){
  int n,a[N],i,b;
  cin >> n;
  for(i=0;i<n;i++)
    cin >> a[i];
  for(i=n-1;i>0;i--)
    cout << a[i] <<" ";
  cout<<a[0];
  cout << endl;
  return 0;
}

Measured memory_bytes: 1160
"""
AtCoder Grand Contest 039  A - Connection and Disconnection


Sの中で、隣り合う文字が同じ場合、連続しないよう書き換える
・abba -> abca
・abbba -> abcba：奇数個連続している場合、（連続してる個数）// 2 書き換える
・abbbba -> abcbca：偶数個連続している場合、（連続してる個数）// 2 書き換える。奇数個と同じ

また、Sを並べていく中で、「Sの末尾の文字群」と「Sの先頭の文字群」が同じ場合も、書き換えが必要。
S = abcda
SSSSS = abcda abcda abcda abcda abcda

文字列の両端は、普通に処理するのでなく、同じ文字であれば合算する形で処理したい
aaabcdaaa aaabcdaaa aaabcdaaa aaabcdaaa aaabcdaaaだと、間にaが6こ続くパターンと、全体の両端にaaaがある、みたいな。

Sが全部同じ文字だと、話がちょっと違って、交互に違う文字が出るように変える。これがコーナーケースかな？


（被らせないために）使えない文字は多くても2文字なので、書き換え先について悩むことはない。
"""
"""
AtCoder Grand Contest 041  A - Table Tennis Training

勝った人がX-1の卓、負けた人がX+1の卓で、引き分けはないから、±1のどちらかが絶対におこる
A,Bの間の距離が偶数の時、一方が勝ち一方が負けることで、差が2埋まるから、(B-A)/2回の試合後に、二人が試合できるはず
距離が奇数だと、
・端っこの卓で出会う
・一方が一回端っこの卓で足踏みしてからお互いの距離が縮まるように勝敗を決める
だと思う→一回端っこで足踏みしたら、そこで待つ必要もないので、端っこで出会うはなくていいかも。
二人の距離が奇数かつ、差が1なら両端のどちらかで出会うし、そうでなければ、一回足踏みののち、出会う方向に移動する形か

A側で一回足踏みするなら、足踏みが終わるまでにかかる試合数がa回で、そこから出会うまでが、(b-a-1) / 2回
B側で一回足踏みするなら、足踏みが終わるまでにかかる試合数がN-b+1回で、そこから出会うまでが、(N-(a+N-b+1)) / 2 = (b-a-1) / 2回
"""

N,A,B = map(int, input().split())

if (B-A) % 2 == 0:
    ans = (B-A) // 2
else:
    ans = min(A, N-B+1) + (B-A-1)//2
print(ans)

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < k; ++i) {
    int d;
    cin >> d;
    for (int j = 0; j < d; ++j) {
      int a;
      cin >> a;
      --a;
      ++v[a];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (v[i] == 0) {
      ++ans;
    }
  }
  cout << ans << endl;
}


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

int main() {
  string s;cin>>s;
  vector<int>vec(26);
  rep(i,s.size()){
    vec[s[i]-'a']++;
  }
  rep(i,26){
    if(vec[i]%2==1){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int main(){
    ll q;
    cin >> q;
    priority_queue<ll>f;
    priority_queue<ll,vector<ll>,greater<ll>> b;//小さい順にしたい時の宣言
    ll f_sum = 0;
    ll b_sum = 0;
    ll mid=INF;
    ll p = 0;
    rep(i,q){
        int x;
        cin >> x;
        if(x==2){
            ll ans;
            if(b_sum==0){
                ans = p;
            }
            else{
                ans = b_sum-f_sum+p;
            }
            if(mid!=INF){
                cout << mid << ' ' << ans << endl;
            }
            else{
                cout << f.top() << ' ' << ans << endl;
            }
        }
        if(x==1){
            ll y,z;
            cin >> y >> z;
            if(f.empty()){
                f.push(y);
                p += z;
                f_sum += y;
                continue;
            }
            if(b.empty()){
                p += z;
                ll f_now = f.top();
                if(f_now<=y){
                    b_sum += y;
                    b.push(y);
                }
                else{
                    f_sum = y;
                    b.push(f.top());
                    b_sum = f.top();
                    f.pop();
                    f.push(y);
                }
                continue;
            }
            p += z;
            if(mid!=INF){
                if(mid>y){
                    b_sum += mid;
                    b.push(mid);
                    f_sum += y;
                    f.push(y);
                    mid = INF;
                }
                else{
                    b_sum += y;
                    b.push(y);
                    f_sum += mid;
                    f.push(mid);
                    mid = INF;
                }
            }
            else{
                ll f_now = f.top();
                ll b_now = b.top();
                if(f_now<=y&&y<=b_now){
                    mid = y;
                }
                else if(y<f_now){
                    f_sum -= f_now;
                    f_sum += y;
                    mid = f_now;
                    f.pop();
                    f.push(y);
                }
                else{
                    b_sum -= b_now;
                    b_sum += y;
                    mid = b_now;
                    b.pop();
                    b.push(y);
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3828
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

int n,a,b; cin >> n >> a >> b;

int ans = 0;
ans += n / (a + b) * a;
ans += min(n % (a+b), a);

cout << ans << endl;
}







Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    div2 = 0
    div4 = 0
    notdiv4 = 0
    for ea in a:
        if ea % 4 == 0:
            div4 += 1
        elif ea % 2 == 0:
            div2 += 1
        else:
            notdiv4 += 1

    notdiv4 += div2 % 2
    if notdiv4 - 1 > div4:
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':
    main()

Measured memory_bytes: 14252
N, M = map(int, input().split())
A = list(set(map(int, input().split())))

def gcd(m, n):
    if n == 0:
        return m
    return gcd(n, m % n)

LCM = A[0]
for a in A:
    LCM = LCM * a // gcd(LCM, a)

K = max(A)
for X in range(K // 2, M + 1, K):
    for a in A:
        if (X - a // 2) % a != 0:
            break
    else:
        print((M - X) // LCM + 1)
        exit()
print(0)


Measured memory_bytes: 63984
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <list>

using namespace std;

#define ul long long
#define ull list<ul>

//#define DEBUG

int main() {
	ul n;
	cin >> n;

	ul buf;
	ull x_sorted;
	for (ul a=0;a<n;a++) {
		cin >> buf;
		x_sorted.push_back(buf);
	}
	x_sorted.sort();

	ull::iterator itr_xs;
	
	itr_xs = --(x_sorted.end());
	ul max = *itr_xs;
	ul desirable[2] = {(max+1)/2, (max +1+ max%2)/2};
	ul current[4]={0,*itr_xs,0,*itr_xs};

	for (itr_xs=x_sorted.begin();itr_xs != x_sorted.end();++itr_xs) {
		if (max % 2) {
			if (abs(*itr_xs-desirable[0]) < current[1]) {
					current[0]=current[2]=*itr_xs;
					current[1]=current[3]=abs(*itr_xs-desirable[0]);
			}
		} else {
			if (abs(*itr_xs-desirable[0]) < current[1]) {
					current[0]=*itr_xs;
					current[1]=abs(*itr_xs-desirable[0]);
			}
			if (abs(*itr_xs-desirable[1]) < current[3]) {
					current[2]=*itr_xs;
					current[3]=abs(*itr_xs-desirable[1]);
			}
		}
	}

	if (current[1] < current[3]) cout << max << " " << current[0] << max << endl;
	else cout << max << " " << current[2] << endl;

#ifdef DEBUG
	for (itr_xs=x_sorted.begin();itr_xs != x_sorted.end();++itr_xs)  cout << *itr_xs << " ";
#endif //DEBUG

	return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int cnt = 0;
		if (b != 1) {
			b = b - a;
			a--;
			cnt++;
			while (b > 0) {
				b = b - a;
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


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

    let n: usize = sc.read();
    let mut ans: i64 = 0;
    for i in 1..n + 1 {
        if i % 3 != 0 && i % 5 != 0 {
            ans += i as i64;
        }
    }
    println!("{}", ans);
}

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

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

Measured memory_bytes: 2116
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "queue"

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


int cost[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
ll digitmax = 40;

int main()
{
  int n, m;
  cin >> n >> m;
  int check[35] = {0};
  for (int i = 0; i < n; i++)
  {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++)
    {
      int a;
      cin >> a;
      check[a]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < m + 1; i++)
  {
    if (check[i] == n)
    {
      ans++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double PI = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	long long n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	map<long long, long long> m;
	for (int i = 0; i < n; i++)
		m[a[i]]++;

	long long ans = 0;
	for (auto p: m) {
		long long x = p.first;
		long long y = p.second;
		if (x > y) ans += y;
		else ans += y - x;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7040
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;


int main()
{
	int n,m;cin >> n >> m;
	vector<pair<ll,ll> > pe;
	vector<pair<ll,ll> > ch;
	
	REP(i,n)
	{
		int a,b;cin >> a >> b;
		pe.PB(MP(a,b));
	}
	REP(i,m)
	{
		int c,d;cin >> c >> d;
		ch.PB(MP(c,d));
	}
	
	REP(i,n)
	{
		int ret;ll mi = 1000000000000000;
		REP(j,m)
		{
			if(mi > abs(pe[i].FI-ch[j].FI) + abs(pe[i].SE-ch[j].SE))
			{
				ret = j;
				mi = abs(pe[i].FI-ch[j].FI) + abs(pe[i].SE-ch[j].SE);
			}
		}
		cout << ret + 1 << endl;
	}
			
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll x[3];
int main() {
    cin>>x[0]>>x[1]>>x[2];
    sort(x, x+3);
    reverse(x, x+3);

    cout<<10*x[0]+x[1]+x[2]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S;
    cin >> S;
    int ans = 700;
    rep(0, i, 3)
    {
        if (S[i] == 'o')
        {
            ans += 100;
        }
    }
    cout << ans << endl;
}

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

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

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

    int N;
    cin>>N;
    vector<int> as(N), bs(N), cs(N);
    rep(i, N) cin>>as[i]>>bs[i]>>cs[i];

    vector<int> dpa(N), dpb(N), dpc(N);
    dpa[0] = as[0]; dpb[0] = bs[0]; dpc[0] = cs[0];
    rep(i, N - 1) {
        dpa[i + 1] = max(dpb[i] + as[i + 1], dpc[i] + as[i + 1]);
        dpb[i + 1] = max(dpa[i] + bs[i + 1], dpc[i] + bs[i + 1]);
        dpc[i + 1] = max(dpa[i] + cs[i + 1], dpb[i] + cs[i + 1]);
    }
    int ans = max(dpa[N - 1], max(dpb[N - 1], dpc[N - 1]));
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cmath>
#define F(i,x,y) for(int i=x;i<=y;++i)
using namespace std;
long long n;
long long ans;
void dfs(long long x,long long sum,long long h,long long cnt){
	if(x==0){
		sum+=cnt;
		ans+=sum;
		return;
	}
	dfs(x%h,sum,h/10,cnt*10+x/h);
	dfs(x%h,sum+cnt,h/10,0);
}
int main(){
	scanf("%lld",&n);
	dfs(n,0,pow(10,floor(log10(n))),0);
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
main()
{
    char s[1005],t[1005];
    cin>>s>>t;
    int i,j,l1,l2,ans=1e9;
    l1=strlen(s);l2=strlen(t);
    for(i=0;i<=l1-l2;i++)
    {
       int t1=0;
       for(j=0;j<l2;j++)
       {
           if(t[j]!=s[i+j])
           {
               t1++;
           }
       }
       ans=min(ans,t1);
    }
    cout<<ans<<endl;
}


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

using namespace std;

const int N = 18;

set<pair<int, int> > A[1 << N];
int a[1 << N];

int main()
{
	int n;
	scanf("%d", &n);
	int S = 1 << n;
	for(int i = 0; i < S; i++)
	{
		scanf("%d", &a[i]);
		A[i].insert(make_pair(a[i], i));
	}
	for(int s = 0; s < S; s++)
	{
		for(int i = 0; i < n; i++)
			if(!((s >> i) & 1))
			{
				int tos = s | (1 << i);
				for(set<pair<int, int> >::iterator it = A[s].begin(); it != A[s].end(); it++)
					A[tos].insert(*it);
				while(A[tos].size() > 2)A[tos].erase(A[tos].begin());
			}
	}
	int ans = 0;
	for(int i = 1; i < S; i++)
	{
		int nowans = 0;
		for(set<pair<int, int> >::iterator it = A[i].begin(); it != A[i].end(); it++)
			nowans += (*it).first;
		ans = max(ans, nowans);
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 40960