akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__);
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////

int32_t main() {
    int n,k; cin >> n >> k;
    vector<int> h(n); cin >> h;
    int c = 0;
    rep (i,n) if (h[i] >= k) c++;
    cout << c << endl;
}


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

using namespace std;

const int ARR_SIZE = 1e2+5;

int arr[ARR_SIZE];

int main() {
  int n = -1;
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%d", arr+i);
  }

  sort(arr, arr+n);

  int ans = 0;
  for (int i = 0; i < n-2; ++i) {
    for (int j = i+1; j < n-1; ++j) {
      if (arr[j] == arr[i]) continue;

      for (int k = j+1; k < n; ++k) {
        if (arr[k] == arr[j]) continue;

        if (arr[i] + arr[j] <= arr[k]) break;
        ans++;
      }
    }
  }

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

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

int main(){
  int N,A,B;
  cin >>N>>A>>B;
 
  int ans = 0;
  rep(i,1,N+1){
    int c = 0;
    int t = i;
    rep(j,0,5){
      c += t%10;
      t /= 10; 
    }
    if(A<=c and c<=B) ans+=i;
  }
  cout <<ans<< endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<complex>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

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

typedef complex<double> P;

const double EPS = 1e-8;
inline double dot(P a, P b) {return real( conj(a)*b);}
inline double cross(P a, P b) {return imag( conj(a)*b);}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > EPS)   return +1;       // counter clockwise
  if (cross(b, c) < -EPS)   return -1;       // clockwise
  if (dot(b, c) < -EPS)     return +2;       // c--a--b on line
  if (norm(b) + EPS < norm(c)) return -2;       // a--b--c on line
  return 0;
}
bool IsIntersectSS(P a1, P a2, P b1, P b2) {
  return ccw(a1,a2,b1) * ccw (a1,a2,b2) <= 0 &&
    ccw(b1,b2,a1) * ccw(b1,b2,a2) <= 0;
}

// PolygonÍ½vñèÉ^¦çêÄ¢é±Æ
enum { OUT, IN, ON };
int ConvexContainsP(const vector<P>& poly, P p){
  int N = poly.size();
  bool on = false;
  REP(i,N) {
    P a = poly[i];
    P b = poly[(i+1)%N];
    if( cross(b-a,p-a) < -EPS ) return OUT;
    if( abs( cross(b-a, p-a) ) < EPS ) on = true;
  }
  if( on ) return ON;
  return IN;
}

bool connect(const vector<P> &a, const vector<P> &b) {
  for(int i = 0; i < (int)a.size(); i++)
    for(int j = 0; j < (int)b.size(); j++)
      if( IsIntersectSS( a[i], a[(i + 1) % a.size()], b[j], b[(j + 1) % b.size()]) )
        return true;
  for(int i = 0; i < (int)a.size(); i++)
    if( ConvexContainsP( b, a[i] ) ) return true;
  for(int i = 0; i < (int)b.size(); i++)
    if( ConvexContainsP( a, b[i] ) ) return true;
  return false;
}

int table[128][128];
int visited[128];
void dfs(int p, int N) {
  if( visited[p] ) return;
  visited[p] = 1;
  REP(i, N) if( table[p][i] ) dfs(i, N);
}

void input(vector<P> &v) {
  v.clear();
  REP(k, 4) {
    int x, y; cin >> x >> y;
    v.push_back( P(x, y) );
  }
  reverse(v.begin(), v.end());
}

int solve(int N) {
  vector<P> v[N];
  REP(i, N) input(v[i]);

  REP(i, N) REP(j, N) table[i][j] = 0;

  REP(i, N) REP(j, i) {
    if( connect( v[i], v[j] ) )
      table[i][j] = table[j][i] = 1;
  }

  REP(i, N) visited[i] = 0;
  int cnt = 0;
  REP(i, N) {
    if( !visited[i] ) {
      cnt++;
      dfs(i, N);
    }
  }
  return cnt;
}

int main() {
  for(;;) {
    int N; cin >> N; if( N == 0 ) break;
    REP(i, N) {
      int M; cin >> M;
      int res = solve(M);
      cout << res << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 988
from collections import Counter
 
n = int(input())
v = list(map(int, input().split()))
v1 = Counter(v[::2]).most_common()
v2 = Counter(v[1::2]).most_common()
v1.append((0, 0))
v2.append((0, 0))
if v1[0][0] != v2[0][0]:
    print(n - v1[0][1] - v2[0][1])
else:
    print(min(n - v1[0][1] - v2[1][1], n - v1[1][1] - v2[0][1]))

Measured memory_bytes: 20700
import sys
sys.setrecursionlimit(500000)
s=list(input())
ans=0
cA=1
L=[]
def dfs(v):#vはインデックス
    if 0<=v+1<=len(s)-1 and s[v+1]=='A':
        s[v+1]='#'
        global cA
        cA+=1
        dfs(v+1)
    elif 0<=v+2<=len(s)-1 and s[v+1]=='B' and s[v+2]=='C':
        global ans
        ans+=cA
        dfs(v+2)
    else:
        cA=1
        return

for i,I in enumerate(s):
    if I=='A':
        L.append(i)
for l in L:
    if (0<=l+1<=len(s)-1 and s[l]=='A'and s[l+1]=='A'):
        dfs(l)
    elif (0<=l+2<=len(s)-1 and s[l]=='A'and s[l+1]=='B'and s[l+2]=='C'):
        dfs(l)
    else:
        cA=1
print(ans)

Measured memory_bytes: 173624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	vector<ii> vec;
	int cnt[3]={0,0,0};
	int lim[2]={0,0};
	cin>>lim[0]>>lim[1]>>cnt[0]>>cnt[1]>>cnt[2];
	for(int z=0;z<3;z++)
	{
		for(int j=0;j<cnt[z];j++)
		{
			ll x; cin>>x;
			vec.pb({x,z});
		}
	}
	sort(vec.rbegin(),vec.rend());
	ll ans=0;
	ll apples=lim[0]+lim[1];
	for(int i=0;i<vec.size();i++)
	{
		int ty=vec[i].se;
		if(apples<=0) break;
		if(ty<=1)
		{
			if(lim[ty]<=0) continue;
			lim[ty]--;
			ans+=vec[i].fi;
			apples--;
		}
		else
		{
			apples--;
			ans+=vec[i].fi;
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 10476
import sys

def func(H, W):
    ans = 10**9
    for w in range(1,W):
        w_a = (W - w) // 2
        w_b = W - w  - w_a
        sub = max(H * w, H * w_a, H * w_b) - min(H * w, H * w_a, H * w_b)
        ans = min(ans, sub)

        h_a = H // 2
        h_b = H - h_a
        sub = max(H * w, h_a * (W - w), h_b * (W- w)) - min(H * w, h_a * (W - w), h_b * (W- w))
        ans = min(ans , sub)
    return ans

stdin = sys.stdin

ns = lambda: stdin.readline()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

H, W = na()

print (min(func(H, W), func(W, H)))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;

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

  vector<vector<int>> count(10, vector<int>(10,0));

  for(int i=1; i<=N; i++){
    string w;
    w = to_string(i);
    char top, last;
    top = w.at(0);
    last = w.at(w.size()-1);
    int ntop, nlast;
    ntop = top - '0';
    nlast = last - '0';
    count.at(ntop).at(nlast)++;
  }

  ll answer = 0;
  for(int i=1; i<=9; i++){
    for(int j=i; j<=9; j++){
      if(i==j){
        if(count.at(i).at(j) != 0){
          ll ncount;
          ncount = count.at(i).at(j)*(count.at(i).at(j)-1) + count.at(i).at(j);
          answer += ncount;
        }
      }else{
        if(count.at(i).at(j)!=0 && count.at(j).at(i)!=0){
          ll ncount;
          ncount = count.at(i).at(j) * count.at(j).at(i) * 2;
          answer += ncount;
        }
      }
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
n = int(input())

ls = []
rs = []
for _ in range(n):
    x, y = map(int, input().split())
    ls.append(x)
    rs.append(y)

ls = sorted(ls)
rs = sorted(rs)

if n % 2 == 1:
    print(rs[len(rs)//2] - ls[len(ls)//2] + 1)
else:
    a = (rs[len(rs)//2-1] * 10 + rs[len(rs)//2] * 10) // 2
    b = (ls[len(ls)//2-1] * 10 + ls[len(ls)//2] * 10) // 2
    print((a - b) // 5 + 1)

Measured memory_bytes: 27048
#include <iostream>
#include <cstdlib>

using namespace std;


class element{
    public:
        int key;
        char org[2];
        int postition;
};

void bubble(element *arr, int n);
void select(element *arr, int n);


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

    element arr[n];
    element arr2[n];
    for(int i = 0;i < n;i++)
    {
        cin>>arr[i].org;
        arr[i].key = atoi(&arr[i].org[1]);
        arr[i].postition = i;
        arr2[i] = arr[i];
    }

    bubble(arr, n);
    select(arr2, n);    
}

void bubble(element *arr, int n)
{

    bool stable = true;
    for(int i = 0;i < n;i++)
    {
        //for(int j = 0;j < n - i -1;j++)
        for(int j = 1;j < n;j++)
        {
            //if(arr[j].key > arr[j+1].key)
            if(arr[j].key < arr[j-1].key)
                swap(arr[j], arr[j-1]);
        }
    }

    for(int i = 0; i < n; i++)
    {
        if(i != n && arr[i].key == arr[i+1].key && arr[i].postition > arr[i+1].postition)
            stable = false;
        if(i != n-1) 
            cout<<arr[i].org<<" ";
        else
            cout<<arr[i].org<<endl;
    }
    if(stable)
        cout<<"Stable"<<endl;
    else
        cout<<"Not stable"<<endl;
}

void select(element *arr, int n)
{
    bool stable = true;
    for(int i = 0;i < n;i++)
    {
        int temp = i;
        //for(int j = i + 1;j < n;j++)
        for(int j = i;j < n;j++)
        {
            if(arr[temp].key > arr[j].key)
                temp = j;
        }
        swap(arr[i], arr[temp]);
    }
    for(int i = 0; i < n; i++)
    {
        if(i != n && arr[i].key == arr[i+1].key && arr[i].postition > arr[i+1].postition)
            stable = false;
        if(i != n-1)
            cout<<arr[i].org<<" ";
        else
            cout<<arr[i].org<<endl;
    }

    if(stable)
        cout<<"Stable"<<endl;
    else
        cout<<"Not stable"<<endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 1; i <= n; i++)
#define MAX_N 200010
#define MAX_M 100010

int p[MAX_N], xy[2][MAX_M];
int par[MAX_N], myrank[MAX_N];

void init(int x){
	rep(i,x)par[i]=i,myrank[i]=0;
}

int find(int x){
	if(par[x] == x){
		return x;
	} else return par[x] = find(par[x]);
}

bool same(int x, int y){
	return find(x) == find(y);
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	
	if(x == y)return ;
	
	if(myrank[x] < myrank[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(myrank[x] == myrank[y])myrank[x]++;
	}
}


signed main(){
	const int x = 0, y = 1;
	int N, M, count = 0;
	
	cin>>N>>M;
	
	init(N+3);
	
	rep(i, N){
		cin>>p[i];
	}
	
	rep(i, M){
		cin>>xy[x][i]>>xy[y][i];
		unite(xy[x][i],xy[y][i]);
	}
	
	for(int i = 1; i <= N; i++){
		if(same(i,p[i]))count++;
	}
	
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 5632
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000
#define INF 0x3FFFFFFF
using namespace std;
typedef long long LL;
struct node
{
	int to,w;
	node *nxt;
}edges[MAXN*2+5];
node *ncnt=&edges[0],*Adj[MAXN+5];
int zx,zx2,zxsiz=INF,cnt=0;
int siz[MAXN+5],fa[MAXN+5],N;
LL ans;
void AddEdge(int u,int v,int w)
{
	node *p=++ncnt;
	p->to=v;
	p->w=w;
	p->nxt=Adj[u];
	Adj[u]=p;
	
	node *q=++ncnt;
	q->to=u;
	q->w=w;
	q->nxt=Adj[v];
	Adj[v]=q;
}
void DFS1(int u,int f)
{
	siz[u]=1;
	for(node *p=Adj[u];p!=NULL;p=p->nxt)
	{
		int v=p->to;
		if(v==f)
			continue;
		fa[v]=u;
		DFS1(v,u);
		siz[u]+=siz[v];
	}
}
void DFS2(int u,int fa)
{
	for(node *p=Adj[u];p!=NULL;p=p->nxt)
	{
		int v=p->to,w=p->w;
		if(v==fa)
			continue;
		DFS2(v,u);
		ans+=2LL*min(1LL*siz[v],1LL*N-1LL*siz[v])*w;
	}
}
int main()
{
	scanf("%d",&N);
	int u,v,w;
	for(int i=1;i<N;i++)
	{
		scanf("%d %d %d",&u,&v,&w);
		AddEdge(u,v,w);
	}
	DFS1(1,-1);
	int maxsizn=-1;
	for(int u=1;u<=N;u++)
	{
		maxsizn=N-siz[u];
		for(node *p=Adj[u];p!=NULL;p=p->nxt)
		{
			int v=p->to;
			if(v==fa[u])	continue;
			maxsizn=max(maxsizn,siz[v]);
		}
		if(maxsizn<zxsiz)
			zxsiz=maxsizn,zx=u,cnt=1;
		else if(maxsizn==zxsiz)
			zx2=zx,zx=u,cnt++;
	}
	DFS2(1,-1);
	if(cnt==1)
	{
		int minval=INF;
		for(node *p=Adj[zx];p!=NULL;p=p->nxt)
		{
			int w=p->w;
			minval=min(minval,w);
		}
		ans-=1LL*minval;
	}
	else if(cnt==2)
		for(node *p=Adj[zx];p!=NULL;p=p->nxt)
		{
			int v=p->to,w=p->w;
			if(v==zx2)
			{
				ans-=1LL*w;
				break;
			}
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long int a,b,x;
  cin>>a>>b>>x;
  if(x<b){
  cout<<(a*x)/b;
  
  }else{
    
      cout<<(a*(b-1))/b;
    }
  
  }
  



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int A, B;
    cin >> A >> B;
    if (1 <= A && A <= 9 && 1 <= B && B <= 9) {
        cout << A * B << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long;
int main() {
	// your code goes here
	string str;
	cin>>str;
	int l=str.length();
	if(str[l-1]=='s')
	str+="es";
	else
	str+='s';
	cout<<str<<"\n";
	return 0;
}

Measured memory_bytes: 3632
import collections

n = int(input())
a = list(map(int, input().split()))

C = collections.Counter(a)

ans = [0] * (10 ** 6)
cnt = 0
# print(C)
for i, j in C.items():
    cnt += j * (j - 1) // 2

# print(ans)
# print(cnt)
for i in range(len(a)):
    if C[a[i]] > 0:
        print(cnt - (C[a[i]]-1))
    else:
        print(cnt)


Measured memory_bytes: 29240
#import pysnooper
#import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())

if n==1 or n==2:
    print(n)
    exit()
s=0
for i in range(1,n+1):
    s+=i
    if s>=n:
        ans=[x for x in range(1,i+1) if x!=s-n]
        break
for i in ans:
    print(i)

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <map>


int main(int argc, char const *argv[]) {
    std::string w;
    std::cin >> w;
    std::map<char, int> mp;
    for (int i = 0; i < w.length(); i++) {
        auto iter = mp.find(w[i]);
        if (iter == mp.end()) {
            mp[w[i]] = 1;
        } else {
            mp[w[i]] += 1;
        }
    }

    bool beautiful = true;
    for (auto iter = mp.begin(); iter != mp.end(); ++iter) {
        // std::cout << iter->first << ":" << iter->second << std::endl;
        if (iter->second % 2 != 0) {
            beautiful = false;
            break;
        }
    }

    if (beautiful) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i, sz(v)) { if (i) os << " "; os << v[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a - mod; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
      solve();
    }
}


void solve() {
  int n, m;
  cin >> n >> m;
  if (n % m == 0) cout << -1 << endl;
  else cout << n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <cmath>
#include <complex>

using namespace std;

#define INFD numeric_limits<double>::infinity()
#define INFL (int)1e8
#define INFLL (long long)1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define rnd(d) (ll)((double)d + ((d >= 0) ? 0.5 : -0.5))
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

/*******************************************************/

int main() {
  int n; cin >> n;
  vll a(n), b(n);
  Loop(i, n) cin >> a[i];
  Loop(i, n) cin >> b[i];
  sort(b.begin(), b.end());
  vvll d(32, vll(n));
  Loop(k, 32) {
    Loop(i, n) {
      d[k][i] = b[i] % (1 << (k + 1));
    }
    sort(d[k].begin(), d[k].end());
  }
  ll ans = 0;
  Loop(k, 32) {
    int buf = 0;
    Loop(i, n) {
      ll c = a[i] % (1 << (k + 1));
      ll t = 1 << k;
      int index[4];
      index[0] = lower_bound(d[k].begin(), d[k].end(), t - c) - d[k].begin();
      index[1] = lower_bound(d[k].begin(), d[k].end(), t * 2 - c) - d[k].begin() - 1;
      index[2] = lower_bound(d[k].begin(), d[k].end(), t * 3 - c) - d[k].begin();
      index[3] = lower_bound(d[k].begin(), d[k].end(), t * 4 - c) - d[k].begin() - 1;
      int cnt = index[1] - index[0] + index[3] - index[2] + 2;
      buf ^= cnt % 2;
    }
    ans += buf * (1 << k);
  }
  cout << ans << endl;
}

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

int w[103];

int main()
{
	int n, t;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> w[i];
	}
	int c = 10000000;
	for (t = 0; t < n; ++t)
	{
		int s1 = 0;
		int s2 = 0;
		for (int i = 0; i <= t; ++i)
		{
			s1 = s1 + w[i];
		}
		for (int i = t + 1; i <= n; ++i)
		{
			s2 = s2 + w[i];
		}
		c = min(c, abs(s1-s2));
	}
	cout << c;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char
import Data.Ord
import Data.Array.IO

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

f s = f' 0 0 s
  where
    f' rect rhom [] = [rect, rhom]
    f' rect rhom ([a,b,c]:ss)
      | a^2 + b^2 == c^2 = f' (rect+1) rhom ss
      | a == b = f' rect (rhom+1) ss
      | otherwise = f' rect rhom ss

main = map (map readInt . wordsBy (==',')) . lines <$> getContents >>= mapM_ print . f

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

int main() {
	ll n,x;cin>>n>>x;
  	vector<ll> a(n);for(int i=0;i<n;i++) cin>>a[i];
  	sort(a.begin(),a.end());
  	for(int i=0;i<n;i++){
    	x-=a[i];
      	if(x<0){
        	cout<<i<<endl;
          	return 0;
        }
    }
  	if(x==0){
    	cout<<n<<endl;
    }else{
    	cout<<n-1<<endl;
    }
}

Measured memory_bytes: 256
l, r = list(map(int, input().split()))
ans = 2019
if r-l+1 >= 2019:
    ans = 0
else:
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            pmod = i*j % 2019
            if pmod < ans:
                ans = pmod
print(ans)

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

using namespace std;

int main() {
	string abc = "abcdefghijklmnopqrstuvwxyz";
	string s;
	cin >> s;
	long long int sz = s.size();
	vector<long long int> d(sz);
	for (long long int i = 0; i < sz; i++) {
		for (long long int j = 0; j < abc.size(); j++) {
			if (s[i] == abc[j]) {
				d[i] = j;
				break;
			}
		}
		//cout << d[i] << endl;
	}
	long long int k;
	cin >> k;
	for (long long int i = 0; i < sz; i++) {
		if (k > 0) {
			if (d[i] != 0 && k >= 26-d[i]) {
				k -= 26-d[i];
				d[i] = 0;
			}
			//cout << d[i] << endl;
		}
	}
	k %= 26;
	d[sz-1] += k;
	d[sz-1] %= 26;
	for (long long int i = 0; i < sz; i++) {
		cout << abc[d[i]];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,i,j,l=1;
  cin >> a >> b;
  j = a;
  if(b==1) l=0;
  else{
    while(j<b){
        j = j + a -1;
        ++l;
    }
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

ll combination(ll a){
  ll ret = a*(a-1)/2;
  return ret;
}
int main(){
  int n; cin >> n;
  vector<ll> a(n),b(n+1);
  rep(i,n) cin >> a[i];
  b[0] = 0;
  rep(i,n){
    b[i+1] = b[i]+a[i];
  }
  map<ll,ll> mp;
  rep(i,n+1){
    ll tmp = b[i];
    mp[tmp]++;
  }
  
  ll ans = 0;
  for(auto m:mp){
    if(m.second > 1) ans += combination(m.second);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define pb push_back
#define fi first
#define se second
 
const ll MOD = 1000000007;
const string RGB = "RGB"; 

int main() {
   int N, D; scanf("%d%d", &N, &D);
   printf("%d", (N + 2 * D) / (2 * D + 1));
   return 0;
}

Measured memory_bytes: 256
import math
import itertools

n=int(input())

d={}
for i in range(n):
    d[i] = tuple(map(int,input().split()))

def calc(a,b):

    x,y = d[a] 
    xx,yy = d[b]

    return math.sqrt((x-xx)**2 + (y-yy)**2)

res=0
for i in itertools.permutations(range(n)):


    for  j in range(n-1):
        res+= calc(i[j],i[j+1])


print(res/math.factorial(n))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

#include <map>
#include <set>
#include <queue>
#include <stack>

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int pls(char c){
	return c == 'A' ? 1 : 2;
}

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

	string S,T;
	cin >> S >> T;

	int sz = S.size();
	int x[sz+1];
	x[0] = 0;

	rep(i,sz){
		x[i+1] = x[i] + pls(S[i]);
	}

	int tz = T.size();
	int y[tz+1];
	y[0] = 0;

	rep(i,tz){
		y[i+1] = y[i] + pls(T[i]);
	}

	int q;
	cin >> q;

	rep(i,q){
		int a,b,c,d;
		cin >> a >> b >> c >> d;

		int xx = x[b] - x[a-1];
		int yy = y[d] - y[c-1];
		if(xx % 3 == yy % 3) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 1744
#include<bits/stdc++.h>
#define N 1005
using namespace std;
string s;
int ans;
int main()
{
    cin>> s;
    for(int i=0; i<s.length(); i++){
        if(s[i] == '+')
            ans++;
        else
            ans--;
    }
    cout<< ans;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split()))
d.sort()
if n % 2 == 1:
    print(0)
    exit()
half = n // 2
if d[half] == d[half - 1]:
    print(0)
    exit()
else:
    print(d[half] - d[half - 1])


Measured memory_bytes: 52780
def main():
    s = input().strip()
    N = len(s)
    check = [False] * N
    ans = N
    for i in range(N):
        now = s[i] # now: 検索対象
        # print("="*10)
        # print(now)
        max_ = N-1-i
        count = 0
        for j in range(i+1):
            if s[j] != now:
                count += 1
                # print(j, s[j], count)
            else:
                # print(j, s[j], count)
                max_ = max(max_, count)
                count = 0
        ans = min(ans, max_)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN2(a,b);
  OUT(max({2*a-1, 2*b-1, a+b}));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }



signed main(){

    int N, A, B, C; cin >> N >> A >> B >> C;
    vec l(N); readv(l);

    vec v(N, 0);
    int ans = INF;
    while(v[0] < 4){

        vec L(3, 0);
        int tmp = -30;
        REP(i, N) if(v[i] != 3){
            tmp += 10;
            L[v[i]] += l[i];
        }
        if(L[0] > 0 && L[1] > 0 && L[2] > 0){
            tmp += llabs(L[0] - A) + llabs(L[1] - B) + llabs(L[2] - C);
            Min(ans, tmp);
        }

        int n = N - 1;
        v[n]++;
        while(n >= 1 && v[n] >= 4){
            v[n] = 0;
            n--;
            v[n]++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
dp = [float("Inf")]*(n+1)
for i in range(min(6, n+1)):
    dp[i] = i
for i in range(n):
    for j in range(1,n//6+1):
        if i + 6**j > n:
            break
        dp[i+6**j] = min(dp[i+6**j], dp[i] + 1)
    for j in range(1,n//9+1):
        if i + 9**j > n:
            break
        dp[i+9**j] = min(dp[i+9**j], dp[i] + 1)
print(dp[-1])

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, h, w;

int main() {
	cin >> n >> h >> w;
	
	int ans = 0;
	inc(i, n) {
		int a, b;
		cin >> a >> b;
		if(h <= a && w <= b) { ans++; }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

int main(){
    long long n, m, q;
    cin >> n >> m >> q;
    vector<vector<long long> > a(n + 1);
    long long l, r;
    for(int i = 0; i < m; ++i){
        cin >> l >> r;
        a[l].push_back(r);
    }
    for(int i = 1; i <= n; ++i) sort(a[i].begin(), a[i].end());

    
    for(int i = 0; i < q; ++i){
        long long ans = 0;
        cin >> l >> r;
        for(int j = l; j <= r; ++j){
            ans += upper_bound(a[j].begin(), a[j].end(), r) - a[j].begin();
        }
        cout << ans << endl;
    }

}

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

int main(){
  int n;
  cin >> n;
  set<char> st;
  for(int i = 0 ; i < n ; i++){
    char c;
    cin >> c;
    st.insert(c);
  }
  if(st.size() == 3){
    cout << "Three" << endl;
  }else{
    cout << "Four" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    n = input().replace("\n", "")
    s = len(n)
    sub = 0
    for i in range(s):
        sub += int(n[i])
        sub %= 9
    if sub:
        print("No")
    else:
        print("Yes")
    
    
if __name__ == "__main__":
    main()


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



int main() {
	
	
	int n,k; cin >> n >> k;
	
	vector<int> a(n); rep(i,n) cin >> a[i];

	int l = n-k;
	rep(i,l){
		if(a[i] < a[k+i]) cout << "Yes" << endl;
		else cout << "No" << endl;
		//cout << a[i] << " " << a[k+i] << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 4056
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    long long N;
    cin >> N;
    vector<long long> a(N),S(N);
    for (long long i=0; i<N; i++) {
        cin>>a[i];
    }
    
    // 累積和を計算
    S[0]=a[0];
    for (int i=1; i<N; i++) {
        S[i] = S[i-1] + a[i];
    }
    
    
    // 偶数番目が正
    long long ans1=0;
    for (long long i=0; i<N; i++) {
        if (i%2==1 && S[i]>=0) {
            ans1+=abs(S[i])+1;
            S[i]=-1;
        }
        else if (i%2==0 && S[i]<=0){
            ans1+=abs(S[i])+1;
            S[i]=1;
        }
        
        if (i!=N-1) {
            S[i+1]=S[i]+a[i+1];
        }
    }
    
    // 累積和を計算
    S[0]=a[0];
    for (int i=1; i<N; i++) {
        S[i] = S[i-1] + a[i];
    }
    
    // 奇数番目が正
    long long ans2=0;
    for (long long i=0; i<N; i++) {
        if (i%2==0 && S[i]>=0) {
            ans2+=abs(S[i])+1;
            S[i]=-1;
        }
        else if (i%2==1 && S[i]<=0){
            ans2+=abs(S[i])+1;
            S[i]=1;
        }
        
        if (i!=N-1) {
            S[i+1]=S[i]+a[i+1];
        }
    }
    
    if (ans1<ans2) {
        cout << ans1 << endl;
    }
    else{
        cout << ans2 << endl;
    }
}


Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for i in range(Q)]

total = sum(A)
from collections import Counter
counter = Counter(A)

for b, c in BC:
    total += (c-b) * counter[b]
    counter[c] += counter[b]
    counter[b] = 0
    print(total)

Measured memory_bytes: 104016
N = int(input())
B = [int(i) for i in input().split(' ')]
A = [0] * N

A[0] = B[0]
for i in range(1,N-1):
    A[i] = min(B[i-1],B[i])
A[N-1] = B[N-2]

print(sum(A))

Measured memory_bytes: 3064
import java.io.*;

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

		BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
		boolean sift[] = new boolean[1000000];
		int prim[] = new int[1000000];
		int cnt=0;
		String str;

		sift[0] = false;
		sift[1] = false;
		prim[0]=0;

		for(int i = 2;i < 1000000;i++){
			sift[i] = true;
		}

		for(int i = 1;i < 1000000;i++){
			if(sift[i] == true){
				cnt++;
				for(int j = i*2;j < 1000000;j+=i){
					sift[j]=false;
				}
			}
		prim[i]=cnt;
		}

		while((str = in.readLine()) != null){
			System.out.println(prim[Integer.parseInt(str)]);
		}
	}
}

Measured memory_bytes: 26280
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define mod 1000000007
#define mod1 1000000009
#define mod2 1000000021
#define INF 500001
#define MAX 1000000001
using namespace std;

/* 🐣🐥 */
int deg[100001], dp[100001];
queue<int> q;
vector<int> vec[100001];
int main() {
	int n, m, a, b, ans = 0;
	scanf("%d %d", &n, &m);
	while (m--) {
		scanf("%d %d", &a, &b);
		vec[a].push_back(b);
		deg[b]++;
	}
	for (int i = 1; i <= n; i++) {
		if (!deg[i]) q.push(i);
	}
	while (!q.empty()) {
		int cur = q.front();
		q.pop();
		for (int v : vec[cur]) {
			deg[v]--;
			dp[v] = max(dp[v], dp[cur] + 1);
			ans = max(dp[v], ans);
			if (deg[v] == 0) q.push(v);
		}
	}
	printf("%d", ans);

	return 0;
}

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

int main() {
  int a[3]={},n;
  cin >> n;
  r(i,n){
    int b;
    cin >> b;
    if(b%4==0)a[2]++;
    else if(b%2==0)a[1]++;
    else a[0]++;
  }
  if(a[0]>a[2]+1)cout<<"No"<<endl;
  else if(a[0]==a[2]+1&&a[1]>0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        s: Chars,
        t: Chars
    };

    let mut res = 0;
    for i in 0..s.len() {
        if s[i] != t[i] {
            res += 1;
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 3004
n = input()
s = str(input())
n = int(n)

ans_count =0

for i in range(10):
    for j in range(10):
        for k in range(10):
            i_pos = s.find(str(i))

            if i_pos < 0:
                continue

            j_pos = s.find(str(j),i_pos+1)

            if j_pos < 0:
                continue

            k_pos = s.find(str(k), j_pos +1)

            if k_pos < 0:
                continue

            ans_count += 1

print(ans_count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  if((a*b)%2 == 0) cout << "No" << endl;
  else cout << "Yes" << endl;
  
  return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define INV(a,n) REP(i,n){\
	lli TMP;\
	cin>>TMP;\
	a.push_back(TMP);\
}

lli max(lli a,lli b){
	return a>=b ? a:b;
}

int main(){

	lli n;
	vector<lli> a;
	vector<lli> b;

	cin>>n;
	INV(a,n);
	INV(b,n);
	lli ans=0;

	REP(i,n){
		int flag=0;
		lli sum=0;
		REP(j,n){
			if(flag==0){
				sum+=a.at(j);
			}
			else{
				sum+=b.at(j);
			}
			if(j==i){
				sum+=b.at(j);
				flag=1;
			}
		}
		ans = max(sum,ans);
	}
	cout<<ans<<endl;



	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define min(p,q)((p)<(q)?(p):(q))
#define zahyoutype long

typedef struct Point{zahyoutype x,y;}P;
zahyoutype crossproduct(P p,P q,P o){return (p.x-o.x)*(q.y-o.y)-(p.y-o.y)*(q.x-o.x);}
void readpoint(P*p){zahyoutype x=1;scanf(x/2?"%lf%lf":"%ld%ld",&p->x,&p->y);}

int main(){
	int q;
	scanf("%d",&q);
	P o,p1,p2;
	readpoint(&o);
	readpoint(&p1);
	q-=2;
	zahyoutype s=0;
	while(q--){
		readpoint(&p2);
		s+=crossproduct(p1,p2,o);
		p1=p2;
	}
	printf("%.1f\n",fabs(s/2.0));
}


Measured memory_bytes: 2148
n=gets.to_i
a=gets.split.map(&:to_i)
l=[0]*1000001
a.each do |aa|
  l[aa]+=1
end
c=n
a.uniq.sort.each do |aa|
  i=aa
  if l[i]>1
    c-=l[i]
  elsif l[i]==0
    next
  end
  i+=aa
  while i<=1000000
    if l[i]>0
      c-=l[i]
      l[i]=0
    end
    i+=aa
  end
end
puts c


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

int main(){
  int n;
  cin >> n;
  
  if(n == 1){
    cout << "Hello World" << endl;
  } else{
    int a, b;
    cin >> a >> b;
    
    cout << a + b << endl;
  }
  
  return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
vector<int> G[100010];
int depth[100010];
int in[100010];
int parent[100010];
void Calc(){
	int N = rei();
	int M = rei();
	for(int i=0;i<N+M-1;i++){
		int a = rei()-1;
		int b = rei()-1;
		G[a].push_back(b);
		in[b]++;
	}
	stack<int> sp;
	for(int i=0;i<N;i++){
		if(in[i] == 0){
			sp.push(i);
			parent[i] = -1;
		}
	}
	while(!sp.empty()){
		int v = sp.top();
		sp.pop();
		for(int t : G[v]){
			if(depth[t] < depth[v]+1){
				parent[t] = v;
				depth[t] = depth[v]+1;
			}
			in[t]--;
			if(in[t] == 0){
				sp.push(t);
			}
		}
	}
	for(int i=0;i<N;i++){
		cout << parent[i]+1 << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

int main() {
    long long N;
    cin >> N;
    string ans;
    long long i = 1;
    while (N > 0) {
        N--;
        ans = char ('a' + (N % 26)) + ans;
        N /= 26;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
X, Y = map(int, input().split())

max_legs = 4 * X

if max_legs < Y:
    print("No")
    exit()

legs = max_legs

for i in range(X+1):
    legs = i * 2 + (X-i) * 4
    if legs == Y:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  ll x;
  cin >> x;
  ll n_500, n_5;
  n_500 = x / 500;
  x -= n_500 * 500;
  n_5 = x / 5;
  ll ans = 0;
  ans = n_500 * 1000 + n_5 * 5;
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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

#define rep(i, n) for(ll i=0; i<n; i++)
#define all(v) v.begin(), v.end()
#define vec vector

typedef long long ll;

/*  <<bit全探索>>

    for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
        bitset<ビット数> s(tmp);
    }
*/

/*　<<stringで読み込んだ数列を一桁ずつint型へ変換>>

    string str;
    int N[桁数];

    cin >> str;

    for (int i = 0; i < 15; ++i) {

        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換

        //cout << N[i] << endl;  //確認のため表示
    }
*/

int main(){
    
    int N;
    cin >> N;
    
    vec<string> K(N);
    rep(i, N){
        cin >> K.at(i);
    }
    
    sort(all(K));
    
    int dup = 0;
    rep(i, N - 1){
        if(K.at(i) != K.at(i + 1)){
            dup++;
        }
    }


    cout << dup + 1 << endl;
}

Measured memory_bytes: 9596
import math
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

x=[i for i in range(2,55556)if is_prime(i)and i%5==1]
print(*x[:int(input())])

Measured memory_bytes: 3060
#include <cstdio>
int n, b[100009]; long long a[100009];
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%lld%d", &a[i], &b[i]);
	long long ret = 0;
	for(int i = n - 1; i >= 0; i--) {
		long long d = (a[i] + ret) % b[i];
		if(d) ret += b[i] - d;
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 1408