akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int, vector<vector<int>>> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    vector<vector<int>> num(4, vector<int>(4));
    for(int i=0; i<2; i++){
        for(int j=0; j<4; j++){
            num[i][j] = i * 4 + j;
        }
    }

    map<vector<vector<int>>, int> cnt;
    map<vector<vector<int>>, bool> used;
    cnt[num] = 0;
    used[num] = true;
    queue<T> que;
    que.push(T(0, 0, 0, num));
    while(que.size()){
        int cy, cx, cost;
        vector<vector<int>> cnum(4, vector<int>(4));
        tie(cy, cx, cost, cnum) = que.front();
        que.pop();

        for(int i=0; i<4; i++){
            int ny = cy + dy[i];
            int nx = cx + dx[i];

            if(0 <= ny && ny < 2 && 0 <= nx && nx < 4){
                swap(cnum[cy][cx], cnum[ny][nx]);
                if(!used[cnum]){
                    used[cnum] = true;
                    cnt[cnum] = cost + 1;
                    que.push(T(ny, nx, cost + 1, cnum));
                }
                swap(cnum[cy][cx], cnum[ny][nx]);
            }
        }
    }

    vector<vector<int>> v(4, vector<int>(4));
    while(cin>>v[0][0]){
        for(int i=1; i<4; i++) cin>>v[0][i];
        for(int i=0; i<4; i++) cin>>v[1][i];

        cout << cnt[v] << endl;
    }
}


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

ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000000;
int exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1){
        if(exp(x,y-1)==-1)return -1;
        if(x*exp(x,y-1)>big)return -1;
        return (exp(x,y-1)*x);
    }
    ll t=exp(x,y/2);
    if(t==-1||t*t>big)return -1;
    return (t*t);
}

const int dx[6]={1,0,-1,0,1,-1};
const int dy[6]={0,1,0,-1,1,1};


ll in(ll x){
    return exp(x,big-2);
}

int half(int k,vector<int> &eat,int l,int r,bool aaa){//[l,r)
    if(aaa){
        ll j=1;
        while(j<=r-1){
            if(eat[j]>k)return half(k,eat,j/2-1,j,false);
            j*=1;
        }
        return half(k,eat,j/2-1,r,false);
    }
    if(r-l==1)return r;
    int m=(l+r)/2;
    if(eat[m]>k){
        return half(k,eat,l,m,false);
    }else{
        return half(k,eat,m,r,false);
    }
}

int find(int k,vector<int> &eat,int chi){
    if(eat[chi-1]<k)return -1;
    if(eat[0]>k)return 0;
    int s=half(k,eat,0,chi,true);
    return s;
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    int n;cin >> n;
    map<int,int> a;
    ll sum=0;
    rep(i,n){
        int k;cin >> k;
        a[k]++;
        sum+=k;
    }
    int q;cin >> q;
    rep(i,q){
        int b,c;cin >> b >> c;
        sum+=(c-b)*a[b];
        a[c]+=a[b];
        a.erase(b);
        cout << sum << '\n';
    }
    
}


Measured memory_bytes: 6568
d,g = map(int,raw_input().split())

arr = []

for i in range(d):
	arr.append(map(int,raw_input().split()))


ans = float("inf")
for i in range(2**d-1,-1,-1):
	b = bin(i)[2:].zfill(d)
	count = 0
	point = 0
	for j in range(d-1,-1,-1):
		if b[j] == "1":
			count += arr[j][0]
			point += (j+1) * 100 * arr[j][0] + arr[j][1]
	if point < g:

		for j in range(d-1,-1,-1):

			if b[j] == "0":
				t = 0
				while point < g and arr[j][0]-t > 1:
					point += (j+1) * 100
					t += 1
					count += 1

	if point < g:
		continue
	ans = min(ans, count)

print ans



Measured memory_bytes: 2696
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
	
	int n,i;
	cin >>n;
	
	double x[n];
	string u[n];
	double total;
	for (i=0 ; i<n ; i++) {
		cin >>x[i] >>u[i];
		if (u[i]=="BTC") {
			total+=x[i]*380000.0;
		} else {
			total+=x[i];
		}
	}
	
	cout <<total <<endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
n=int(input())
a=list(input())
A=[]
for i in range(n):
  a[i]=int(a[i])-1
  A.append(a[i]%2)

xorct=0
for i in range(n):
  if n-1==(i|n-1-i):
    xorct^=A[i]
if xorct==1:
  print(1)
  sys.exit()

if 1 in a:
  print(0)
  sys.exit()

for i in range(n):
  a[i]=a[i]//2
xorct=0
for i in range(n):
  if n-1==(i|n-1-i):
    xorct^=a[i]
if xorct==1:
  print(2)
  sys.exit()

print(0)

Measured memory_bytes: 148864
from collections import defaultdict
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = [0]*N
    min_inds = defaultdict(lambda: 10**5)
    nums = defaultdict(lambda: 0)
    for ind,a in enumerate(A):
        min_inds[a] = min(min_inds[a],ind)
        nums[a] += 1
    min_inds = sorted(list(map(list,min_inds.items())), key=lambda x:x[0])
    min_inds.append([10**9+1,10**5])
    nums = sorted(list(map(list,nums.items())), key=lambda x:x[0])
    nums.append([0,0])
    for i in range(len(min_inds)-2,-1,-1):
        min_inds[i][1] = min(min_inds[i][1],min_inds[i+1][1])
        nums[i][1] += nums[i+1][1]
        ans[min_inds[i][1]] += nums[i][1]*(nums[i][0]-nums[i-1][0])
    return ans
print(*solve(),sep='\n')

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

vector<int>v;
int main()
{
    int n; cin >> n;
    for(int i=0;i<=n;i++)
    {
        int p; cin >> p;
        v.push_back(p);
    }
    sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
    if(v.size()==n)cout << "YES\n";
    else cout << "NO\n";
    return 0;
}




Measured memory_bytes: 1400
#include<stdio.h>
int main(void)
{
	int h[10],i,j,box;
	for(i=0;i<10;i++)
		scanf("%d",&h[i]);
	for(i=0;i<9;i++){
		for(j=i+1;j<10;j++){
			if(h[i]<h[j]){
				box=h[i];
				h[i]=h[j];
				h[j]=box;
			}
		}
	}
	for(i=0;i<3;i++)
		printf("%d\n",h[i]);
	return 0;
}

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

using namespace std;

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

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

    int n;
    cin >> n;
    ll rez = 0;
    for (int ctr1 = 1; ctr1 <= n; ++ctr1) {
        ll tot = n / ctr1;
        rez += tot * (tot + 1) / 2 * ctr1;
    }
    cout << rez << '\n';
    return 0;
}


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

  int n; cin>>n;
  int a[n];
  rep(i,n){cin>>a[i];}
  int c=0;
  
  rep(i,n+1){if(a[i]%2==1)c++;
             i++;}
  cout<<c<<endl;
  
}

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

int main()
{
		int n, i;
		cin >> n;
		int a[n];
		for (i=0; i<n; i++) cin >> a[i];
		for (i=n-1; i>=0; i--) {
				if (i==0) cout << a[i] << "\n";
				else cout << a[i] << " ";
		}
}

Measured memory_bytes: 3072
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

int main(){
	string s;
	int x[3], num, ans=INF;
	
	cin >> s;
	
	REP(k,s.length()-2){
		REP(i,3){
			x[i] = s[i+k] - '0';
		}
		num = 100*x[0] + 10*x[1] + x[2];
		ans = min(ans, abs(num - 753));
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <string>
#include <sstream>
#include <math.h>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n ; i++)
#define pb push_back
static const int INF = 1000000;

typedef pair<int, int> P;
typedef pair<P, int> PP;

static const int MAX_V = 100;

struct edge { int to, cap, rev; };
vector<edge> G[MAX_V];
bool used[MAX_V];

int dfs(int st, int ed, int f){
  if ( st == ed ) return f;
  used[st] = true;

  rep(i,G[st].size()){
    edge &e = G[st][i];
    if ( !used[e.to] && e.cap > 0 ){
      int d = dfs(e.to, ed, min(f,e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int main(void){
  int v,e; cin >> v >> e;
  int a,b,c;
  rep(i,e){
    cin >> a >> b >> c;
    G[a].pb((edge){b,c,G[b].size()});
    G[b].pb((edge){a,0,G[a].size()-1});
  }

  //int st,ed; cin >> st >> ed;
  int flow = 0;
  while(true){
    rep(i,sizeof(used)){
      used[i] = 0;
    }
    int f = dfs(0,v-1,INF);
    if ( f == 0 ) {
      cout << flow << endl;
      break;
    }
    flow += f;
  }


  return 0;
}

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

int main(){
  ll s,t,k;
  cin >> s >> t >> k;
  
  if(k > (s+t)){ s = 0; t = 0;}
  else if(k > s) {
    t -=(k-s);
    s = 0;
  }else{
    s-=k;
  }
  cout << s << " " << t << endl;
}


Measured memory_bytes: 256
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin >> n;
	cout << (n + n*n + n*n*n);
}
//.........

Measured memory_bytes: 3620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemB solver = new ProblemB();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemB {
		final int N = 200010;
		final int MOD = (int) (1e9 + 7);
		int[] fact = new int[N];
		int[] inv = new int[N];
		int[] invFact = new int[N];

		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			precalc();

			int n = in.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
			}

			long[] h = new long[n];
			for (int i = 1; i < n; i++) {
				h[i] = (h[i - 1] + inv[i + 1]) % MOD;
			}

			long ans = 0;
			for (int i = 0; i < n; i++) {
				ans = (ans + a[i] * (1 + h[i] + h[n - i - 1])) % MOD;
			}
			ans = ans * fact[n] % MOD;

			out.println(ans);
		}

		private void precalc() {
			inv[1] = 1;
			for (int i = 2; i < N; i++) {
				inv[i] = (int) ((MOD - (MOD / i) * (long) inv[MOD % i] % MOD) % MOD);
			}
			fact[0] = 1;
			invFact[0] = 1;
			for (int i = 1; i < N; i++) {
				fact[i] = (int) (i * (long) fact[i - 1] % MOD);
				invFact[i] = (int) (inv[i] * (long) invFact[i - 1] % MOD);
			}
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 44312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 16;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		C[keta] = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) putchar(C[i]);
	putchar('\n');
}

int main() {
	int N;
	N = getint();
	int A[200001] = {};

	int mae = 0;
	int kotae = 1;
	int mod = 1e9 + 7;
	rep(i, N) {
		int C;
		C = getint();
		if (mae != C) kotae = (kotae + *(A + C)) % mod;
		*(A + C) = kotae;
		mae = C;
	}

	putint(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;


namespace ABC127_1
{
    class B
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var r = a[0];
            var D = a[1];
            var x = a[2];

            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(r * x - D);
                x = r * x - D;
            }
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define emp emplace

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

const int W = 100010;
ll pd[110][W];
int w[110], v[110];
int main()
{
	int n, mw;
	scanf("%d %d", &n, &mw);
	for (int i = 0; i < n; i++)
		scanf("%d %d", w+i, v+i);
	for (int i = n-1; i >= 0; i--)
	{
		for (int we = 0; we <= mw; we++)
		{
			pd[i][we] = pd[i+1][we];
			if (we + w[i] <= mw)
				pd[i][we] = max(pd[i][we], pd[i+1][we + w[i]] + v[i]);
		}
	}
	printf("%lld\n", pd[0][0]);
	return 0;
}



Measured memory_bytes: 80128
def resolve():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    g = [1] * N
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        if H[a] <= H[b]:
            g[a] = 0
        if H[b] <= H[a]:
            g[b] = 0

    print(sum(g))
resolve()

Measured memory_bytes: 20028
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

   int k; cin>>k;

    
    string s; cin>>s;

    int n = s.length();

    if(n <= k)cout<<s<<"\n";
    else{
        cout<<s.substr(0, k)<<"...\n";
    }
}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;

int a[200010];
int b[200010];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int n;
    set<int> st;
    cin >> n;
    REP(i, n){
        int a; cin >> a;
        st.insert(a);
    }
    int m; cin >> m;
    REP(i, m){
        int a; cin >> a;
        st.insert(a);
    }
    
    for(auto it=st.begin(); it!=st.end(); ++it){
        cout << *it << endl;
    }
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  if(S=="BBB"||S=="AAA")
    cout << "No";
  else
  cout << "Yes";
  return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
     
#define mp make_pair
#define sz(x) (int)((x).size())
#define all(x) (x).begin(),(x).end()
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define eb emplace_back
 
typedef pair< int, int > pii;
typedef pair< long long, long long > pll;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef vector< pii > vpii;
typedef vector< vpii > vvpii;
typedef vector< pll > vpll;
typedef long double ld;
typedef vector< ld > vld;
typedef unsigned int uint;
 
const ll MOD2 = 1e9 + 7;
const int MOD = 1e9 + 7;
 
const ull infull = numeric_limits<unsigned long long>::max();
 
void fix(int &x, ll MOD) {
    x = (x % MOD);
    if(x < 0) x += MOD;
    return;
}
 
ll lgput(ll a, ll b, ll MOD) {
    ll ret = 1;
    a %= MOD;
    while(b) {
        if(b&1) ret = ret*a % MOD;
        a = a*a % MOD;
        b >>= 1;
    }
 
    return ret;
}
 
ll inv(ll a, ll MOD) {
    return lgput(a, MOD-2, MOD);
}
 
template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    const bool operator<(const M& o) const {return v < o.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
 
using Mint = ModInt<(int)1e9 + 7>;
 
int main() { 
    #ifdef BLAT
        freopen("stdin", "r", stdin);
        freopen("stderr", "w", stderr);
    #endif
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    srand(time(NULL));
    
    int n;
    cin >> n;

    ll ans = 0;
    for(int i = 1; i <= n; ++i) {
        if(i % 3 && i % 5) ans += i;
    }

    cout << ans << '\n';
    return 0; 
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String ans = solve(N);

        System.out.println(ans);
    }

    private static String solve(int N) {
        String abc = N < 1000 ? "ABC" : "ABD";

        return abc;
    }
}


Measured memory_bytes: 21716
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect

def solve(animals, legs):
    if legs % 2 != 0:
        return False
    min_ = animals * 2
    max_ = animals * 4
    if min_ <= legs <= max_:
        return True
    else:
        return False

if __name__ == '__main__':
    animals, legs = list(map(int, input().split()))
    ans = solve(animals, legs)
    if ans:
        print("Yes")
    else:
        print("No")

    #print('\33[32m' + 'end' + '\033[0m') # debug


Measured memory_bytes: 71836
a,b,c = map(int,input().split())
ok = False
if a == 5 and b == 5 and c == 7:
    ok = True
elif a == 5 and b == 7 and c == 5:
    ok = True
elif a == 7 and b == 5 and c == 5:
    ok = True
if ok == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
N = int(input())
prev = input()
lst = [prev]
flg = True
for i in range(N-1):
    w = input()
    lst.append(w)
    if w[0] != prev[-1]:
        flg = False
    prev = w

lst.sort()
for i in range(N-1):
    if lst[i+1] == lst[i]:
        flg = False
        break

if flg:
    print("Yes")
else:
    print("No")


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm

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

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

    int2(n, m);
    vector<string> ban(n);
    rep(i, n) {
        cin >> ban[i];
    }

    rep(i, n) {
        rep(j, m) {
            if (ban[i][j] == '.') {
                int cnt = 0;
                rep(k, 8) {
                    int nx = i + dx[k], ny = j + dy[k];
                    if (0 <= nx && nx < n && 
                            0 <= ny && ny < m) {
                        if (ban[nx][ny] == '#') {
                            cnt++;
                        }
                    }
                }
                ban[i][j] = '0' + cnt;
            }
        }
    }

    rep(i, n) {
        cout << ban[i] << endl;
    }

    
    return 0;
}



Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
q = int(input())
 
f=e-d
g=e-c
h=e-b
i=e-a
j=d-c
k=d-b
l=d-a
m=c-b
n=c-a
o=b-a

 
 
if f<=q and g<=q and h<=q and i<=q and j<=q and k<=q and l<=q and m<=q and n<=q and o<=q:
  print("Yay!")
 
else:
  print(":(")

Measured memory_bytes: 3064
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

string A;
map<char,ll> mp;
int main (){
      cin>>A;
      ll n=A.size();
      ll ans=(n*(n+1ll))/2;
      rep0(i,n){
            mp[A[i]]++;
      }
      ll hoge=0;
      for(char c='a';c<='z';c++){
            hoge+=((mp[c]*(mp[c]+1))/2);
      }
      cout<<1ll+ans-hoge<<endl;
      
      return 0;
}


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

int main(){
    char a;
    cin >> a;
    if(a >= 'a' && a <= 'z'){
        cout << 'a' << endl;
        return 0;
    }
    else{
        cout << 'A' << endl;
    }
    
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int n  = sc.nextInt();
		int r  = sc.nextInt();
		
		if(n<10) {
			r += 100*(10-n);
		}

		System.out.println(r);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	
	public static boolean palindromic(int t) {
		String ans = String.valueOf(t);
		int n = ans.length();
		for(int i = 0; i < n / 2; ++i) {
			if(ans.charAt(i) != ans.charAt(n - i - 1))return false;
		}
		return true;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		int ans = 0;
		sc.close();
		for(int i = a; i <= b; ++i) {
			if(palindromic(i))++ans;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 29072
N, A, B = map(int, input().split())
S = list(input())
cnt = 0
fcnt = 0
for i in range(N):
    if S[i] == "a":
        if cnt < A + B:
            print("Yes")
            cnt += 1
        else:
            print("No")
    elif S[i] == "b":
        if cnt < A + B and fcnt < B:
            print("Yes")
            fcnt += 1
            cnt += 1
        else:
            print("No")
    elif S[i] == "c":
        print("No")
        


Measured memory_bytes: 4712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
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;}

int N;
void dfs(string s, char big, int len){
  if(len==N){
    cout << s << endl;
    return;
  }
  for(int i=0;'a'+i-1<=big; i++){
    if((char)('a'+i-1)!=big)dfs(s+(char)('a'+i), big, len+1);
    else dfs(s+(char)('a'+i), (char)('a'+i), len+1);
  }
}

int main(){
  cin >> N;
  dfs("a",'a',1);

  return 0;
}


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

int main()
{
  char s_str[101], t_str[101];
  
  scanf("%s", s_str);
  scanf("%s", t_str);
  int len = strlen(s_str);
  
  bool res;
  int flg = 0;
  for(int i=0; i<len; i++)
  {
    res = true;
    for(int j=0; j<len; j++)
    {
      if(s_str[j] != t_str[j])	res = false;
    }
    if(res == true)	flg = 1;
    char temp = s_str[0];
    for(int k=0; k<len-1; k++)
    {
      s_str[k] = s_str[k+1];
    }
    s_str[len-1] = temp;
  }
  
  if(flg == 1)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
	string s;cin>>s;
	string t=s;reverse(t.begin(),t.end());
	for(int i=0;i<t.length();i++){
		if(t[i]=='b'){
			t[i]='d';
		}else if(t[i]=='d'){
			t[i]='b';
		}else if(t[i]=='p'){
			t[i]='q';
		}else{
			t[i]='p';
		}
	}
	if(s==t){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, u, v) for (int i = u; i <= v; i++)
#define FORD(i, v, u) for (int i = v; i >= u; i--)
#define pii pair<int, int>
#define mp make_pair
#define F first
#define S second
#define PB push_back
#define N 200005
#define mod 1000000007

using namespace std;

int n, m, len, x[4], y[4], beX, beY;
char s[N], t[N];
string dir = "LRUD";
int fx[4] = {0, 0, -1, 1};
int fy[4] = {-1, 1, 0, 0};

bool isOut(int id) {
	return (x[id] < 1 || y[id] < 1 || x[id] > n || y[id] > m);
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
	freopen("INP.TXT", "r", stdin);
	freopen("OUT.TXT", "w", stdout);
	#endif*/
	cin >> n >> m >> len;
	cin >> beX >> beY;
	FOR(i, 1, len) cin >> s[i];
	FOR(i, 1, len) cin >> t[i];

	FOR(i, 0, 3) x[i] = beX, y[i] = beY;

	FOR(i, 1, len) {
		int dirS = dir.find(s[i]);
		int dirT = dir.find(t[i]);

		x[dirS] += fx[dirS];
		y[dirS] += fy[dirS];

		if (isOut(dirS)) {
			cout <<"NO";
			return 0;
		}
		x[dirT^1] += fx[dirT];
		y[dirT^1] += fy[dirT];
		if (isOut(dirT^1)) {
			x[dirT^1] -= fx[dirT];
			y[dirT^1] -= fy[dirT];
		}
	}
	cout <<"YES";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  998244353
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    string S,T; cin>>S>>T;
    ll q; cin>>q;
    ll NS=S.length();
    ll NT=T.length();
    ll s[NS+1]={};
    ll t[NT+1]={};
    rep(i,NS){
        ll x;
        if(S[i]=='A') x=1;
        else x=2;
        s[i+1]=s[i]+x;
    }
    rep(i,NT){
        ll x;
        if(T[i]=='A') x=1;
        else x=2;
        t[i+1]=t[i]+x;
    }
    rep(i,q){
        ll a,b,c,d; cin>>a>>b>>c>>d;
        cout<< ( (s[b]-s[a-1])%3 == (t[d]-t[c-1])%3 ? "YES" : "NO" )<<"\n";
    }

}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main(int argc, char const *argv[])
{
    int h,w;cin>>h>>w;
    vector<string> a(h);
    vector<string> tmp;
    for(int i=0;i<h;i++){
        cin>>a[i];
        bool is_w = true;
        for(int j=0;j<w;j++){
            if(a[i][j]=='#'){
                is_w = false;
                break;
            }
        }
        if(!is_w)tmp.push_back(a[i]);
    }
    vector<string> ret(tmp.size());
    for(int j=0;j<w;j++){
        bool is_w = true;
        for(int i=0;i<tmp.size();i++){
            if(tmp[i][j]=='#'){
                is_w = false;
                break;
            }
        }
        if(!is_w){
            for(int i=0;i<tmp.size();i++){
                ret[i]+=tmp[i][j];
            }
        }
    }
    for(auto s:ret)cout << s << endl;
    return 0;
}


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

using namespace std;

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n;
   cin >> n;
   long long ans = 0;
   while(n--) {
       int foo;
       cin >> foo;
       ans += --foo;
   }
   cout << ans << endl;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s; cin >> s;
    bool ok = true;
    for(int i=1;i<=s.size();i++){
        if(i %2 == 1){
            if(s[i-1] == 'L'){
                ok = false;
                break;
            }
        }else{
            if(s[i-1] == 'R'){
                ok = false;
                break;
            }
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using namespace std;

int main() {
    int N;

    cin >> N;

    vector<int> count(N+1, 0);
    int result = 0;

    for(int i = 1; i < N+1; i++) {
        for(int j = i; j < N+1; j += i) {
            count[j]++;
        }
    }

    for(int i = 1; i < N+1; i++) {
        if(i % 2 == 1) {
            if(count[i] == 8) {
                result++;
            }
        }
    }

    cout << result << endl;


	return 0;
}

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

using namespace std;

#define int long long

main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
		
	int cnt = 0;
	int n_of_A = 0;
	
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'A')
			n_of_A++;
		else
		{
			if(i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C')
			{
				cnt += n_of_A;
				i++;
			}
			else
				n_of_A = 0;
		}
    }
	
	cout << cnt << endl;
}


Measured memory_bytes: 720
n    = gets.to_i
ary  = gets.split.map(&:to_i)

cntS = ary[0]
cntA = ary.inject(:+) - ary[0]
ans  = (cntS - cntA).abs

for i in 1 .. n - 2
  cntS += ary[i]
  cntA -= ary[i]
  ans   = [ans, (cntS - cntA).abs].min
end

puts ans


Measured memory_bytes: 19204
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;

int main(){
	int n, d, x, i, ans=0;
	int a[110];
	cin>>n>>d>>x;
	for(i=0; i<n; i++) cin>>a[i];
	for(i=0; i<n; i++){
		ans+=(d-1)/a[i]+1;
	}
	cout<<ans+x<<endl;
	return 0;
}

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

int main() {

  int N;
  cin >> N;

  set<string> S;

  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    S.insert(s);
  }

  cout << S.size() << endl;

  return 0;

}

Measured memory_bytes: 19228
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int S, W;
  cin >> S >> W;
  cout << (S <= W ? "unsafe" : "safe") << endl;
  return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>
using namespace std;
int main() {
  int N;
  string a, b;
  cin >> N >> a >> b;
  for(int i = 0; i <= N; ++i) {
    if(a.substr(i, N - i) == b.substr(0, N - i)){
	  cout << N + i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 25

typedef struct{
  int l,r,par;
} node;

node N[MAX];

void init(int);
void Preorder(int);
void Inorder(int);
void Postorder(int);

int main(){
  int n,i,id,l,r;
  int p;
  
  scanf("%d" ,&n); 
  init(n);

  for(i = 0 ; i < n ; i++){
    if(i<n){
        break;
    }
  }



  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d" ,&id ,&l ,&r);

    if(l != -1){
      N[id].l = l;
      N[l].par = id;
    }
    if(r != -1){
      N[id].r = r;
      N[r].par = id;
    }
  }

  for(i = 0 ; i < n ; i++){
    if(N[i].par == -1){
        
      p = i;
      break;
    }
  }

  
  puts("Preorder");
  Preorder(p);
  puts("");

  puts("Inorder");
  Inorder(p);
  puts("");

  puts("Postorder");
  Postorder(p);
  puts("");

  return 0;
}

void init(int n){
  int i;

  for(i = 0 ; i < n ; i++){
    N[i].par = N[i].l = N[i].r = -1;
  }
}

void Preorder(int p){
  if(p != -1){
    printf(" %d" ,p);
    Preorder(N[p].l);
    Preorder(N[p].r);
  }
}

void Inorder(int p){
  if(p != -1){
    Inorder(N[p].l);
    printf(" %d" ,p);
    Inorder(N[p].r);
  }
}

void Postorder(int p){
  if(p != -1){
    Postorder(N[p].l);
    Postorder(N[p].r);
    printf(" %d" ,p);
  }
}


Measured memory_bytes: 2124
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

char S[1111];

void MAIN() {
    scanf("%s", S);
    int len = strlen(S);
    int x = count(S, S+len, 'x');

    if (15 - x >= 8) puts("YES");
    else puts("NO");

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int kou[7], tei[7];
	int sa[7];
	int i;
	
	for (i = 0; i < 7; i++){
		scanf("%d %d", &kou[i], &tei[i]);
		
		sa[i] = kou[i] - tei[i];
	}
	
	for (i = 0; i < 7; i++){
		printf("%d\n", sa[i]);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int n=N;
  int s=0;
  for(int i=0;i<10;i++){
    s += N%10;
    N = N/10;
  }
  if(n%s == 0) cout << "Yes" <<endl;
  else cout << "No" << endl;
}
  

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int ans,sco[100],i;
	int max = 1,num = 0;
	
	scanf("%d",&ans);
	
	for(i = 0;i < ans;i++){
		scanf("%d",&sco[i]);
	}
	while(i-1 < ans){
		if(max <= sco[i-1]){
			num++;
		}
		if(max == num){
			i = 0;
			max++;
			num = 0;
		}
		i++;
	}
	
	printf("%d\n",max-1);
	
	return(0);
}

Measured memory_bytes: 1868
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	s := IOInitialize()
	A := Int(s)
	B := Int(s)
	C := Int(s)
	nums := []int{A, B, C}
	index := max(nums)
	res := 0
	for i, num := range nums {
		if i == index {
			res += num * 10
		} else {
			res += num
		}
	}
	fmt.Println(res)
}

func max(nums []int) int {
	res := 0
	n := nums[0]
	for i, num := range nums {
		if n < num {
			n = num
			res = i
		}
	}
	return res
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (ll)1e9+7
#define LLINF (ll)1e30
// #define int ll
using namespace std;
const int MAX =101010;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,q,sum[200010];
    vector<ll> G[200010];
    bool V[200010];
    cin>>n>>q;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }
    rep(i,q){
        int p,x;
        cin>>p>>x;
        sum[p]+=x;
    }
    queue<ll> que;
    que.push(1);
    while(!que.empty()){
        ll u=que.front();
        que.pop();
        V[u]=1;
        for(auto i:G[u]){
            if(V[i]==1) continue;
            sum[i]+=sum[u];
            que.push(i);
        }
    }
    rep2(i,1,n+1){
        cout<<sum[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 18160
W, H, x, y, r = [int(i) for i in input().split()]

if (x - r) < 0 or (x + r) > W:
    print("No")
elif (y - r) < 0 or (y + r) > H:
    print("No")
elif r > x:
    print("No")
elif r > y:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 7720
n = int(input())
ans = 0
if 1800 <= n <= 1999:
    ans = 1
elif 1600 <= n <= 1799:
    ans = 2
elif 1400 <= n <= 1599:
    ans = 3
elif 1200 <= n <= 1399:
    ans = 4
elif 1000 <= n <= 1199:
    ans = 5
elif 800 <= n <= 999:
    ans = 6
elif 600 <= n <= 799:
    ans = 7
else:
    ans = 8
print(ans)

Measured memory_bytes: 9212
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int a[1001];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);  
	int n;
	cin >> n;
	for(int i=2;i<=n;i++)
	{
		int temp=i;
		for(int j=2;j*j<=i;j++)
		{
			while(temp%j==0)
			{
				// cout << "dsf";
				a[j]++;
				temp/=j;
			}
		}
		if(temp>1)
			a[temp]++;
	}
	lld ans=1;
	for(int i=2;i<1001;i++)
	{
		// cout << i << " " <<  ans  << "\n";
		if(a[i]>0)
		{
			ans*=(a[i]+1);
			ans%=1000000007;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int sum = 0, n = N;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  if(N % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys
n,m = map(int,input().split())
#input = sys.stdin.readline
sys.setrecursionlimit(10**9)
list1 = []
s = list(input())
s.reverse()
def maze(mass): #今いるマス、現状の手数
    if mass+m >= n:
        list1.append(n-mass)
        return
    for i in range(m,0,-1):
        if s[mass+i] == "0":
            list1.append(i)
            maze(mass+i)
            return
        elif i == 1:
            print(-1)
            exit()
maze(0)
list1.reverse()
print(" ".join(map(str,list1)))

Measured memory_bytes: 130700
#include <algorithm>
#include <cmath>
#include <cstring>
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <utility>
#include <vector>
// five elements
#include <cstdlib>
#include <iomanip>
#define ll long long
#define ef else if
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rev(i, s, n) for (int i = s; i > n; i = i - 1)
using namespace std;
#define fr first
#define se second
#define pb push_back
#define mp make_pair
#define mv vector<ll>
#define vv vector<vector<ll>>
#define vii vector<pair<ll, ll> >
#include <functional>
#include <map>
#include <queue>
#include <set>
// akane_psycho
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define c1(a) cout << a << endl;
#define c2(a, b) cout << a << " " << b << endl;
#define c4 (k, x, b, c) printf(" %d %d %d %d ", &k, &x, &b, &c)
#define db double
#define inf 1e18
#define lim 2000000000
#define mo 1000000007
#include <bitset>
#define rp(v)      cout << endl;                                                                \
  rep(i, 0, v.size()) cout << v[i] << " ";                                     \
  cout << endl;
ll mod(ll n) { return n % (ll)mo; }
string s;
int n;

int main()
{
	cin>>s;
	n=s.size();
	ll ans=1;
	string c,p;p+=s[0];
	
	rep(i,1,n){
		c=s[i];
		if(c==p){
		//	c=s[i];
			if(i<n-1)
			{i++;
			c+=s[i];
			p=c;
			ans++;
		}
		}
		else{
			
			p=s[i];
			ans++;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 640
import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    V = 10 ** 5 + 5
    edge = [[] * (2 * V) for _ in range(2 * V)]
    visited = [False] * (2 * V)
    for i in range(N):
        x, y = map(int, input().split())
        y += V
        edge[x].append(y)
        edge[y].append(x)

    ans = 0
    for i in range(2 * V):
        if visited[i]:
            continue
        cnt = [0,0]
        q = deque([i])
        while q:
            s = q.pop() # dfsをやりたいのでpopleftではなくpop
            if visited[s]:
                continue
            visited[s] = True
            cnt[s//V] += 1
            for v in edge[s]:
                if visited[v]:
                    continue
                q.append(v)
        ans += cnt[0] * cnt[1]

    print(ans - N)


if __name__ == "__main__":
    main()

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

using namespace std;

#define int long long

void solve() {
    int n, k;
    cin >> n >> k;
    vector <int> ws(n);
    for (int i = 0; i < k; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int val;
            cin >> val;
            ws[val - 1] = 1;
        }
    }
    int cnt = 0;
    for (int i =0; i < n; ++i) if (ws[i] == 0)++cnt;
    cout << cnt;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3644