akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

        if (x >= 30) {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26852
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
#define rp
int main()
{
int a,b,c,x,y,z,k;
cin>>a>>b>>c>>k;
x=a+b+c*pow(2,k);
y=c+b+a*pow(2,k);
z=a+c+b*pow(2,k);
x=max(x,y);
y=max(x,z);
cout<<y<<endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	pair<int,int> p[m];
	for(int i=0;i<m;i++){
		int l,r;
		cin>>l>>r;
		p[i].first=l;
		p[i].second=r;
	}
	sort(p,p+m);
	int f=0;
	int k=0;
	for(int i=1;i<m;i++){
		if(p[k].second<p[i].first){
			f=1;
			break;
		}
		else{
			if(p[k].second>p[i].second)
				k=i;
		}
	}
	if(f==0)
		cout<<p[k].second-p[m-1].first+1;
	else
		cout<<0;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>

using namespace std;

pair<int,int> d[11111];
int k;

pair<int,int> a[11111];
int ak;
pair<int,int> b[11111];
int bk;
pair<int,int> c[11111];
int ck;

int main()
{
	while(1)
	{
		int n,m,p,q,r;
		scanf("%d",&n);
		if(n == 0)
		{
			break;
		}
		scanf("%d%d%d%d",&m,&p,&q,&r);
		k = 1;
		d[0] = make_pair(1,n);
		for(int j = 0; j < m; j++)
		{
			int x,y;
			scanf("%d%d",&x,&y);
			int nk = 0;
			ak = 0;
			int ne;
			for(int i = 0; i < k; i++)
			{
				nk += d[i].second - d[i].first + 1;
				a[ak] = d[i];
				ak++;
				if(nk >= x)
				{
					if(nk == x)
					{
						ne = i + 1;
					}
					else
					{
						a[ak - 1].second -= nk - x;
						d[i].first = a[ak - 1].second + 1;
						ne = i;
					}
					nk = x;
					break;
				}
			}
			bk = 0;
			for(int i = ne; i < k; i++)
			{
				nk += d[i].second - d[i].first + 1;
				b[bk] = d[i];
				bk++;
				if(nk >= y)
				{
					if(nk == y)
					{
						ne = i + 1;
					}
					else
					{
						b[bk - 1].second -= nk - y;
						d[i].first = b[bk - 1].second + 1;
						ne = i;
					}
					nk = y;
					break;
				}
			}
			ck = 0;
			for(int i = ne; i < k; i++)
			{
				c[ck] = d[i];
				ck++;
			}
			k = 0;
			for(int i = 0; i < ck; i++)
			{
				d[k] = c[i];
				k++;
			}
			for(int i = 0; i < bk; i++)
			{
				d[k] = b[i];
				k++;
			}
			for(int i = 0; i < ak; i++)
			{
				d[k] = a[i];
				k++;
			}
		}
		int now = 0;
		int all = 0;
		for(int i = 0; i < k; i++)
		{
			now++;
			int nex = now + d[i].second - d[i].first;
			if(now > q)
			{
				break;
			}
			if(p <= now && nex <= q)
			{
				if(d[i].second <= r)
				{
					all += d[i].second - d[i].first + 1;
				}
				else if(d[i].first <= r)
				{
					all += r - d[i].first + 1;
				}
			}
			else if(p <= now && now <= q)
			{
				d[i].second -= nex - q;
				if(d[i].second <= r)
				{
					all += d[i].second - d[i].first + 1;
				}
				else if(d[i].first <= r)
				{
					all += r - d[i].first + 1;
				}
			}
			else if(p <= nex && nex <= q)
			{
				d[i].first += p - now;
				if(d[i].second <= r)
				{
					all += d[i].second - d[i].first + 1;
				}
				else if(d[i].first <= r)
				{
					all += r - d[i].first + 1;
				}
			}
			now = nex;
		}
		printf("%d\n",all);
	}
	return 0;
}

Measured memory_bytes: 1532
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cstring>

using namespace std;
int const maxn = static_cast<const int>(1e3 + 7);
char str[maxn];

bool judge() {
    size_t len = strlen(str);
    for (int i = 0; i < len; i += 2) {
        if (str[i] != 'R' && str[i] != 'U' && str[i] != 'D')
            return false;
    }
    for (int i = 1; i < len; i += 2) {
        if (str[i] != 'L' && str[i] != 'U' && str[i] != 'D')
            return false;
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> str;
    if(judge())
        cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,p[1000][3],flg[1000]={0},cnt,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			scanf("%d",&p[i][j]);
		}
		sort(p[i],p[i]+3);
	}
	cnt=0;
	for(i=0;i<n-1;i++){
		if(flg[i]==0){
			for(j=i+1;j<n;j++){
				if(p[i][0]==p[j][0]&&p[i][1]==p[j][1]&&p[i][2]==p[j][2]){
					cnt++;
					flg[j]=1;
					}
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}


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

int main() {
	int N;
	int A[1100];
	cin>>N;
	for(int i=0;i<N;++i)cin>>A[i];

	bool check=true;
	for(int i=0;i<N;++i){
		if(A[i]%2==0){
			if(A[i]%3==0 || A[i]%5==0){
			}
			else {
				check=false;
				break;
			}
		}
	}
	check?cout<<"APPROVED"<<endl:cout<<"DENIED"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
void BubbleSort(int a[], int n, int &sum) {
	int i, j;
	for ( i = 0; i < n; i++){
		for (j = n - 1; j > i; j--) {
			if (a[j] < a[j - 1])
			{
				swap(a[j], a[j - 1]);
				sum++;
			}
		}
	}
}
void Print(int a[], int n) {
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << a[i];
	}
}
int main() {
	int n,sum=0;
	cin >> n;
	int a[105];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	BubbleSort(a, n, sum);
	Print(a, n);
	cout << endl << sum <<endl;
	
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#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 namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  int N,allxor;
  cin >> N;
  vector<int> vec(N);
  rep(i,N){
    cin >> vec[i];
    if(i == 0){
      allxor = vec[i];
    }
    else{
      allxor ^= vec[i];
    }
  }
  
  rep(i,N){
    cout << (allxor ^ vec[i]) << " ";
  }
  cout << endl;   
  return 0;
}

Measured memory_bytes: 4040
gets
a = gets.split.map{|x| x.to_i << 50}.sort!
while a.size > 1
  a[0] = (a[0] + a[1]) / 2
  a[1] = a[-1]
  a.pop
  a.sort!
end
p a[0] / (1<<50).to_f

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    int m, n; cin >> m >> n;
    VI a(n); cin >> a;
    int ans = INF;
    if (m == 2) {
        FOR(i, 0, 2) {
            int cnt = 0;
            FOR(j, 0, n) {
                if (i != (a[j] % 2 + j % 2) % 2)++cnt;
            }
            chmin(ans, cnt);
        }
    }
    else {
        ans = 0;
        FOR(i, 0, n - 1) {
            if (a[i] == a[i + 1]) {
                a[i + 1] = -1;
                ++ans;
            }
        }
    }
    cout << ans << "\n";
}



Measured memory_bytes: 3120
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
vector<int> G[200005];
vector<int> second;
bool vis[200005];
int main() {
    int N, M;
    scanf("%d%d",&N,&M);
    memset(vis, false, sizeof(vis));
    for (int i = 0; i < M; i++) {
        int a, b;
        scanf("%d%d",&a,&b);
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for (int i = 0; i < G[1].size(); i++) {
        int v = G[1][i];
        if (!vis[v]) {
            second.push_back(v);
            vis[v] = true;
        }
    }
    for (int i = 0; i < second.size(); i++) {
        int v = second[i];
        for (int j = 0; j < G[v].size(); j++) {
            if (G[v][j] == N) {
                printf("POSSIBLE\n");
                return 0;
            }
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 12912
#include<iostream>
#include<cstring>
using namespace std;
int n[2200][2200][3], l[2200][3], h, w, q, a, b, c, d; char s;
int main() {
	cin >> h >> w >> q;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> s;
			if (s == 'J') {
				l[i][0]++;
			}
			else if (s == 'O') {
				l[i][1]++;
			}
			else {
				l[i][2]++;
			}
			n[i][j][0] = n[i - 1][j][0] + l[i][0];
			n[i][j][1] = n[i - 1][j][1] + l[i][1];
			n[i][j][2] = n[i - 1][j][2] + l[i][2];
		}
	}
	for (int i = 0; i < q; i++) {
		cin >> a >> b >> c >> d;
		for (int j = 0; j < 3; j++) {
			if (j) { cout << ' '; }
			cout << n[a - 1][b - 1][j] + n[c][d][j] - n[a - 1][d][j] - n[c][b - 1][j];
		}
		cout << endl;
	}
	return 0;
}

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

int isPrime(int x);

int main() {
	int n;

	cin >> n;
	int sum = 0;
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (isPrime(a))sum++;
	}


	cout << sum << endl;

}

int isPrime(int x) {
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) {
		return false;
	}

	int i = 3;
	while (i*i <= x) {
		if (x%i == 0)return false;
		i = i + 2;
	}
	return true;
}


Measured memory_bytes: 3096
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip())

    ans = 0

    prev = 0
    for i, b in enumerate(input().rstrip().split(" ")):
        b = int(b)
        if i == 0:
            ans += b
            prev = b
            continue

        ans += min(b, prev)
        prev = b
    ans += b

    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int numa[1000000], numb[1000000];
int main(){
    int n; cin >> n;
    vector<int> a, b;
    int x, y;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        a.push_back(x);
        numa[x]++;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> y;
        b.push_back(y);
        numb[y]++;
    }
    for (int i = 1; i <= n; i++)
    {
        if(numa[i]+numb[i] > n) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    for (int i = 1; i <= n; i++)
    {
        numa[i] += numa[i-1];
        numb[i] += numb[i-1];
    }
    int shift=0;
    for (int i = 1; i <= n; i++)
    {
        shift = max(shift, numa[i] - numb[i-1]);
    }
    for(int i = 0; i < n; i++){
        cout << b.at((i+n-shift)%n) << " ";
    }
    puts("");
}

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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

const int MAXN = (int) 2.5e5;

int n;

char s[MAXN + 5];

inline void input()
{
	n = read<int>();
	scanf("%s", s + 1);
}

inline int fpm(int x, int y, int MOD)
{
	int res = 1;
	for(; y; y >>= 1, x = (LL) x * x % MOD) if(y & 1) res = (LL) res * x % MOD;
	return res;
}

inline void solve()
{
	// Thanks to zhou888

	const int MOD1 = 998244353, MOD2 = 1004535809, B = 233;

	static int p[MAXN + 5];
	static int prefix1[MAXN + 5], p1_pow[MAXN * 2 + 5];
	static int prefix2[MAXN + 5], p2_pow[MAXN * 2 + 5];

	p1_pow[0 + n] = 1;
	p2_pow[0 + n] = 1;
	for(int i = 1, invB1 = fpm(B, MOD1 - 2, MOD1), invB2 = fpm(B, MOD2 - 2, MOD2); i <= n; ++i)
	{
		p1_pow[ i + n] = (LL) p1_pow[ i - 1 + n] *     B % MOD1;
		p1_pow[-i + n] = (LL) p1_pow[-i + 1 + n] * invB1 % MOD1;
		p2_pow[ i + n] = (LL) p2_pow[ i - 1 + n] *     B % MOD2;
		p2_pow[-i + n] = (LL) p2_pow[-i + 1 + n] * invB2 % MOD2;
	}

	for(int i = 1; i <= n; ++i)
	{
		p[i] = p[i - 1];
		prefix1[i] = prefix1[i - 1];
		prefix2[i] = prefix2[i - 1];
		if(s[i] == '<') --p[i];
		if(s[i] == '>') ++p[i];
		if(s[i] == '+')
		{
			(prefix1[i] += p1_pow[p[i] + n]) %= MOD1;
			(prefix2[i] += p2_pow[p[i] + n]) %= MOD2;
		}
		if(s[i] == '-')
		{
			(prefix1[i] -= p1_pow[p[i] + n]) %= MOD1;
			(prefix2[i] -= p2_pow[p[i] + n]) %= MOD2;
		}
	}
	for(int i = 1; i <= n; ++i)
	{
		(prefix1[i] += MOD1) %= MOD1;
		(prefix2[i] += MOD2) %= MOD2;
	}

	static map<pii, int> cnt;

	LL ans = 0;
	for(int i = 1; i <= n; ++i) ans += prefix1[i] == prefix1[n] && prefix2[i] == prefix2[n];
	for(int i = 1; i <= n; ++i)
	{
		ans += cnt[mp(prefix1[i], prefix2[i])];
		int res1 = (prefix1[i] + (LL) p1_pow[p[i] + n] * prefix1[n] % MOD1) % MOD1;
		int res2 = (prefix2[i] + (LL) p2_pow[p[i] + n] * prefix2[n] % MOD2) % MOD2;
		++cnt[mp(res1, res2)];
	}
	printf("%lld\n", ans);
}

int main()
{
//	freopen("F.in", "r", stdin);
//	freopen("F.out", "w", stdout);

	input();
	solve();

	return 0;
}




Measured memory_bytes: 38528
n = int(input())
ans = {"AC":0, "WA":0, "TLE":0, "RE":0}
for i in range(n):
    s = input()
    ans[s] += 1

print("AC x " + str(ans["AC"]))
print("WA x " + str(ans["WA"]))
print("TLE x " + str(ans["TLE"]))
print("RE x " + str(ans["RE"]))


Measured memory_bytes: 9196
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



ll N;

int main () {
  cin >> N;

  ll ans = 0;

  if (N % 2 == 0) {
    ll div = 5LL;

    while (N >= div) {
      ll tmp = N / div;
      ans += (tmp / 2);

      div *= 5LL;
    }

  } else {
    ans = 0;
  }

  cout << ans << "\n";
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int a, b, c, d;
    string s, t="";
    cin >> s;
    int fc=0, ff=0;
    rep(i,s.size()) {
        if(s[i]=='C'&&fc==0) {
            t+='C';
            fc=1;
        }
        else if(s[i]=='F'&&ff==0&&fc==1) {
            t+='F';
            ff=1;
        }
    }
    if(t=="CF") P("Yes");
    else P("No");

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int A,B,C,D;
    printf("\n");
    scanf("%d %d %d %d",&A,&B,&C,&D);
    while(1){
        C=C-B;
        if(C<=0){
            printf("Yes\n");
            break;
        }
        A=A-D;
        if(A<=0){
            printf("No\n");
            break;
        }
        }
    
    
    return 0;
}


Measured memory_bytes: 1640
N, M = map(int, input().split())
box = [1]*N
cld = [False]*N
cld[0] = True
for i in range(M):
	x, y = map(int, input().split())
	x -= 1
	y -= 1
	if cld[x]:
		if box[x] == 1:
			cld[x] = False
		cld[y] = True
	box[x] -= 1
	box[y] += 1
print(sum(cld))

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, N) cin >> A.at(i);
	vector<int> ans(N);
	rep(i, N) ans.at(A.at(i) - 1) = i + 1;
	rep(i, N) cout << ans.at(i) << " ";
	cout << endl;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;

typedef long long ll;

const int maxn = 200010;

int L, n, x[maxn];
ll d1[maxn], d2[maxn];

ll s1[maxn], s2[maxn];

int dis(int a, int b) {
	if (b > a) return b-a;
	else return L+b-a;
}

ll ans;

int main() {
	scanf("%d%d", &L, &n);
	for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
	x[0] = 0;
	for (int i = 1; i <= n; i++) d2[i] = dis(0, x[i]), d1[i] = dis(x[i], 0);
	for (int i = 1; i <= n; i++) s1[i] = s1[i-1]+d1[i], s2[i] = s2[i-1]+d2[i];
	int lc = n, rc = 0;
	for (int i = 0; i < n; i++) {
		//i->i+1
		ll tans = 0;
		{
			int tc = min(lc, rc);
			ll t1 = s1[min(n, n-lc+tc+1)]-s1[n-lc+1]; //n-lc+1~n-lc+tc
			ll t2 = s2[rc]-s2[rc-tc]; //rc-tc+1~rc
			tans = max(tans, 2*t1+2*t2+d1[n-lc+1]);
			//cout << i << "a" << tans+d1[n-lc+1]+d2[rc] << endl;
		}
		{
			int tc = min(lc, rc);
			ll t1 = s1[n-lc+tc]-s1[n-lc]; //n-lc+1~n-lc+tc
			ll t2 = s2[rc-1]-s2[max(0, rc-tc-1)]; //rc-tc+1~rc
			tans = max(tans, 2*t1+2*t2+d2[rc]);
			//cout << i << "b" << tans+d1[n-lc+1]+d2[rc] << endl;
		}
		ans = max(ans, tans);
		-- lc; ++ rc;
	}
	printf("%lld\n", max(ans, d2[n]));
	return 0;
}

Measured memory_bytes: 7296
import io.StdIn

object Main extends App {
  val out = new java.io.PrintWriter(System.out)
  val Array(n, m) = StdIn.readLine.split(" ").map(_.toInt)
  val st = Iterator.continually(StdIn.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .toArray
  val cp = Iterator.continually(StdIn.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .toArray

  val ans = st.map(es => {
    cp./:(Int.MaxValue, 0, 0)((min, ep) => {
      val d = (es(0) - ep(0)).abs + (es(1) - ep(1)).abs
      if(min._1 > d) (d, min._3 + 1, min._3 + 1)
      else (min._1, min._2, min._3 + 1)
    })._2
  })

  ans.foreach(out.println)
  out.flush
}

Measured memory_bytes: 25424
N=int(input())
count = ""
for i in range(1,N+1):
 x=i
 if x%3==0:
  count += " " + str(i)
 else:
   while x:
      if x % 10 == 3:
          count += " " + str(i)
          break
      x //= 10
print(count)

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

const char NL = '\n';
const int MOD = 1e9 + 7;

void solve()
{
    double n, d; cin >> n >> d;
    int ans = 0;
    while (n--) {
        double x, y; cin >> x >> y;
        ans += sqrt(abs(pow(x, 2)) + abs(pow(y, 2))) <= d;
    }
    cout << ans << NL;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3856
import copy
import collections
N = int(input())
seq = [int(i) for i in input().split()]
seqP1 = [i + 1 for i in copy.copy(seq)]
seqM1 = [i - 1 for i in copy.copy(seq)]
mixed = seq + seqM1 + seqP1
print(mixed.count(collections.Counter(mixed).most_common()[0][0]))


Measured memory_bytes: 33588
#include <stdio.h>
int main() {
	int r, g, b;
	scanf("%d%d%d", &r, &g, &b);
	if ((10 * g + b) % 4 == 0) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
// AOJ 0240
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int n, y;
	while (cin >> n, n){
		cin >> y;
		double r, t;
		int b;
		vector < pair <double, int> > d;
		for (int i = 0; i < n; i++){
			cin >> b >> r >> t;
			double p = r / 100.0;
			if (t == 1){
				d.push_back(make_pair(1 + (y * p), b));
			}
			else {
				d.push_back(make_pair(pow(1 + p, y), b));
			}
		}
		sort(d.rbegin(), d.rend());
		cout << d[0].second << endl;
	}

	return 0;
}

Measured memory_bytes: 1240
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;


int main()
{
	int N;
	cin >> N;
	vector<int> Xn(N, 0);

	double sum = 0;
	rep(i, N) {
		cin >> Xn[i];
		sum += Xn[i];
	}
	int mean = round(sum / (double)N);

	sum = 0;
	rep(i, N){
		sum += (Xn[i] - mean) * (Xn[i] - mean);
	}

	cout << sum << endl;
	return 0;
} 

Measured memory_bytes: 3812
import sys
import math
def input():
    return sys.stdin.readline()[:-1]

N, D = map(int, input().split())

X = []

for n in range(N):
    X.append(list(map(int, input().split())))

def nolm(x, y):
    s = len(x)
    total = 0
    for i in range(s):
        total += (x[i] - y[i]) ** 2
    return math.sqrt(total)

ans = 0

for n in range(N-1):
    for i in range(n+1, N):
        if nolm(X[n], X[i]).is_integer():
            ans += 1

print(ans)


Measured memory_bytes: 3064
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

K,N=get_i
A=get_i
ans=K
diff=array(N,0)
N.times do|i|
    if i!=N-1
        diff[i]=A[i+1]-A[i]
    else
        diff[i]=(K-A[i])+A[0]
    end
end
puts ans-diff.max

Measured memory_bytes: 20364
n = int(input())
for i in range(1, n + 1):
    if i % 3 == 0:
        print(f' {i}', end='')
        continue
    x = i
    while x > 0:
        if x % 10 == 3:
            print(f' {i}', end='')
            break
        x //= 10

print()



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

//#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int n; string s, t; cin >> n >> s >> t;
	int ans = n + n;
	rep(i, n) {
		bool ok = true;
		rep(j, n) if (i + j < n) {
			if (s[i + j] != t[j]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			ans = i + n;
			break;
		}
	}
	cout << ans << endl;

	system("pause");
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;

int n;
int lo[MAXN], ro[MAXN];
int l[MAXN], r[MAXN];
int a[MAXN], ord[MAXN];
int lv[MAXN], rv[MAXN], p[MAXN];

void init ();
void input ();
void work ();

LL getans ()
{
	sort ( l + 1, l + 1 + n ), reverse ( l + 1, l + 1 + n );
	sort ( r + 1, r + 1 + n );
	int m = n >> 1;

	lpi ( i, 1, m ) lv[i] = r[i];
	lpi ( i, 1, n - m ) rv[i] = l[i];

	lpi ( i, 1, n - m ) p[i * 2 - 1] = rv[i], p[i * 2] = lv[i];

	int cur = 0;
	LL ans = 0;
	lpi ( i, 1, n ) {
		if ( i & 1 ) {
			if ( cur < p[i] ) {
				ans += p[i] - cur;
				cur = p[i];
			}
		} else {
			if ( cur > p[i] ) {
				ans += cur - p[i];
				cur = p[i];
			}
		}
	}
	ans += qabs ( cur );
	return ans;
}



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	cin >> n;
	lpi ( i, 1, n ) cin >> l[i] >> r[i];
}

void work ()
{
	// main work

	lpi ( i, 1, n ) lo[i] = l[i], ro[i] = r[i];
	LL ret = getans ();
	lpi ( i, 1, n ) l[i] = -ro[i], r[i] = -lo[i];
	ret = max ( ret, getans () );

	cout << ret << endl;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int l, r;
    cin >> l >> r;
    set<int> zigoku;
    vector<long long> cand;
    for (long long int i = l; i <= min(r, l + 3000); i++)
    {
        cand.push_back(i % 2019);
    }
    rep(i, cand.size())
    {
        REP(j, i + 1, cand.size())
        {
            zigoku.insert((cand[i] * cand[j]) % 2019);
        }
    }

    cout << (*zigoku.begin() % 2019) << endl;
    return 0;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**6)

def get_nagasa(i):
    if nagasa[i] != -1:
        return nagasa[i]
    if ko[i] == []:
        nagasa[i] = 0
        return 0
    re = 0
    for ii in ko[i]:
        p = get_nagasa(ii) + 1
        if p > re:
            re = p
    nagasa[i] = re
    return re

n, m = map(int, input().split())
ko = [[] for _ in range(n)]
nagasa = [-1] * n
for _ in range(m):
    x, y = map(int, input().split())
    ko[x - 1] += [y - 1]
mx = 0
for i in range(n):
    tmp = get_nagasa(i)
    if tmp > mx:
        mx = tmp
print(mx)


Measured memory_bytes: 59056
x = int(input())
ans = 1

if x >= 4:
    tei = 2
    while True:
        beki = 2
        if tei >= x:
            break
        else:
            while tei ** beki <= x:
                ans = max(ans, tei ** beki)
                beki = beki + 1
            tei = tei + 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  ll N;
  cin >> N;
  string s;
  cin >> s;
  vector<ll> x(N);
  for(ll i=0;i<N;i++) x[N-1-i]=(s[i]=='0' ? 0 : 1);
  ll pcnt=0;
  for(ll i=0;i<N;i++){
    if(x[i]==1) pcnt++;
  }

  //cout << pcnt << endl;
  
  if(pcnt==0){
    for(ll i=0;i<N;i++){
      cout << 1 << endl;
    }
    return 0;
  }
  if(pcnt==1){
    if(s[N-1]=='1'){
      for(ll i=0;i<N-1;i++){
        cout << 2 << endl;
      }
      cout << 0 << endl;
      return 0;
    }else{
      for(ll i=0;i<N-1;i++){
        if(s[i]=='1') cout << 0 << endl;
        else cout << 1 << endl;
      }
      cout << 2 << endl;
      return 0;
    }
  }
  
  ll tmp0=1%(pcnt+1),tmp1=1%(pcnt-1);
  ll mod0=0,mod1=0;

  for(ll i=0;i<N;i++){
    mod0+=x[i]*tmp0; mod0%=(pcnt+1);
    mod1+=x[i]*tmp1; mod1%=(pcnt-1);
    tmp0*=2; tmp0%=(pcnt+1);
    tmp1*=2; tmp1%=(pcnt-1);
  }

  tmp0=1%(pcnt+1);tmp1=1%(pcnt-1);
    
  vector<ll> ans(N);
  for(ll i=0;i<N;i++){
    ll cur;
    if(x[i]==0){
      cur=(mod0+tmp0+pcnt+1)%(pcnt+1);
    }else{
      cur=(mod1-tmp1+pcnt-1)%(pcnt-1);
    }

    ll a=1;
    while(cur!=0){
      a++;
      cur%=__builtin_popcount(cur);
    }

    ans[N-1-i]=a;

    tmp0*=2; tmp0%=(pcnt+1);
    tmp1*=2; tmp1%=(pcnt-1);
  }

  for(ll i=0;i<N;i++) cout << ans[i] << endl;

  return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a>=2*b){
        cout << a-2*b << endl;
    }
    else{
        cout << 0 << endl;
    }
    

    return 0;
}

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

int main(void){
    int N;
    cin >> N;
    int sum = 0;
    for(int i = 1; i <= N; i++){
        sum += i;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import static java.lang.Character.toLowerCase;


public class Main {

    // input
    static int n;
    static int k;
    
    /**
     * input
     */
    static void input(){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k = sc.nextInt();
        sc.close();
    }
 
    /**
     * solver
     */
    static void solve(){
        double ans = 0;
        int cMax = 0;

        for (int i =1;i<=n;i++) {
            int c = 0;  // # of coin toss requred. p = (1/2)^n
            int j = i;
            while (j < k) {
                j *= 2;
                c ++;
            }
            if (i == 1) cMax = c;
            ans += Math.pow(2, cMax - c);
        }

        ans *= 1.0 / n / Math.pow(2, cMax);

        System.out.println(ans);
    }

    public static void main(String args[]) {

        input();

        solve();
    }
}


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

int main(){
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;

    bool flg = true;

    for(int i=0; i<A; ++i){
        if(S.at(i)-'0' >= 0 && S.at(i)-'0' <= 9) ;
        else {
            flg = false;
            break;
        }
    }

    if(S.at(A) == '-') ;
    else {
        flg = false;
    }

    for(int i=(A+1); i<(A+B+1); ++i){
        if(S.at(i)-'0' >= 0 && S.at(i)-'0' <= 9) ;
        else {
            flg = false;
            break;
        }
    }

    if(flg == true) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  int n;
  cin >> n;
  vi b(n - 1), a(n);
  REP(i, 0, n - 1)  cin >> b[i];

  a[0] = b[0];
  a[n - 1] = b[n - 2];
  for(int i = 1; i <= n - 2; i++)
    a[i] = min(b[i], b[i - 1]);

  ll sum = 0;
  REP(i, 0, n)  sum += a[i];

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int mod = 1000000007;
        int s = sc.nextInt();
        int[] dp = new int[s+1];
        dp[0] = 1;
        int x = 0;
        for (int i = 3; i <= s; i++) {
            x = (x + dp[i - 3]) % mod ;
            dp[i] = x;
        }
        System.out.println(dp[s]);
	}
}

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

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];

    ll ct=1;
    ll ans=0;
    rep(i,N){
        if(A[i]<ct) continue;
        ans+=(A[i]-1)/ct;
        if(A[i]==ct or i==0) ++ct;
    }
    cout<< ans <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
// int mI(int a, int m)  {return power(a, m - 2, m);}
// vector<vector<int>> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1},{1,1},{1,-1},{-1,1},{-1,-1}};
vector<vector<int>> v;
int n,m;
vector<vec> g;
vec vis;
vec dis;
vec par;
void bg(){
    cin >> n >> m;
    g.resize(n);
    vis.resize(n,0);
    int x, y;
    fo(i,m){
        cin >> x >> y;
        x--;
        y--;
        g[x].pb(y);
        g[y].pb(x);
    }
}

const int INF = 1000000000;

// void dijkstra(int s, vector<int> & d, vector<int> & p) {
//     int n = adj.size();
//     d.assign(n, INF);
//     p.assign(n, -1);

//     d[s] = 0;
//     set<pair<int, int>> q;
//     q.insert({0, s});
//     while (!q.empty()) {
//         int v = q.begin()->second;
//         q.erase(q.begin());

//         for (auto edge : g[v]) {
//             int to = edge.first;
//             int len = edge.second;

//             if (d[v] + len < d[to]) {
//                 q.erase({d[to], to});
//                 d[to] = d[v] + len;
//                 p[to] = v;
//                 q.insert({d[to], to});
//             }
//         }
//     }
// }
void bfs(int i){
    vis.clear();
    dis.clear();
    par.clear();
    vis.resize(n, 0);
    dis.resize(n, 0);
    par.resize(n, 0);

    queue<int> q;
    q.push(i);
    vis[i] = 1;
    par[i] = -1;
    while(!q.empty()){
        int p=q.front();
        q.pop();
        for(auto it:g[p]){
            if(vis[it]==0){
                vis[it] = 1;
                dis[it] = dis[p] + 1;
                par[it] = p;
                q.push(it);
            }
        }
    }
}
void dfs(int i){
    for(auto it:g[i]){
        if(vis[it]==0){
            vis[it] = 1;
            dfs(it);
        }
    }
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    bg();
    bfs(0);
    cout << "Yes\n";
    foo(i,1,n){
        cout << par[i] + 1 << "\n";
    }
}
    


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

using namespace std;
#include <atcoder/all>
using namespace atcoder;

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const double PI = acos(-1);
const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,m;
    cin >> n >> m;
    dsu d(n);
    rep(i, m){
        ll a,b;
        cin >> a >> b;
        --a, --b;
        d.merge(a, b);

    }
    ll ans = 0;
    ll prev = 0;
    rep(i, n){
        if(i == 0) {
            prev = d.leader(i);
        } else {
            if(d.leader(i) != prev) ans++;
            d.merge(prev, i);
            prev = d.leader(i);
        }
    }
    print(ans);
    
}


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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  int n;
  cin >> n;
  vi v(n), c(n);
  REP(i, 0, n)  cin >> v[i];
  REP(i, 0, n)  cin >> c[i];

  vi diff(n);
  REP(i, 0, n)  diff[i] = v[i] - c[i];
  sort(all(diff));

  int ans = 0;
  REP(i, 0, n){
      if(diff[i] > 0)
        ans += diff[i];
  }
  cout << ans << endl;
  
  return 0;
}


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

int main(void){
  int N,M;
  cin>>N>>M;
  int A[N];
  int tmp;
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int k=1;k<=M;k++){
    for(int i=0;i<N-1;i++){
      if(A[i]%k>A[i+1]%k){
        tmp=A[i];
        A[i]=A[i+1];
        A[i+1]=tmp;
      }
    }
  }
  for(int i=0;i<N;i++){
    cout<<A[i]<<endl;
  }
return 0;
}



Measured memory_bytes: 3120
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

ll MOD = 2019;

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

    ll L, R;
    cin >> L >> R;

    ll ans = 5000;
    for (ll i = L; i <= R; i++) {
        for (ll j = i+1; j <= R; j++) {
            ans = min (ans, (i*j) % MOD);
            if (ans == 0) break;
        }
        if (ans == 0) break;
    }

    cout << ans << "\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch ThisMessageWillSelfDestructIn5s | diff ThisMessageWillSelfDestructIn5s.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address ThisMessageWillSelfDestructIn5s.cpp && ./a.out

/*
 
 5/3/2020
 
 5:32-
 
 */

const int MAX_N=1e6+1;
int A[MAX_N];
int N;

void solve() {
  LL res=0;
  map<int,int> cnt;
  REP(j,N) {
    if(j-A[j]>=0&&cnt.count(j-A[j])) res+=cnt[j-A[j]];
    cnt[j+A[j]]++;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 13684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll> >;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int n;cin >> n;
    int a=0,b=0,c=0,d=0;
    for(int i=0;i<n;i++){
	string s;cin >> s;
	if(s=="AC") a++;
	if(s=="WA") b++;
	if(s=="TLE") c++;
	if(s=="RE") d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int ans;
  if( N <= 9 ){
    ans = N;
  } else if ( N <= 99 ){
    ans = 9;
  } else if ( N <= 999 ){
    ans = N - 99 + 9;
  } else if ( N <= 9999 ){
    ans = 900 + 9;
  } else if ( N <= 99999 ){
    ans = N - 9999 + 900 + 9;
  } else {
    ans = 90000 + 900 + 9;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

ll n;
ll ans;

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

    cin >> n;

    FOR(i, 1, n + 1) ans += (n + 1 - i) * i;

    rep(i, n - 1) {
        ll a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);
        ans -= a * (n + 1 - b);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648