akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define US unordered_set
#define ALL(a) (a).begin(),(a).end()
const ll INF = (1ll << 60);

bool hasCycle(vvi &G) {
  ll V=G.size();
  REP(i,V) {
    vi visited(V);
    queue<ll> q; q.push(i);
    visited[i]=1;
    while(q.size()) {
      ll from=q.front();
      q.pop();
      for(ll to:G[from]) {
        if(to==i) return true;
        if(!visited[to]) {
          visited[to]=1;
          q.push(to);
        }
      }
    }
  }
  return false;
}

int main(){
  ll V,E; cin>>V>>E;
  vvi G(V);
  REP(i,E) {
    ll s,t; cin>>s>>t;
    G[s].PB(t);
  }
  if(hasCycle(G)) cout<<1<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

LLI dp[5][200100];

LLI cost(LLI c, int p){
  if(p == 0 or p == 4) return c;
  else if(p == 1 or p == 3) return c==0 ? 2 : c%2;
  return 1-(c%2);
}

const LLI inf = LLONG_MAX / 2;


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

  int N;
  while(cin >> N){
    vector<LLI> A(N); cin >> A;

    fill_array(dp, inf);

    dp[0][0] = 0;
    
    REP(i,N){
      
      REP(j,5){
        REPE(k,j){
          chmin(dp[j][i+1], dp[k][i] + cost(A[i],j));
        }
      }
    }

    LLI ans = inf;

    REP(i,5){
      chmin(ans, dp[i][N]);
    }
    
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 9600
import java.util.*;

public class Main {
	
	static Set<String> permutations = new HashSet<String>();
	static int N;
	static char base[]; 
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		int M = sc.nextInt();
		int to [][] = new int[N+1][N+1];
		for(int i=0;i<M;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			to[a][b] = 1;
			to[b][a] = 1;
		}
		sc.close();
			
		//1~Nの順列を全列挙する。
		
		StringBuilder sb = new StringBuilder();
 
		
		base = new char[N];
		for(int i=1;i<=N;i++) base[i-1]= (char)(i+'0');
		
		for(int i=0;i<N;i++) {
			char start[] = new char[N];
			start[0] = base[i];
			dfs(start);
		}
		
		int cnt = 0;
		//search all permutations
		for(String tmp : permutations) {
			int len = tmp.length();
			for(int i=0;i<len-1;i++) {
				int now = tmp.charAt(i)-'0';
				int next = tmp.charAt(i+1)-'0';
				if(i==0) {
					if (now !=1)break;
				}
				if(to[now][next]==0)break;
				if(i==len-2) cnt++;
			}
		}
		System.out.println(cnt);
//		System.out.println(permutations.size());

//		for(String tmp : permutations) {
//			System.out.println(tmp);
//		}
		
	}
	
	static void dfs(char c[]) {
		if(finished(c)) {
			permutations.add(new String(c));
			return;
		}
		for(int i=0;i<N;i++) {
			char nextChar = base[i];
			if(isContain(c, nextChar)) continue;
			char nextC[] = c.clone();
			nextC[depth(c)]=nextChar;
			dfs(nextC);
		}
	}
	
	static boolean isContain(char target[], char c) {
		for(char t :target) if(c==t) return true;
		return false;
	}
	
	static boolean finished(char target[]) {
		if(isContain(target, '\u0000'))return false;
		return true;
	}
	
	static int depth(char target[]) {
		int cnt = N;
		for(char t:target) {
			if(t=='\u0000')cnt--;
		}
		return cnt;
	}
	
}


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

int check(string s, char c) {
  int len = s.length(), count = 0;
  for (int i = 0; i < len; ++i) {
    if (c == s[i]) {
      ++count;
      c = (c == '1' ? '0' : '1');
    } else {
      c = s[i];
    }
  }
  return count;
}

int main(void){
  string s;
  cin >> s;
  int count1 = check(s, '0');
  int count2 = check(s, '1');
  cout << (count1 < count2 ?  count1 : count2) << endl;
}


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

int main()
{
    int n;
    int tmp;
    cin >> n;
    vector<int> a;
    
    for(int i=0; i < n; i++){       
        cin >> tmp;
        a.push_back(tmp);
    }
    
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
      
    cout << a.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long 
int N;
int T[13];
bool used[48];
int ans;
std::vector<int> t;
void dfs(int n) {
	if (n == t.size()) {
		int res = 100;
		std::vector<int> copy = t;
		std::sort(copy.begin(), copy.end());
		for (int i = 1; i < copy.size(); i++) {
			res = std::min(res, copy[i] - copy[i - 1]);
		}
		res = std::min(res, copy[0] + 24 - copy[copy.size()-1]);
		ans = std::max(res, ans);
		return;
	}
	dfs(n + 1);
	t[n] = 24 - t[n];
	dfs(n + 1);
	t[n] = 24 - t[n];
	return;
}
int main() {
	T[0]++;
	std::cin >> N;
	if (N == 1) {
		int tmp;
		std::cin >> tmp;
		std::cout << tmp << std::endl;
		return 0;
	}
	for (int i = 1; i <= N; i++) {
		int tmp;
		std::cin >> tmp;
		T[tmp]++;
	}
	if (T[0] > 1 || T[12] > 1) {
		std::cout << 0 << std::endl;
		return 0;
	}
	for (int i = 0; i <= 12; i++) {
		if (T[i] >= 1)t.emplace_back(i);
		if (T[i] >= 2)t.emplace_back(i);
		if (T[i] >= 3) {
			std::cout << 0 << std::endl;
			return 0;
		}
	}
	dfs(1);
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
import math
n,d = map(int,input().split())
point_list = [0,0]*n
for i in range(n):
    point = list(map(int,input().split()))
    point_list[i]=point
count = 0

for j in range(n):
    distance = math.sqrt(point_list[j][0]**2 + point_list[j][1]**2)
    if distance <= d:
        count += 1

print(count)

Measured memory_bytes: 46888
#include <iostream>
using namespace std;
int main(){
    int c, m, r, t;
    char s;

  while(1) {
    cin >> c >> m >> r;

    if(c < 0 && m < 0 && r < 0) break;

    t = c + m;
    if(c < 0 || m < 0) { s = 'F';
    } else if(t >= 80) { s = 'A';
    } else if(t >= 65) { s = 'B';
    } else if(t >= 50) { s = 'C';
    } else if(t < 30) { s = 'F';
    } else if(r >= 50) { s = 'C';
    } else { s = 'D'; }

    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <functional>
#include <numeric>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <stdio.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

int n, k, a[100005];
vector<int> gph[1000005];
int dep[100005], dfn[100005], sz[100005], piv;
int par[30][100005];

void dfs(int x){
	sz[x] = 1;
	dfn[x] = ++piv;
	for(auto &i : gph[x]){
		dep[i] = dep[x] + 1;
		dfs(i);
		sz[x] += sz[i];
	}
}

struct bit{
	int tree[100005];
	void add(int x, int v){
		while(x <= n){
			tree[x] += v;
			x += x & -x;
		}
	}
	int query(int x){
		int ret = 0;
		while(x){
			ret += tree[x];
			x -= x & -x;
		}
		return ret;
	}
}bit;

int main(){
	cin >> n >> k;
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	int ret = 0;
	if(a[1] != 1){
		ret++;
		a[1] = 1;
	}
	for(int i=2; i<=n; i++){
		gph[a[i]].push_back(i);
	}
	dfs(1);
	vector<pi> v;
	for(int i=1; i<=n; i++){
		v.push_back(pi(dep[i], i));
		par[0][i] = a[i];
	}
	for(int i=1; i<30; i++){
		for(int j=1; j<=n; j++){
			par[i][j] = par[i-1][par[i-1][j]];
		}
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for(auto &i : v){
		int p = i.second;
		if(bit.query(dfn[p])) continue;
		for(int i=29; i>=0; i--){
			if((k-1) & (1<<i)){
				p = par[i][p];
			}
		}
		if(a[p] == 1) continue;
		bit.add(dfn[p], 1);
		bit.add(dfn[p] + sz[p], -1);
		ret++;
	}
	cout << ret<< endl;
}



Measured memory_bytes: 44532
program make_them_even
  implicit none
  integer :: h, w, a(500,500) = -1, i, j, l, r, s, m = 0
  integer, dimension(250000) :: x1 = 0, y1 = 0, x2 = 0, y2 = 0
  read(*,*) h, w
  do i = 1, h
    read(*,*) a(i,1:w)
  end do
  l = 1
  r = w
  s = 1
  do i = 1, h
    do j = l, r, s
      if (mod(a(i,j),2) == 0) cycle
      if (j == r .and. i /= h) then
        m = m+1
        x1(m) = i
        y1(m) = j
        x2(m) = i+1
        y2(m) = j
        a(i,j) = a(i,j)-1
        a(i+1,j) = a(i+1,j)+1
      else if (j /= r) then
        m = m+1
        x1(m) = i
        y1(m) = j
        x2(m) = i
        y2(m) = j+s
        a(i,j) = a(i,j)-1
        a(i,j+s) = a(i,j+s)+1
      end if
    end do
    l = w+1-l
    r = w+1-r
    s = -s
  end do
  write(*,'(i0)') m
  do i = 1, m
    write(*,'(i0,x,i0,x,i0,x,i0)') x1(i), y1(i), x2(i), y2(i)
  end do
end program make_them_even

Measured memory_bytes: 6016
// {{{ by shik
// #include <stdio.h>
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const long long &x ) { printf("%" PRId64,x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

template<typename T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

int main() {
    LL n,a,b;
    R(n,a,b);
    LL l=(n-1)*a+b,r=(n-1)*b+a;
    LL ans=max(0LL,r-l+1);
    W(ans);
    return 0;
}


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

int main() {
  int N,x;
  cin >> N >> x;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  int i=0;
  for(i;i<N-1;i++){
    if(A.at(i)<=x){
      x-=A.at(i);      
    }else{
      break;
    }
  }
  if(x==A.at(N-1)){
    i++;
  }
  
  cout << i << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  cout << (n-2)*180 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

double dist(int *a, int *b, int d){
	int i, sum=0;
	for(i=0;i<d;i++){
		sum += pow(abs(a[i]-b[i]), 2);
	}
	return sqrt(sum);
}

int main(){
	int n, d, x[10][10], i, j, count=0;
	double delta;
	scanf("%d %d", &n, &d);
	for(i=0;i<n;i++){
		for(j=0;j<d;j++){
			scanf("%d", &x[i][j]);
		}
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			delta = dist(x[i], x[j], d);
			if(delta*delta == (int)delta*(int)delta) count++;
		}		
	}
	printf("%d", count);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,x,y=0,n;
  cin>>a>>b>>x;
  if(a+b==x || a+x==b || b+x==a)
  	cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    if (n % 2 == 1) {
        cout << "No\n";
        exit(0);
    }
    string s; cin >> s;
    int half = n / 2;
    for (int i = 0; i < half; i++) {
        if (s[i] != s[i + half]) {
            cout << "No\n";
            exit(0);
        }
    }
    cout << "Yes\n";
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int S,E,N,W;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>s;
	FORR(r,s) {
		if(r=='S') S++;
		if(r=='E') E++;
		if(r=='N') N++;
		if(r=='W') W++;
	}
	
	if(N&&S==0)return _P("No\n");
	if(S&&N==0)return _P("No\n");
	if(E&&W==0)return _P("No\n");
	if(W&&E==0)return _P("No\n");
	_P("Yes\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=9223372036854775806;
const int inf=2147483646;
int n,a[100000];

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	for (int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	cout<<(a[n>>1]-a[(n>>1)-1]);
	return 0;
}

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

int main() {
    int n;cin >> n;
    bool is_zero = false;
    vector<Int> a(n);
    rep(i, n) {
        cin >> a[i];
        if (a[i] == 0) {
            is_zero = true;
        }
    }
    if (is_zero) {
        cout << "0" << endl;
        return 0;
    }

    Int ans = 1;
    bool is_ng = false;
    rep(i, n) {
        //if (a[i] > (MX+1) / ans || ans * a[i] > MX) {
        if (a[i] > (MX) / ans) {
            is_ng = true;
            break;
        }
        ans *= a[i];
    }
    if (is_ng) cout << "-1" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
#define int long long
using namespace std;
const int N=1e5+100;
int n,m,v,p,a[N],sum[N],ans;
signed main()
{
	scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	for (int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
	a[n+1]=inf;
	for (int i=n;i>=1;i--)
	{
		if (i>=v)
		{
			int pos=upper_bound(a+1,a+2+n,a[i]+m)-a;
			if (n-pos+1<p) ans++;
		}
		else
		{
			int pos=upper_bound(a+1,a+2+n,a[i]+m)-a;
			if (n-pos+1>=p) continue;
			if (v-i-p+1<=0)
			{
				ans++;
				continue;
			}
			int cnt=v-i-p+1;
			int l=i+1,r=min(n-p+1,pos-1);
			if (r-l+1>=cnt && cnt*m<=(a[i]+m)*(r-l+1)-(sum[r]-sum[l-1])) ans++;
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 5292
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int main(){
  ll n;cin>>n;
  ll a[5];rep(i,5) cin>>a[i];
  ll mini=INFLL;
  rep(i,5){
    mini=min(mini,a[i]);
  }
  ll res=n/mini+5;
  if(n%mini==0) res--;
  prin(res);
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long int ll;

int main(){

    string s;
    cin >> s;
    
    for(ll i = 0; i < s.length(); i++){
        if(s[i] == s[i+1]){
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }

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

    }

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

} 

Measured memory_bytes: 512
#!/usr/bin/env python3
import math
import sys
readline = sys.stdin.buffer.readline


def calc_dist(x, y):
    return math.sqrt(x**2 + y**2)


N, D = map(int, readline().split())
count = 0

for _ in range(N):
    X, Y = map(int, readline().split())

    if calc_dist(X, Y) <= D:
        count += 1

print(count)


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

using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    if(n<1200)cout << "ABC" << endl;
    else if(n<2800)cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int A = scn.nextInt(), B = scn.nextInt(), C = scn.nextInt(), D = scn.nextInt(), E = scn.nextInt(), F = scn.nextInt();

		double ans  = -1;
		int water = 0, sugar = 0;
		
		
		for(int a = 0;a <= F/(A*100);a++) {
			for(int b = 0;b <= (F-100 * A * a)/(100 * B);b++) {
				for(int c = 0;c <= (F - 100 * A * a - 100 * B * b)/(C);c++) {
					for(int d = 0;d <= (F - 100 * A * a - 100 * B * b - C * c)/D;d++) {
						if(C*c+D*d > (A*a+B*b)*E || a+b==0)continue;
						double buf = (double)(C*c+D*d)/(double)(100 * (A*a+B*b) + C*c+D*d);
						if(buf > ans) {
							ans = buf;
							water = (A*a+B*b)*100;
							sugar = C*c+D*d;
						}
					}
				}
			}
		}

		System.out.println(water+sugar + " " + sugar);

	}

}


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

const long long INF = 1e18;

bool f(long long x, long long y, vector<long long> &A, int n) {
    long long s = 0;
    for (int i = 0; i < n; i++) {
        int l = -1, r = n;
        if (A[i] >= 0) {
            while (l+1 < r) {
                int m = (l+r) / 2;
                if (A[i]*A[m] < x) l = m;
                else r = m;
            }
            s += l+1;
        } else {
            while (l+1 < r) {
                int m = (l+r) / 2;
                if (A[i]*A[m] < x) r = m;
                else l = m;
            }
            s += n-r;
        }
        if (A[i]*A[i] < x) s--;
    }
    s /= 2;
    return s < y;
}

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    long long l = -INF-5, r = INF+5;
    while(l+1 < r) {
        long long m = (l+r) / 2;
        if (f(m, K, A, N)) l = m;
        else r = m;
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
 /* #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a,b;
  char c;
  cin>>a>>c>>b;
  if(c=='+')
  {
    cout<<a+b<<endl;
  }
  else
  {
    cout<<a-b<<endl;
  }
  
  
  

}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    int main()
    {
      vector<int> v;
      int x = 0;
      for(int i=0;i<3;i++)
      {
        cin >> x; v.push_back(x);
      }
      sort(v.begin(),v.end());
      if(v[0]==5 && v[1]==5 && v[2]==7){cout <<"YES"<<endl;}
      else{cout << "NO";}
    }
      

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

int main(){
    int n, w;
    cin >> n >> w;
    int weights[n];
    ll values[n];
    for(int i=0; i<n; i++)
        cin >> weights[i] >> values[i];

    ll dp[n+1][w+1];
    for(int i=0; i<=n; i++)
        dp[i][0] = 0;
    for(int j=0; j<=w; j++)
        dp[0][j] = 0;

    for(int i=1; i<=n; i++){
        for(int j=0; j<=w; j++){
            dp[i][j] = dp[i-1][j];
            if(weights[i-1] <= j && (dp[i][j] < dp[i-1][j-weights[i-1]] + values[i-1])){
              dp[i][j] = max(dp[i-1][j], values[i-1] + dp[i-1][j-weights[i-1]]);
            }
        }
    }

    cout << dp[n][w] << endl;
}


Measured memory_bytes: 79104
n,k = map(int,input().split())
s = list(input())

ans  = 0
tran = 0

for i in range(n-1):
    chk = s[i] + s[i+1]

    if chk == 'LR' or chk == 'RL':
        tran += 1
    else:
        ans += 1

if k*2 >= tran:
    print(n-1)
else:
    print(ans+(k*2))

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

#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    string s;
    string ans;
    rep(i,3) {
        cin >> s;
        ans += toupper(s[0]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
 * 500.cpp
 *
 *  Created on: 2012/06/24
 *      Author: shimomire
 */
#include <iostream>
#include<string>
#include <complex>
#include<list>
#include<float.h>
#include <functional>
#include <vector>
#include <map>
#include <queue>

using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define REP0(i,n)   REP(i,0,n)
#define foreach(it,o) for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
typedef complex<double> P;
bool operator <(const P& a, const P& b) {
	return abs(a) < abs(b);
}
int n;

int main(){
	while(true){
		cin >> n;
		if(n==0){
			break;
		}
		int ap=0,bp=0;
		REP0(i,n){
			int tmpa,tmpb;
			cin>> tmpa>> tmpb;
			if(tmpa>tmpb){
				ap+=tmpa+tmpb;
			}else if(tmpa< tmpb){
				bp+=tmpa+tmpb;
			}else{
				ap+=tmpa;
				bp+=tmpb;
			}
		}
		cout<< ap<< " "<< bp<< endl;
	}
}

Measured memory_bytes: 1160
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    ll n, m;
    cin >> n >> m;
    rep(i, m) {
        int day;
        cin >> day;
        n -= day;
    }
    if( n >= 0) {
        cout << n << endl;
    }else {
        cout << "-1" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

signed main(void) {
	int i, j, k, l;
	int W, H, T;
	int p;
	int x[55] , y[55] , t[55];
	int field[55][55];
	cin >> W >> H >> T;
	cin >> p;
	rep(i, p) {
		cin >> x[i] >> y[i] >> t[i];
	}
	rep(i, H) rep(j, W) {
		cin >> field[i][j];
	}
	int cnt = 0;
	rep(i, p) {
		if (field[y[i]][x[i]]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N;
  cin >> N;
  ll x;
  cin >> x;
  vector<int> a(N);
  rep(i, N)
  {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int counter = 0;
  for (int i = 0; i < N; i++)
  {
    if (x >= a[i])
    {
      x -= a[i];
      counter++;
    }
  }
  if (counter == N && x > 0)
  {
    counter--;
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#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++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる
//時間を意識しろ
//コードテストちゃんとして
//画面とにらめっこするな書け
//WA出すたびにABCは五億円払え
//わからない問題はとばせ
//躊躇なくぐぐれ

//ここから
int main(){
    long double a,b,x;
    cin>>a>>b>>x;
    if(x>=a*a*b/2.0){
        cout<<fixed<<setprecision(10)<<atan((2.0*a*a*b-2.0*x)/(a*a*a))*180.0/pi<<endl;
    }else{
        long double Ans;
        cout<<fixed<<setprecision(10)<<(pi/2.0-atan(2.0*x/(a*b*b)))*180.0/pi<<endl;
    }
}



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

int n, m, ct, val[40];
bool s;
char ans[40000];
long long get_dis(pair <int, int> x, pair <int, int> y)
{
	return (long long) abs(x.first - y.first) + abs(x.second - y.second);
}
int main()
{
	m = 32;
	val[1] = 1;
	for (int i = 2; i <= m; i++)
		val[i] = 1 << (i - 2);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		pair <int, int> now, goal, to;
		scanf("%d%d", &goal.first, &goal.second);
		if (i == 1) s = (goal.first + goal.second) & 1;
		else if (s != ((goal.first + goal.second) & 1))
		{
			puts("-1");
			return 0;
		}
		for (int j = m; j >= (s ? 2 : 1); j--)
		{
			char ch;
			long long mini = 0x3f3f3f3f3f3f3f3fLL, tmp;
			if (mini > (tmp = get_dis(goal, make_pair(now.first, now.second + val[j])))) ch = 'U', mini = tmp, to = make_pair(now.first, now.second + val[j]);
			if (mini > (tmp = get_dis(goal, make_pair(now.first, now.second - val[j])))) ch = 'D', mini = tmp, to = make_pair(now.first, now.second - val[j]);
			if (mini > (tmp = get_dis(goal, make_pair(now.first + val[j], now.second)))) ch = 'R', mini = tmp, to = make_pair(now.first + val[j], now.second);
			if (mini > (tmp = get_dis(goal, make_pair(now.first - val[j], now.second)))) ch = 'L', mini = tmp, to = make_pair(now.first - val[j], now.second);
			now = to;
			ans[++ct] = ch;
		}
		ans[++ct] = '\n';
	}
	printf("%d\n", m - s);
	for (int i = m; i >= (s ? 2 : 1); i--)
		printf("%d ", val[i]);
	puts("");
	for (int i = 1; i <= ct; i++)
		putchar(ans[i]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> t(s.size());
	REP(i, s.size()) {
		t[i] = s[i] - 'A';
		t[i] += n;
		t[i] = (t[i])%26;
		cout << (unsigned char)(t[i]+'A');
	}
	put("");
	return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

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

	int N=in();
	vector<int> dp(N+1,1e9+7);
	dp[0] = 0;
	for(int i=0;i<N;i++){
		// 1
		chmin(dp[i+1],dp[i]+1);
		// 6
		int v = N-i;
		int num = 0;
		while(v){
			num++;
			v /= 6;
		}
		for(int j=1,k=6;j<num;j++){
			chmin(dp[i+k],dp[i]+1);
			k *= 6;
		}
		// 9
		v = N-i;
		num = 0;
		while(v){
			num++;
			v /= 9;
		}
		for(int j=1,k=9;j<num;j++){
			chmin(dp[i+k],dp[i]+1);
			k *= 9;
		}
	}
	cout << dp[N] << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "random"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
main(){
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    int n=in;
    cout<<n*n;
}



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

const int MOD = (int)1e9+7;

int main(){
  int N;
  cin >> N;
  vector<int> a(3*N);
  for(int i=0;i<3*N;i++)  cin >> a.at(i);

  sort(a.begin(),a.end(),greater<int>());
  long long ans=0;
  for(int i=1;i<2*N;i+=2){
    ans+=(long long)a.at(i);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  ll N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  map<ll,ll> mp;
  rep(i,N) mp[A[i]]++;

  ll all=0;
  for(auto m:mp){
    ll val=m.second;
    all+=val*(val-1)/2;
  }

  for(int i=0;i<N;i++){
    ll val=mp[A[i]];
    ll diff=(val-1)*(val-2)/2-val*(val-1)/2;
    cout<<all+diff<<endl;
  }

  return 0;
}


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

int main()
{
    int N;
    map<string, int> B;
    int c;
    int res = 0;
    //int B[9][9];
    string a, b;
    //to_string(j)[0] == to_string(i % 10)[0]

    cin >> N;

    rep(i, N+1)
    {
        a = to_string(i)[0];
        b = to_string(i % 10)[0];
        //cout << a << " " << b << endl;
        ++B[a + b];
        //cout << a << " " << b << endl;
        //res += B[b + a];
    }
    rep(i, N+1)
    {
        a = to_string(i)[0];
        b = to_string(i % 10)[0];
        res += B[b + a];
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define rep(i, a, b) for(int i = (a); i < (b); ++i)

int main(){
    int A[3000], B[3000], count = 0;
    while(1){
        int x, y;
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0) break;
        A[count] = x;
        B[count] = y;
        count++;
    }

    rep(i, 0, count){
        if(A[i] > B[i]) printf("%d %d\n", B[i], A[i]);
        else printf("%d %d\n", A[i], B[i]);
    }

    return 0;
}



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

int main() {
  int N,A=0,B=0;
  cin >> N;
  
  vector<int>vec(N);
  vector<int>vec1(N/2);
  vector<int>vec2(N/2);
  
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  for(int j=0; j<N; j++){
    if(j%2 == 1){
      continue;
    }
    else{
      A=A+vec.at(j);
    }
  }
  
  for(int k=0; k<N; k++){
    if(k%2 == 0){
      continue;
    }
    else{
      B=B+vec.at(k);
    }
  }
  
  cout << A-B << endl;
}

Measured memory_bytes: 3616
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		char[] ID = scanner.next().toCharArray();
		int m = scanner.nextInt();

		int[] a = new int[m];
		for (int i = 0; i < m; i++)
			a[i] = scanner.nextInt();
		int[][] dp = new int[10][n + 1];
		dp[0][0] = 1;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < 10; j++) {
				if (ID[n - 1 - i] != '*')
					dp[(j + slove(i, ID[n - 1 - i] - '0')) % 10][i + 1] += dp[j][i];
				else
					for (int k = 0; k < m; k++)
						dp[(j + slove(i, a[k])) % 10][i + 1] += dp[j][i];
			}
		System.out.println(dp[0][n]);

	}

	private int slove(int p, int i) {
		int j = i * 2;
		return (p % 2 == 1) ? j / 10 + j % 10 : i;
	}
}

Measured memory_bytes: 28572
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x=0,y=0,t=0,a,b,c;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b>>c;
    if(a-t<abs(x-b)+abs(y-c)){
      cout<<"No";
      return 0;
    }else{
      if((a-t-(abs(x-b)+abs(y-c)))%2==1){
        cout<<"No";
        return 0;
      }else{
        t=a;
        x=b;
        y=c;
      }
    }
  }
  cout<<"Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
ll n,m,k,a,b,c,ans,fa[100001],ra[100001],L;
ll find(ll x){
    if(x==fa[x])return x;
    return fa[x]=find(fa[x]);
}
void uni(ll x,ll y){
    x=find(x),y=find(y);
    if(x==y)return ;
    if(ra[x]<ra[y])swap(x,y);
    fa[y]=x;
    if(ra[x]==ra[y])ra[x]++;
    return ;
}
int main(void){
    for(int i=0;i<100001;i++)fa[i]=i;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b>>c;
        if(a==0)uni(b,c);
        else{
            if(find(b)==find(c))cout<<1<<endl;
            else cout<<0<<endl;
        }
    }
}



Measured memory_bytes: 3964
n=int(input())
cnt_10=0
MAX_10=0
if n%2==1:
    print(0)
else:
    for i in range(100):
        if 2*5**i<=n and n<2*5**(i+1):
            MAX_10=i
            break
    for j in range(1,MAX_10+1):
        cnt_10+=n//(2*5**j)  
    print(cnt_10)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;
const int N=2e5+10;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()


#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
} 
int binomialCoeff(int n, int k)  
{
    if (k == 0 || k == n)  
        return 1;  

    return binomialCoeff(n - 1, k - 1) +  
                binomialCoeff(n - 1, k);  
}  
long long power(ll a, ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%MOD;
        b/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

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

vector<int>v[N];
ll sum[N];

void dfs(int n,int vis)
{
    for(int i=0;i<v[n].size();i++)
    {
        if(v[n][i]!=vis)
        {
            sum[v[n][i]]+=sum[n];
            dfs(v[n][i],n);
        }
    }
}


int main()
{
    IOS;
    ll n;
    cin>>n;
    cout<<(n*(n-1))/2<<endl;


}

Measured memory_bytes: 4992
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

int main() {
  ios::sync_with_stdio(false);
  ll N, K;
  cin >> N >> K;
  vector<PL> ops(N);
  FOR(op, ops) {
    cin >> op.first >> op.second;
  }
  sort(ops.begin(), ops.end());
  ll cnt = 0;
  FOR(op, ops) {
    cnt += op.second;
    if(cnt >= K) {
      cout << op.first << endl;
      break;
    }
  }
  return 0;
}


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

int count = 0;
int search(int n,int m,int i)
{
	
	if(n==0 && m==0){
		count++;
		return 1;
	}
	if(n==0 || i>=10){
		return 0;
		
	}
	search(n-1,m-i,i+1);
	search(n,m,i+1);
	return count;
}
int main()
{
	int n,m;
	while(cin >> n >> m){
		if(n == 0 && m == 0)
			break;
		count = 0;
		cout << search(n,m,0) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
typedef long long int ll;
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fora(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define mp make_pair 
#define sc second 
#define f first 
#define kek cout<<"\n" 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
const ll MOD = 1e9 + 7;
const int N = 1005;
const ll INF = 1e9;
using namespace std;
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
        
      int a,b,c;
      cin>>a>>b>>c;
      if(a==b && b!=c) cout<<"Yes";
      else if(a==c && a!=b) cout<<"Yes";
      else if(b==c && a!=c) cout<<"Yes";
      else cout<<"No";
      
        
        
        
        
        
        return 0;
        
        
        
        
        
}

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

using namespace std;

int main()
{
    char b_str[10];
    long long a;
    cin >> a >> b_str;
    int b100 = 100 * (b_str[0]-'0') + 10 * (b_str[2]-'0') + b_str[3]-'0';
    cout << (long long)((a*b100) / 100) << endl;
    return 0;
}

Measured memory_bytes: 3636