akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    ll n, k;
    cin >> n >> k;
    ll r = 0;
    ll tmp = 0;
    for (ll i = k; i <= n+1; i++) {
        ll f = i * (i-1) / 2;
        ll l = (n*2 - i + 1) * i / 2;
        tmp = l-f + 1;
        r += tmp;
        r %= MOD;
    }
    
    mes(r);
    
    
    
    

}
    
    
    
    
    


Measured memory_bytes: 3604
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        Map<Pair, Long> map = new HashMap<>();
        int N = scanner.nextInt();

        if(N == 1) {
            System.out.println(1);
            return;
        }

        long[] x = new long[N];
        long[] y = new long[N];
        for(int i = 0; i< N; i++) {
            x[i] = scanner.nextLong();
            y[i] = scanner.nextLong();
        }
        for(int i = 0; i< N-1; i++) {
            for(int j = i+1; j< N; j++) {
                long subX = x[i] - x[j];
                long subY = y[i] - y[j];
                if(map.get(new Pair(subX, subY)) != null){
                    map.put(new Pair(subX, subY), map.get(new Pair(subX, subY)) + 1);
                }else{
                    map.put(new Pair(subX, subY), 1L);
                }
                subX = x[j] - x[i];
                subY = y[j] - y[i];
                if(map.get(new Pair(subX, subY)) != null){
                    map.put(new Pair(subX, subY), map.get(new Pair(subX, subY)) + 1);
                }else{
                    map.put(new Pair(subX, subY), 1L);
                }
            }
        }
        long value = map.entrySet().stream().max(
                (entry1, entry2) -> entry1.getValue() > entry2.getValue() ? 1 : -1).get().getValue();


        System.out.println(N - value);

    }

    public class Pair {
        public Long x;
        public Long y;

        public Pair(long x, long y) {
            this.x = x;
            this.y = y;
        }
        @Override
        public boolean equals(Object obj) {
            if (!(obj instanceof Pair))
                return false;
            Pair ref = (Pair) obj;
            return this.x.equals(ref.x) &&
                    this.y.equals(ref.y);
        }

        @Override
        public int hashCode() {
            return x.hashCode() ^ y.hashCode();
        }

    }

}


Measured memory_bytes: 28500
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()

    val a = Array(n) { sc.nextInt() }
    val b = Array(n) { sc.nextInt() }
    val c = Array(n) { sc.nextInt() }


    Arrays.sort(a)
    Arrays.sort(b)
    Arrays.sort(c)

    val A = mutableMapOf<Int, Int>()
    var cur = 0
    for (i in 0 until n) {
        while (cur < n && a[cur] < b[i]) {
            cur += 1
        }
        A.put(b[i], cur)
    }

    val C = mutableMapOf<Int, Int>()



    cur = n - 1
    for (i in n - 1 downTo 0) {
        while (cur >= 0 && c[cur] > b[i]) {
            cur -= 1
        }
        C.put(b[i], n - cur - 1)
    }

    var sum = 0L
    for (i in 0 until n) {
        val x = A[b[i]] ?: throw Exception()
        val y = C[b[i]] ?: throw Exception()
        sum += x.toLong() * y
    }
    println(sum)


}


class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}






Measured memory_bytes: 83684
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

int toi(string in) {
	int ans = 0;
	REP(i, in.size()) {
		int num = 0;
		if(i != 0)
			num = (int)in[i-1] - '0'; 
		if(in[i] == 'm') {
			if(0 < num && num < 10)  
				ans += num * 1000;
			else
				ans += 1000;
		}
		else if(in[i] == 'c') {
			if(0 < num && num < 10)  
				ans += num * 100;
			else
				ans += 100;
		}
		else if(in[i] == 'x') {
			if(0 < num && num < 10)  
				ans += num * 10;
			else
				ans += 10;
		}
		else if(in[i] == 'i') {
			if(0 < num && num < 10)  
				ans += num;
			else
				ans += 1;
		}
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	REP(i, n) {
		string in1, in2;
		cin >> in1 >> in2;
		int ans = toi(in1) + toi(in2);
		if(ans / 1000) {
			if(ans / 1000 > 1)
				cout << ans / 1000;
			cout << 'm';
		}
		if(ans % 1000 / 100) {
			if(ans % 1000 / 100 > 1)
				cout << ans % 1000 / 100;
			cout << 'c';
		}
		if(ans % 100 / 10) {
			if(ans % 100 / 10 > 1)
				cout << ans % 100 / 10;
			cout << 'x';
		}
		if(ans % 10) {
			if(ans % 10 > 1)
				cout << ans % 10;
			cout  << 'i';
		}
		cout << endl;
	}
	return 0;
}

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

class UnionFind {
public:
  vector<int> uni;
  UnionFind(int s) : uni(s, -1) {}

  int root(int a) {
    if (uni[a] < 0)
      return a;
    return uni[a] = root(uni[a]);
  }

  bool connect(int a, int b) {
    a = root(a);
    b = root(b);
    if (a == b)
      return false;
    if (uni[a] > uni[b])
      swap(a, b);
    uni[a] = uni[a] + uni[b];
    uni[b] = a;
    return true;
  }

  bool isConnect(int a, int b) { return root(a) == root(b); }

  int size(int a) { return -uni[root(a)]; }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind uf(N);
  vector<int> A(M), B(M);
  vector<ll> ans(M);
  rep(i, M) {
    cin >> A[i] >> B[i];
    A[i]--, B[i]--;
  }
  for (int i = M - 1; i >= 0; i--) {
    if (uf.isConnect(A[i], B[i]))
      continue;
    ans[i] = uf.size(A[i]) * uf.size(B[i]);
    uf.connect(A[i], B[i]);
  }
  rep(i, M - 1) ans[i + 1] += ans[i];
  rep(i, M) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 3328
//Brave Force Story
#include<bits/stdc++.h>
using namespace std;

typedef pair< pair<int, int>, int> Q;
#define INF -1
int dx[6]={1, 1, 0, -1, -1, 0}, dy[6]={1, 0, -1, -1, 0, 1};
int mp[121][121];//+60
int d[121][121]; //+30

Q make_Q(int x, int y, int z){
  Q ret;
  ret.first.first=x;
  ret.first.second=y;
  ret.second=z;
  return ret;
}

int main(){
  int t, n;
  while(cin>>t>>n, !(t==0&&n==0)){
    memset(mp, 0, sizeof(mp));
    for(int i=0; i<121; i++)
      for(int j=0; j<121; j++)
	d[i][j]=INF;
    while(n--){
      int tmp_x, tmp_y;
      cin>>tmp_x>>tmp_y;
      mp[tmp_x+60][tmp_y+60]=INF;
    }
    int sx, sy;
    cin>>sx>>sy;
    d[sx+60][sy+60]=0;
    queue<Q> q;
    q.push(make_Q(sx+60, sy+60, t));
    while(!q.empty()){
      Q now=q.front(); q.pop();
      if(now.second==0)break;
      for(int i=0; i<6; i++){
	int nx=now.first.first+dx[i], ny=now.first.second+dy[i];
	if(0<=nx && nx<121 && 0<=ny && ny<121 && mp[nx][ny]!=INF && d[nx][ny]==INF){
	  q.push(make_Q(nx, ny, now.second-1));
	  d[nx][ny]=d[now.first.first][now.first.second]+1;
	}
      }
    }
    int cnt=0;
    for(int i=0; i<121; i++)
      for(int j=0; j<121; j++)
	if(d[i][j]!=INF)cnt++;
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1336
#include <bits/stdc++.h>
using namespace std;
vector <long long int> v;
vector <double> vd;

vector <char> vc;
vector <string> vs;
map <string,int> sm;
map <int,int> mp;
map <char,int>cm;
set <int> st;
#define soort(v) sort(v.begin(),v.end())
#define foor(i,n) for(int i=1; i<n; i++)



int main(){
    int a,b,c,n;
    string s,p;
    char ch;
    vector <string> vs;
    
    cin >> a >> b;
    
    for(int i=0; i<b; i++){
        s+=to_string(a);
    }
    
    for(int i=0; i<a; i++){
        p+=to_string(b);
    }
    
    vs.push_back(s);
    vs.push_back(p);
    sort(vs.begin(), vs.end());
    
    cout << vs[0] << endl;
    
    
}


Measured memory_bytes: 256
# 8 Queens Problem
[N, FREE, NOT_FREE] = [8, -1, 1]
initial_Q = [FREE for i in range(N)]
row = [FREE for i in range(N)]
col = [FREE for i in range(N)]
dneg = [FREE for i in range(N*2 - 1)]
dpos = [FREE for i in range(N*2 - 1)]

k = int(input())
for i in range(k):
    [r, c] = list(map(int, input().split()))
    initial_Q[r] = NOT_FREE
    row[r] = c
    [col[c], dpos[r + c], dneg[r - c + N - 1]] = [NOT_FREE, NOT_FREE, NOT_FREE]

def printBoard():
    global N, row
    for i in range(N):
        row_data = ["." for i in range(N)]
        row_data[row[i]] = "Q"
        print("".join(row_data))
    
def putQueen(i):
    global N, FREE, NOT_FREE
    global initial_Q
    global row, col, dneg, dpos
    if i == N:
        printBoard()
        return 1
    
    if initial_Q[i] != FREE:
        if putQueen(i + 1) == 1:
            return 1
        else:
            return 0
    else:
        for j in range(N):
            if col[j] == NOT_FREE or dpos[i + j] == NOT_FREE or dneg[i - j + N - 1] == NOT_FREE:
                continue
            row[i] = j
            [col[j], dpos[i + j], dneg[i - j + N - 1]] = [NOT_FREE, NOT_FREE, NOT_FREE]
            if putQueen(i + 1) == 1:
                return 1
            row[i] = FREE
            [col[j], dpos[i + j], dneg[i - j + N - 1]] = [FREE, FREE, FREE]

    return 0

putQueen(0)


Measured memory_bytes: 5616
#include <stdio.h>

int main(void){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    
    if( (A<C&&C<B)||(B<C&&C<A) )
    printf("Yes");
    else
    printf("No");
    
    return(0);
    
}


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


const int N = 2e5 + 5, MOD = 1e9 + 7;



int n, a[N], dp[N], val[N];

inline void add(int &x, int y){
    x += y;
    if(x >= MOD){
        x -= MOD;
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(a[i] != a[i - 1]){
            add(val[a[i]], dp[i - 1]);
        }
        dp[i] = val[a[i]];
    }
    cout << dp[n];
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())


int main(int argc, char const *argv[]) {
   int n,cnt=0;
   cin >> n;
   for(int i=1; i<=n; i++) if(i%2==1) cnt++;
   printf("%.9f\n",(double)cnt/n);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n,k,ans;
int head[100100],nxt[100100],to[100100],cnt=0;
int TO[100100];
void add(int x,int y){
	to[++cnt]=y;
	nxt[cnt]=head[x];
	head[x]=cnt;
}
int dfs(int u,int depth){
	int rest_max=depth;
	for (int i=head[u];i;i=nxt[i])
		rest_max=max(rest_max,dfs(to[i],depth+1));
	if (TO[u]!=1&&rest_max-depth==k-1) {
		ans++;return 0;
	}
	return rest_max;
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&TO[i]);
		if (i==1){
			if (TO[i]==1) ans=0;else ans=1;
			TO[i]=1;
		}else {
			add(TO[i],i);//¼Ó·´Ïò±ß 
		}
	}
	dfs(1,0);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 6528
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll ans = 0;
vector<int> vec;

void dfs(int d, ll c) {

  if (c == 0) return;

  if (d >= 10) {
    dfs (d / 10 + d % 10, c);
    ans += c;
  } else {
    if (c == 1) {
      vec.push_back(d);
      return;
    }

    dfs (d * 2, c / 2);
    ans += c / 2;
    if (c % 2) vec.push_back(d);
  }
}


int main(){
  int M;

  scanf("%d", &M);


  for (int i=0; i<M; i++) {
    int d;
    ll c;
    scanf("%d%lld", &d, &c);
    dfs(d, c);
  }

  if (vec.size()) ans--;

  int prev = 0;
  for (auto p : vec) {
    prev += p;
    ans++;
    if (prev >= 10) {
      ans++;
      prev = prev / 10 + prev % 10;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 18792
int main()
{
  long a, b, n;
  scanf("%ld %ld %ld", &a, &b, &n);
  
  long x;
  if (n < b)
    x = n;
  else
    x = b - 1;
  printf("%ld", (a * x / b) - a * (x / b));
}


Measured memory_bytes: 1724
#include<iostream>
using namespace std;
int main() {
	int n, m;
	int i, j, k;
	int mat[100][100] = { {} };
	int ve[100] = {};
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			cin >> mat[i][j];
		}
	}
	for (j = 0; j < m; j++) cin >> ve[j];
	for (i = 0; i < n; i++) {
		int x = 0;
		for (j = 0; j < m; j++) x += mat[i][j] * ve[j];
		cout << x << endl;
	}

	return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect

const int N = 2e5 + 7, INF = 1e15;

void solve() {
    int n; cin >> n;
    cout << n / 500 * 1000 + n % 500 / 5 * 5;
}
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion


LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 



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

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

	int n;
	cin >> n;
	vi a(n), b(n);
	f_v2I(a, b, n);
	int ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		a[i] += ans;
		if (a[i]%b[i] == 0) {
			continue;
		}
		ans += b[i] - (a[i] % b[i]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

//#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)
#define MAX_N (10000000)

ll N;

void solve() {
  int root = sqrt(N);
  debug_printf("%d %f\n", root, sqrt(N));
  for (ll i = root; i >= 1; i--) {
    if (N % i == 0) {
      ll x = log10(i) + 1;
      ll y = log10(N / i) + 1;
      printf("%lld\n", max(x, y));
      return;
    }
  }
}

int main() {
  scanf("%lld", &N);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m,x,a[100000];
    scanf("%d %d %d",&n,&m,&x);
    for(int i = 1;i<=m;i++)
    {
        scanf("%d",&a[i]);
    }
    int cost;
    int mid = (n/2)+1;
    if(x == 0)
        printf("0");
    else if(x == n)
        printf("0");
    else
 {
         int cost = 0;
        for(int i = x;i<=n;i++)
        {
            for(int j = 1;j<=m;j++)
            if(a[j]>0 &&a[j]<n && a[j] == i)
              {
                  cost++;
              }
        }
        int save1 = cost;
        cost = 0;
        for(int i = x;i>=0;i--)
        {
            for(int j = 1;j<=m;j++)
            if(a[j]>0 &&a[j]<n && a[j] == i)
              {
                  cost++;
              }
        }
        int save2 = cost;
        if(save1 > save2)
            printf("%d\n",save2);
        else
            printf("%d\n",save1);
  }
}



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

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

using namespace std;

ll N, M;
vector<vector<ll>> graph;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    cin >> N >> M;
    graph.assign(N, vector<ll>());
    Rep (i, M) {
        ll s, t;
        cin >> s >> t;
        s--; t--;
        graph[s].push_back(t);
    }    

    double ans = 1000;
    Rep (j, N) {
        vector<double> dp(N, 0);
        dp[N-1] = 0;
        for (ll i = N-2; i >= 0; i--) {

            double var = 0;
            for (ll e : graph[i]) {
                dp[i] += dp[e] + 1;
                chmax(var, dp[e] + 1);
            }
            if (i == j && graph[i].size() > 1) {
                dp[i] -= var;
                dp[i] /= (graph[i].size()-1);
            }
            else dp[i] /= graph[i].size();
        }
        chmin(ans, dp[0]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
ll dp[100005][2]={0};
const int mod=1000000007;
int main(){
  string s;
  cin>>s;
  dp[1][0]=1;
  dp[1][1]=2;
  for(int i=1;i<s.size();i++){
    int n_bit=s[i]-'0';
    if(n_bit==1){
      dp[i+1][0]+=dp[i][1];
      dp[i+1][1]+=dp[i][1]*2;
    }
    else{
      dp[i+1][1]+=dp[i][1];
    }
    dp[i+1][0]+=dp[i][0]*3;
    dp[i+1][0]%=mod;
    dp[i+1][1]%=mod;
  }
  cout<<(dp[s.size()][0]+dp[s.size()][1])%mod<<endl;
}


Measured memory_bytes: 2048
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using uInt = long long unsigned int;
using Double = long double;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;
        vector<vector<Int>> dist(N, vector<Int>(N, INFl));
//        for (int i = 0; i + 1 < N; ++i) {
//            dist[i][i + 1] = dist[i + 1][i] = 1;
//        }
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                dist[i][j] = abs(i - j);
            }
        }
        Int X, Y;
        cin >> X >> Y;
        X--, Y--;
        dist[X][Y] = dist[Y][X] = 1;
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                chmin(dist[i][j], dist[i][X] + dist[X][j]);
            }
        }
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                chmin(dist[i][j], dist[i][Y] + dist[Y][j]);
            }
        }

        vector<Int> ans(N);
        for (int i = 0; i < N; ++i) {
            for (int j = i + 1; j < N; ++j) {
                ans[dist[i][j]]++;
            }
        }
//        for (auto e : ans) {
//            cout << e << endl;
//        }
        for (int i = 1; i < ans.size(); ++i) {
            cout << ans[i] << endl;
        }
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 31616
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<map>
#include<set>
#include<string>
#include<vector>

#define gec getchar
#define FILE(F) freopen(F".in","r",stdin),freopen(F".out","w",stdout)
#define DEBUG fprintf(stderr,"Passing [%s] in Line (%d)\n",__FUNCTION__,__LINE__);

typedef long long ll;
template<class T>
inline void read(T&x)
{
	x=0;bool f=0;char c=gec();
	for(;c<'0'||c>'9';c=gec())f=(c=='-');
	for(;c>='0'&&c<='9';c=gec())x=x*10+c-'0';
	x=f?-x:x;
}

const int MP(1e9+7);
int n,m,Ans;
int main()
{
	read(n);read(m);
	if(n-m<-1||n-m>1)Ans=0;
	else Ans=1;
	if(n==m)Ans*=2;
	for(int i=1;i<=n;i++)
	Ans=(ll)Ans*i%MP;
	for(int i=1;i<=m;i++)
	Ans=(ll)Ans*i%MP;	
	printf("%d\n",Ans);
	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int count = 0;
  for(int i=2; i<n; i++) {
    if(s[i]=='C' && s[i-1]=='B' && s[i-2]=='A') count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main(){
	int a, b;
	cin >> a;
	cin >> b;
	
	if ( a > b ) {
		cout << "a > b" << endl;
	} else if ( a == b ) {
		cout << "a == b" << endl;
	} else if ( a < b ) {
		cout << "a < b" << endl;
	}

}

Measured memory_bytes: 1156
n=int(input())
a=list(map(int,input().split()))
temp=[0]*n
for i in range(0,n):
  temp[i]=a[i]-(i+1)
temp.sort()
ave=int(n/2)
ans=0
for i in range(0,n):
  ans=ans+abs(temp[i]-temp[ave])
print(ans)

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

int main()
{
    long n;
    std::cin >> n;
    
    std::vector<long> num(n);
    for(int i=0;i<n;i++)
        std::cin >> num[i];
        
    long sum=num[0],max=num[0],min=num[0];
    for(int i=1;i<n;i++)
    {
        sum += num[i];
        if(max < num[i]) max = num[i];
        if(min > num[i]) min = num[i];
    }
    
    std::cout << min << " " << max << " " << sum << std::endl;
}


Measured memory_bytes: 3168
#include <cstdio>
#include <cstring>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else
		return 0;
}

long long getKey(char str[]) {
	long long i, sum = 0, p = 1;
	for (i = 0; i < strlen(str); ++i) {
		sum += p * getChar(str[i]);
		p *= 5;
	}
	return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + key % (M - 1); }

int find(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0; ; ++i) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0; ; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 0;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 1;
		}
	}
	return 0;
}

int main() {
	int i, n, h;
	char str[L], com[9];
	for (i = 0; i < M; ++i) H[i][0] = '\0';

	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%s %s", com, str);
		if (com[0] == 'i') {
			insert(str);
		}
		else {
			if (find(str))
				printf("yes\n");
			else
				printf("no\n");
		}
	}
	return 0;
}


Measured memory_bytes: 16988
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string s;
    cin >> s;
    map<char,bool>mp;

    for (int i=0; i<s.size(); i++){
        if(mp[s[i]]){
            cout << "no" << endl;
            return 0;
        }
        mp[s[i]] = true;
    }
    cout << "yes" << endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	string s;
	cin >> s;
	int res = 0;
	REP(i, 4) if (s[i] == '+') ++res; else --res;
	cout << res << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int h, w;
    cin >> h >> w;
    vs s(h);
    rep(i, h) cin >> s[i];
    int white = 0;
    rep(i, h) rep(j, w) {
        if (s[i][j] == '.') ++white;
    }
    vector<vi> d(h, vi(w, INF));
    queue<pii> q;
    auto ps = [&] (int i, int j, int dist) {
        if (i<0||i>=h||j<0||j>=w) return;
        if (s[i][j] != '.') return;
        q.push({i, j});
        d[i][j] = dist;
        s[i][j] = ' ';
    };
    const int di[] = { -1, 1, 0, 0 }, dj[] = { 0, 0, -1, 1 };
    ps(0, 0, 0);
    while(!q.empty()) {
        pii p = q.front(); q.pop();
        int i = p.first, j = p.second, dist = d[i][j];
        rep(i2, 4) {
            int ni = i + di[i2], nj = j + dj[i2];
            ps(ni, nj, dist + 1);
        }
    }
    int res = d[h-1][w-1];
    int ans = (res!=INF)?(white-res-1):-1;
    cout << ans << endl;
    return 0;
}


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

#define REP(i, N) for (ll i = 0; i < N; ++i)
#define pll pair<ll, ll>
#define F first
#define S second

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        siz.assign(sz_, 1LL);  // assign: 再代入
        par.resize(sz_);  // resize: 再確保
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    // input
    ll N, M;
    ll node1, node2;
    cin >> N >> M;
    vector<pll> A(M);
    for (ll i = 0; i < M; i++) {
        cin >> node1 >> node2; --node1, --node2;
        A[i].F = node1;
        A[i].S = node2;
    }

    // calculation
    vector<ll> ans(M);
    ans[M-1] = (N*(N-1))/2;  // 全ての頂点が孤立している状態

    UnionFind uf(N);
    for (ll i = M-1; i >= 1; --i) {
        node1 = A[i].F, node2 = A[i].S;
        if (uf.issame(node1, node2)) {
            ans[i-1] = ans[i];
        } else {
            // 根が異なるとき，それぞれのサイズの積（頂点の組み合わせ）を引く．
            ans[i-1] = ans[i] - (uf.size(node1) * uf.size(node2));
            uf.merge(node1, node2);
        }
    }

    REP(i, M) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  set<int> D;
  for (int i = 0; i < K; i++) {
    int j;
    cin >> j;
    D.insert(j);
  }
  set<int> E;
  for (int i = 0; i < 10; i++)
    if (D.count(i) == 0 ) E.insert(i);
  
  vector<int> V;
  do {
    V.push_back(N % 10);
    N /= 10;
  } while (N > 0);
  int res = 0;
  int i = 0;
  while(i<V.size()) {
    if (E.count(V.at(i)) > 0) {
      res += V.at(i) * pow(10, i);
      i++;
      continue;
    }
    auto x = E.upper_bound(V.at(i));
    if (x == E.end()) {
      x = E.begin();
      res = 0;
      for (int j = 0; j <= i; j++ ) res = res * 10 + *x;
      i++;
      if (i >= V.size()) {
        V.push_back(*E.upper_bound(0));
        continue;
      } else {
        V.at(i)++;
      }
      continue;
    } else {
      res = *E.begin();
      for (int j = 1; j < i; j++) res = res * 10 + res;
      res += *x * pow(10, i);
      i++;
      continue;
    }
  } 
  cout << res << endl;
}

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  string ans;
  while(1){
    c-=b;
    if(c<=0){
      ans = "Yes";
      break;
    }
    a-=d;
    if(a<=0){
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<int> b(m);
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    int sum = accumulate(b.begin(), b.end(), 0);
    cout << (sum > n ? -1 : n - sum) << '\n';
}

Measured memory_bytes: 3684
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>

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

int main()
{
	ll X,Y;
	scanf("%lld %lld",&X,&Y);
	if(X%3==Y%3)
	{
		if(X==Y) puts("Brown");
		else puts("Alice");
	}
	else
	{
		if(X==Y+1||Y==X+1) puts("Brown");
		else puts("Alice");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
map<int,int>memo[3];
int sai(int r,int g,int b,int n,int sum,int q){
    int ans=0,es=0;
    if(q==0){
        if(memo[0].find(sum)!=memo[0].end()){
            ans+=memo[0][sum];
        }else if(sum+r==n){
            ans++;
        }else if(sum+r<n){
            ans+=sai(r,g,b,n,sum+r,0);
        }
        memo[0][sum]=ans;
    }
    es=ans;
    if(q<=1){
        if(memo[1].find(sum)!=memo[1].end()){
            ans+=memo[1][sum];
        }else if(sum+g==n){
            ans++;
        }else if(sum+g<n){
            ans+=sai(r,g,b,n,sum+g,1);
        }
        memo[1][sum]+=ans-es;
    }
    es=ans;
    if(memo[2].find(sum)!=memo[2].end()){
        ans+=memo[2][sum];
    }else if(sum+b==n){
        ans++;
    }else if(sum+b<n){
        ans+=sai(r,g,b,n,sum+b,2);
    }
    memo[2][sum]=ans-es;
    return(ans);
}
int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    cout<<sai(r,g,b,n,0,0)<<endl;
    return(0);
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var week = new List<string> { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
            Console.WriteLine(7 - week.IndexOf(str));
        }
    }
}


Measured memory_bytes: 13148
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(2);
  
using namespace std;
 
ll inf = 1e9;
const ll N = 1e6+10;
const ll bits = 30;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;
 
int main(){
    FASTIO;

    ll n,k,s;
    cin>>n>>k>>s;

    if(s==inf){
        inf--;
    }

    int ptr=0;

    while(k--){
        ptr++;
        cout<<s<<" ";
    }

    while(ptr<n){
        ptr++;
        cout<<inf<<" ";
    }



    
 
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

vector<int> primes;
typedef struct DP{
    int num;
    bool prime;
} DP;
DP dp[100010];

void erathosthenes(int n) {
    bool primeFlags[n+1];
    for (int i = 0; i <= n; i++) {
        primeFlags[i] = true;
    }
    primeFlags[0] = primeFlags[1] = false;
    vector<int> sqrtprimes;
    for (int i = 2; i*i <= n; i++) {
        bool mod0 = false;
        for (int j = 2; j*j <= i; j++) {
            if (i%j == 0) mod0 = true;
        }
        if (!mod0) sqrtprimes.push_back(i);
    }
    for (int i = 0; i < sqrtprimes.size(); i++) {
        for (int j = 2; j <= n; j++) {
            if (j%sqrtprimes[i] == 0) primeFlags[j] = false;
        }
    }
    for (int i = 0; i < sqrtprimes.size(); i++) primeFlags[sqrtprimes[i]] = true;
    for (int i = 1; i <= n; i++) {
        if (primeFlags[i]) primes.push_back(i);
    }
    return;
}
int main(int argc, char const *argv[]) {
    int Q;
    int MAX = 100005;
    cin >> Q;
    vector<int> l(Q); vector<int> r(Q);
    REP(i,Q) cin >> l[i] >> r[i];
    erathosthenes(MAX);
    REP(i,100002) {
        dp[i].num = 0;
        dp[i].prime = false;
    }
    for (auto x: primes) dp[x].prime = true;
    REP(i,100002) {
        dp[i+1].num = dp[i].num;
        if (dp[i+1].prime && dp[(i+2)/2].prime) {
            dp[i+1].num = dp[i].num+1;
        }
    }
    REP(i,Q) cout << dp[r[i]].num-dp[l[i]-1].num << std::endl;
    return 0;
}

Measured memory_bytes: 2432
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int v[] = new int[N];
        for (int i = 0;i<N;i++){
            v[i] = sc.nextInt();
        }
        Arrays.sort(v);
        double result = v[0];
        for (int i =1;i<N;i++){
            result = (result+v[i])/2.0;
        }
        System.out.println(result);

    }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k;
int h[300010], w[300010];
map<int, int> r, c;
vector<pii> rnd, col;
map<pii, bool> v;
map<int, bool> vr, vc;


int32_t main(){
INIT
cin>>n>>m>>k;

for(int i=1; i<=k; i++){
    cin>>h[i]>>w[i]; r[h[i]]++; c[w[i] ]++;
}
int res=0;

for(int i=1; i<=k; i++){
    res=max(r[h[i] ]+c[w[i] ]-1, res);
    if(!vr[h[i] ] ){
        rnd.pb(mp(r[h[i] ], h[i]) ); vr[h[i] ]=true;
    }
    if(!vc[w[i] ] ){
        col.pb(mp(c[w[i] ], w[i]) ); vc[w[i] ]=true;
    }
    v[mp(h[i], w[i]) ]=true;
}
//cout<<res<<"x\n";
sort(rnd.begin(), rnd.end());
sort(col.begin(), col.end());

for(int i=rnd.size()-1; i>=0; i-- ){
    if(!v[mp(rnd[i].sc, (col.back()).sc ) ] ){
        res=max(res, (col.back()).ft+rnd[i].ft );
        break;
    }
}
for(int i=col.size()-1; i>=0; i-- ){
    if(!v[mp( (rnd.back()).sc, col[i].sc )]) {
        res=max(res, (rnd.back()).ft+col[i].ft );
        break;
    }
}
cout<<res;
return 0;
}





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


int main()
{
	string a;
	cin >> a;
	if(a[2] == a[3] && a[4] == a[5])
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}



Measured memory_bytes: 3604
# -*- coding: utf-8 -*-
n = int(input())
x_list = list(map(int, input().split()))

val_min = 10000000000000000000000

for i in range(1, 101):
    val = 0
    for item in x_list:
        val += (item - i) ** 2
    if val < val_min:
        val_min = val

print(val_min)


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

#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

#define MAX_L 23
struct BIT {
  int n;
  vector<int> xs;
  BIT (int n) : n(n) {
    xs.resize(n+1);
  }
  void add(int i, int v) {
    for (int x=i+1; x<=n; x+=x&-x) xs[x] += v;
  }
  int sum(int i) {
    int s = 0;
    for (int x=i+1; x>0; x-=x&-x) s += xs[x];
    return s;
  }
  int sum(int a, int b) {
    return sum(b) - sum(a-1);
  }
};

int N, Q;
vector<int> G[150000];
int U[MAX_L][150000], R[150000];
vector<int> tour;
BIT a(0), b(0);
int IN[150000], OUT[150000];

void dfs(int s, int p, int r) {
  U[0][s] = p;
  R[s] = r;
  tour.pb(s);
  IN[s] = tour.size()-1;
  for (int t : G[s]) {
    if (t == p) continue;
    dfs(t, s, r+1);
  }
  tour.pb(s);
  OUT[s] = tour.size()-1;
}

int lca(int a, int b) {
  if (R[a] > R[b]) swap(a, b);
  for (int k=0; k<MAX_L; k++) {
    if ((R[a] - R[b]) >> k & 1) b = U[k][b];
  }
  if (a == b) return a;
  for (int k=MAX_L-1; k>=0; k--) {
    if (U[k][a] != U[k][b]) {
      a = U[k][a];
      b = U[k][b];
    }
  }
  return U[0][a];
}

int f(int x) {
  return R[x] * a.sum(IN[x]) + b.sum(IN[x]);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> Q;
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    G[a].pb(b);
    G[b].pb(a);
  }
  dfs(0, -1, 0);
  a = BIT(tour.size());
  b = BIT(tour.size());
  for (int i=0; i<MAX_L-1; i++) {
    for (int v=0; v<N; v++) {
      if (U[i][v] == -1) U[i+1][v] = -1;
      U[i+1][v] = U[i][U[i][v]];
    }
  }

  rep(i, Q) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 0) {
      cout << f(x) + f(y) - 2*f(lca(x, y)) << "\n";
    }
    else {
      a.add(IN[x], y);
      a.add(OUT[x], -y);
      b.add(IN[x], -(y * R[x]));
      b.add(OUT[x], (y * R[x]));
    }
  }
  return 0;
}

Measured memory_bytes: 57988
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n;
int a,b;
int flag;
int hai[100004];
int used[100004];
int h;
int ni;
int iti;
int color[100004];//1..sen 2..kou
vector<int> G[100004];
vector<int> par[100004];
void saiki(int p)
{
	used[p]=1;
	if(p==n-1)
	{
		hai[h]=p;h++;
		flag=1;
		return;
	}
	rep(i,G[p].size())
	{
		if(used[G[p][i]])continue;
		saiki(G[p][i]);
		if(flag)
		{
			hai[h++]=p;
			break;
		}
	}
}
void sai(int p)
{
	used[p]=1;
	rep(i,G[p].size())
	{
		if(used[G[p][i]]==1)continue;
		if(color[G[p][i]]==0)
		{
			color[G[p][i]]=color[p];
			sai(G[p][i]);
		}
		else sai(G[p][i]);
	}
}
int main()
{
	cin>>n;
	rep(i,n-1)
	{
		cin>>a>>b;
		G[a-1].push_back(b-1);
		G[b-1].push_back(a-1);
	}
	saiki(0);
	if(1)
	{
		rep(i,h)
		{
			if(i<h/2)
			{
				color[hai[i]]=2;
			}
			else color[hai[i]]=1;
		}
	}
	rep(i,n)used[i]=0;
	sai(0);
	rep(i,n)
	{
		if(color[i]==1)iti++;
		else ni++;
	}
	if(iti>ni)cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
	return 0;
}

Measured memory_bytes: 13952
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	s := next()

	if s[0] != 'A' {
		fmt.Println("WA")
		return
	}

	cPos := -1
	for i := 2; i < len(s)-1; i++ {
		if s[i] == 'C' {
			if cPos != -1 {
				fmt.Println("WA")
				return
			}
			cPos = i
		}
	}
	if cPos == -1 {
		fmt.Println("WA")
		return
	}

	b := []byte(s)
	b = append(b[1:cPos], b[cPos+1:]...)
	l := bytes.ToLower(b)

	for i := 0; i < len(b); i++ {
		if b[i] != l[i] {
			fmt.Println("WA")
			return
		}
	}

	fmt.Println("AC")
}

Measured memory_bytes: 640
from sys import stdout
n = int(input())
i = 1

while True:
    x = i
    if x % 3 == 0:
        stdout.write(" " + str(i))
    else:
        while x:
            if x % 10 == 3:
                stdout.write(" " + str(i))
                break
            x //= 10
    i += 1
    if i > n: break
print()


Measured memory_bytes: 5724
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int N;	cin>>N;
	vi A(N);
	rep(i,0,N){
		cin>>A[i];
	}
	vi ans(N);
	rep(i,0,N){
		ans[A[i]-1]=i+1;
	}
	rep(i,0,N){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3996